use of org.apache.maven.plugins.shade.filter.MinijarFilter in project maven-plugins by apache.
the class ShadeMojo method getFilters.
private List<Filter> getFilters() throws MojoExecutionException {
List<Filter> filters = new ArrayList<Filter>();
List<SimpleFilter> simpleFilters = new ArrayList<SimpleFilter>();
if (this.filters != null && this.filters.length > 0) {
Map<Artifact, ArtifactId> artifacts = new HashMap<Artifact, ArtifactId>();
artifacts.put(project.getArtifact(), new ArtifactId(project.getArtifact()));
for (Artifact artifact : project.getArtifacts()) {
artifacts.put(artifact, new ArtifactId(artifact));
}
for (ArchiveFilter filter : this.filters) {
ArtifactId pattern = new ArtifactId(filter.getArtifact());
Set<File> jars = new HashSet<File>();
for (Map.Entry<Artifact, ArtifactId> entry : artifacts.entrySet()) {
if (entry.getValue().matches(pattern)) {
Artifact artifact = entry.getKey();
jars.add(artifact.getFile());
if (createSourcesJar) {
File file = resolveArtifactSources(artifact);
if (file != null) {
jars.add(file);
}
}
}
}
if (jars.isEmpty()) {
getLog().info("No artifact matching filter " + filter.getArtifact());
continue;
}
simpleFilters.add(new SimpleFilter(jars, filter.getIncludes(), filter.getExcludes()));
}
}
filters.addAll(simpleFilters);
if (minimizeJar) {
getLog().info("Minimizing jar " + project.getArtifact());
try {
filters.add(new MinijarFilter(project, getLog(), simpleFilters));
} catch (IOException e) {
throw new MojoExecutionException("Failed to analyze class dependencies", e);
}
}
return filters;
}
Aggregations