diff --git a/src/it/buildinfo-multi/pom.xml b/src/it/buildinfo-multi/pom.xml index 0bf5e32..019be16 100644 --- a/src/it/buildinfo-multi/pom.xml +++ b/src/it/buildinfo-multi/pom.xml @@ -56,6 +56,18 @@ + + org.spdx + spdx-maven-plugin + 0.7.0 + + + + createSPDX + + + + @project.groupId@ @project.artifactId@ @@ -65,6 +77,11 @@ buildinfo + + + */*.spdx.json + + diff --git a/src/it/buildinfo-multi/verify.groovy b/src/it/buildinfo-multi/verify.groovy index 81e47b1..7d5a3df 100644 --- a/src/it/buildinfo-multi/verify.groovy +++ b/src/it/buildinfo-multi/verify.groovy @@ -39,9 +39,11 @@ assert buildinfo.contains( "version=1.0-SNAPSHOT" ) assert buildinfo.contains( "outputs.1.coordinates=org.apache.maven.plugins.it:multi-modA" ) assert buildinfo.contains( "outputs.1.0.filename=multi-modA-1.0-SNAPSHOT.pom" ) assert buildinfo.contains( "outputs.1.1.filename=multi-modA-1.0-SNAPSHOT.jar" ) +assert !buildinfo.contains( "outputs.1.2.filename=" ) assert buildinfo.contains( "outputs.2.coordinates=org.apache.maven.plugins.it:multi-modB" ) assert buildinfo.contains( "outputs.2.0.filename=multi-modB-1.0-SNAPSHOT.pom" ) assert buildinfo.contains( "outputs.2.1.filename=multi-modB-1.0-SNAPSHOT.jar" ) +assert !buildinfo.contains( "outputs.2.2.filename=" ) assert !buildinfo.contains( ".buildinfo" ) assert buildinfo.contains( "mvn.aggregate.artifact-id=multi-modB" ) diff --git a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java index b7574dc..3c57eb4 100644 --- a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java +++ b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java @@ -29,7 +29,6 @@ import java.util.Date; import java.util.List; import java.util.Map; -import java.util.Set; import org.apache.maven.archiver.MavenArchiver; import org.apache.maven.artifact.Artifact; @@ -79,10 +78,10 @@ public abstract class AbstractBuildinfoMojo extends AbstractMojo { private boolean ignoreJavadoc; /** - * Artifacts to ignore, specified as extension or classifier.extension. + * Artifacts to ignore, specified as a glob matching against {@code groupId/filename}. */ @Parameter(property = "buildinfo.ignore", defaultValue = "") - private Set ignore; + private List ignore; /** * Detect projects/modules with install or deploy skipped: avoid taking fingerprints. diff --git a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildInfoWriter.java b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildInfoWriter.java index cb3d46d..5e731b1 100644 --- a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildInfoWriter.java +++ b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildInfoWriter.java @@ -22,14 +22,9 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Properties; -import java.util.Set; +import java.nio.file.*; +import java.util.*; +import java.util.stream.Collectors; import org.apache.commons.codec.digest.DigestUtils; import org.apache.maven.artifact.Artifact; @@ -55,7 +50,7 @@ class BuildInfoWriter { private final Map artifacts = new LinkedHashMap<>(); private int projectCount = -1; private boolean ignoreJavadoc = true; - private Set ignore; + private List ignore; private Toolchain toolchain; BuildInfoWriter( @@ -223,6 +218,7 @@ void printArtifacts(MavenProject project) throws MojoExecutionException { continue; } if (isIgnore(attached)) { + // TODO keep track of ignored attachments continue; } printArtifact(prefix, n++, attached); @@ -317,15 +313,14 @@ void setIgnoreJavadoc(boolean ignoreJavadoc) { this.ignoreJavadoc = ignoreJavadoc; } - void setIgnore(Set ignore) { - this.ignore = ignore; + void setIgnore(List ignore) { + FileSystem fs = FileSystems.getDefault(); + this.ignore = ignore.stream().map(i -> fs.getPathMatcher("glob:" + i)).collect(Collectors.toList()); } private boolean isIgnore(Artifact attached) { - String classifier = attached.getClassifier(); - String extension = attached.getType(); - String search = (classifier == null) ? "" : (classifier + '.') + extension; - return ignore.contains(search); + Path path = Paths.get(attached.getGroupId() + '/' + getArtifactFilename(attached)); + return ignore.stream().anyMatch(m -> m.matches(path)); } public void setToolchain(Toolchain toolchain) {