Updated the plugin to use configuration for the filtering instead of hard-coded filter rules
diff --git a/utils/edgent-deployment-filter-maven-plugin/pom.xml b/utils/edgent-deployment-filter-maven-plugin/pom.xml
index 64bbf7e..312a7c3 100644
--- a/utils/edgent-deployment-filter-maven-plugin/pom.xml
+++ b/utils/edgent-deployment-filter-maven-plugin/pom.xml
@@ -59,6 +59,13 @@
<artifactId>plexus-utils</artifactId>
<version>3.0.8</version>
</dependency>
+
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ <version>1.3</version>
+ </dependency>
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
diff --git a/utils/edgent-deployment-filter-maven-plugin/src/it/with-plugin/pom.xml b/utils/edgent-deployment-filter-maven-plugin/src/it/with-plugin/pom.xml
index 26dc3cf..466bd6f 100644
--- a/utils/edgent-deployment-filter-maven-plugin/src/it/with-plugin/pom.xml
+++ b/utils/edgent-deployment-filter-maven-plugin/src/it/with-plugin/pom.xml
@@ -70,11 +70,28 @@
<version>@project.version@</version>
<executions>
<execution>
- <id>filter-test-jars</id>
+ <id>filter-deploy-artifacts</id>
<phase>install</phase>
<goals>
- <goal>filter-test-jars</goal>
+ <goal>filter-deploy-artifacts</goal>
</goals>
+ <configuration>
+ <filterRules>
+ <!-- Filter out all test-jars -->
+ <filterRule>
+ <type>test-jar</type>
+ </filterRule>
+ <!-- Filter out the signatures of all test-jars -->
+ <filterRule>
+ <type>jar.asc</type>
+ <classifier>tests</classifier>
+ </filterRule>
+ <!-- Filter out any source release archives -->
+ <filterRule>
+ <classifier>source-release</classifier>
+ </filterRule>
+ </filterRules>
+ </configuration>
</execution>
</executions>
</plugin>
@@ -116,6 +133,33 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.apache.resources</groupId>
+ <artifactId>apache-source-release-assembly-descriptor</artifactId>
+ <version>1.0.6</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>source-release-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <runOnlyAtExecutionRoot>true</runOnlyAtExecutionRoot>
+ <descriptorRefs>
+ <descriptorRef>${sourceReleaseAssemblyDescriptor}</descriptorRef>
+ </descriptorRefs>
+ <tarLongFileMode>posix</tarLongFileMode>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/utils/edgent-deployment-filter-maven-plugin/src/it/with-plugin/verify.groovy b/utils/edgent-deployment-filter-maven-plugin/src/it/with-plugin/verify.groovy
index c376a30..58286d4 100644
--- a/utils/edgent-deployment-filter-maven-plugin/src/it/with-plugin/verify.groovy
+++ b/utils/edgent-deployment-filter-maven-plugin/src/it/with-plugin/verify.groovy
@@ -21,33 +21,66 @@
def jarFile = new File(basedir, "target/with-plugin-1.0-SNAPSHOT.jar")
def testJarFile = new File(basedir, "target/with-plugin-1.0-SNAPSHOT-tests.jar")
+def testJarAscFile = new File(basedir, "target/with-plugin-1.0-SNAPSHOT-tests.jar.asc")
+def sourceReleaseFile = new File(basedir, "target/with-plugin-1.0-SNAPSHOT-source-release.zip")
+def sourceReleaseAscFile = new File(basedir, "target/with-plugin-1.0-SNAPSHOT-source-release.zip.asc")
// The jar file should exist
assert jarFile.exists() && jarFile.isFile()
-// The test-jar should also exist
+// The test-jar and it's signature should also exist
assert testJarFile.exists() && testJarFile.isFile()
+assert testJarAscFile.exists() && testJarAscFile.isFile()
-// The local repo should contain the test-jar.
+// The source release zip and it's signature should exist
+assert sourceReleaseFile.exists() && sourceReleaseFile.isFile()
+assert sourceReleaseAscFile.exists() && sourceReleaseAscFile.isFile()
+
+// The local repo should contain all files.
def jarLocalRepo = new File("target/maven-repos/local/org/apache/edgent/plugins/it/with-plugin/1.0-SNAPSHOT")
assert jarLocalRepo.exists()
def foundTestJarInLocal = false
+def foundTestJarAscInLocal = false
+def foundSourceReleaseZipInLocal = false
+def foundSourceReleaseZipAscInLocal = false
jarLocalRepo.eachFileRecurse (FileType.FILES) { file ->
println file.name
if(file.name.endsWith("tests.jar")) {
foundTestJarInLocal = true
}
+ if(file.name.endsWith("tests.jar.asc")) {
+ foundTestJarAscInLocal = true
+ }
+ if(file.name.endsWith("source-release.zip")) {
+ foundSourceReleaseZipInLocal = true
+ }
+ if(file.name.endsWith("source-release.zip.asc")) {
+ foundSourceReleaseZipAscInLocal = true
+ }
}
-assert foundTestJarInLocal
+assert foundTestJarInLocal && foundTestJarAscInLocal && foundSourceReleaseZipInLocal && foundSourceReleaseZipAscInLocal
-// The remote repo shouldn't contain it.
+// The remote repo shouldn't not contain test-jar and source-release and their corresponding signatures.
def jarRemoteRepo = new File("target/maven-repos/remote/org/apache/edgent/plugins/it/with-plugin/1.0-SNAPSHOT")
assert jarRemoteRepo.exists()
def foundTestJarInRemote = false
+def foundTestJarAscInRemote = false
+def foundSourceReleaseZipInRemote = false
+def foundSourceReleaseZipAscInRemote = false
jarRemoteRepo.eachFileRecurse (FileType.FILES) { file ->
println file.name
if(file.name.endsWith("tests.jar")) {
foundTestJarInRemote = true
}
+ if(file.name.endsWith("tests.jar.asc")) {
+ foundTestJarAscInRemote = true
+ }
+ if(file.name.endsWith("source-release.zip")) {
+ foundSourceReleaseZipInRemote = true
+ }
+ if(file.name.endsWith("source-release.zip.asc")) {
+ foundSourceReleaseZipAscInRemote = true
+ }
}
-assert !foundTestJarInRemote
+assert !foundTestJarInRemote && !foundTestJarAscInRemote && !foundSourceReleaseZipInRemote && !foundSourceReleaseZipAscInRemote
+
diff --git a/utils/edgent-deployment-filter-maven-plugin/src/it/without-plugin/pom.xml b/utils/edgent-deployment-filter-maven-plugin/src/it/without-plugin/pom.xml
index e90f322..002017b 100644
--- a/utils/edgent-deployment-filter-maven-plugin/src/it/without-plugin/pom.xml
+++ b/utils/edgent-deployment-filter-maven-plugin/src/it/without-plugin/pom.xml
@@ -101,6 +101,33 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.apache.resources</groupId>
+ <artifactId>apache-source-release-assembly-descriptor</artifactId>
+ <version>1.0.6</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>source-release-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <runOnlyAtExecutionRoot>true</runOnlyAtExecutionRoot>
+ <descriptorRefs>
+ <descriptorRef>${sourceReleaseAssemblyDescriptor}</descriptorRef>
+ </descriptorRefs>
+ <tarLongFileMode>posix</tarLongFileMode>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/utils/edgent-deployment-filter-maven-plugin/src/it/without-plugin/verify.groovy b/utils/edgent-deployment-filter-maven-plugin/src/it/without-plugin/verify.groovy
index e294108..ea7d39b 100644
--- a/utils/edgent-deployment-filter-maven-plugin/src/it/without-plugin/verify.groovy
+++ b/utils/edgent-deployment-filter-maven-plugin/src/it/without-plugin/verify.groovy
@@ -21,33 +21,65 @@
def jarFile = new File(basedir, "target/without-plugin-1.0-SNAPSHOT.jar")
def testJarFile = new File(basedir, "target/without-plugin-1.0-SNAPSHOT-tests.jar")
+def testJarAscFile = new File(basedir, "target/without-plugin-1.0-SNAPSHOT-tests.jar.asc")
+def sourceReleaseFile = new File(basedir, "target/without-plugin-1.0-SNAPSHOT-source-release.zip")
+def sourceReleaseAscFile = new File(basedir, "target/without-plugin-1.0-SNAPSHOT-source-release.zip.asc")
// The jar file should exist
assert jarFile.exists() && jarFile.isFile()
-// The test-jar should also exist
+// The test-jar and it's signature should also exist
assert testJarFile.exists() && testJarFile.isFile()
+assert testJarAscFile.exists() && testJarAscFile.isFile()
-// The local repo should contain the test-jar.
+// The source release zip and it's signature should exist
+assert sourceReleaseFile.exists() && sourceReleaseFile.isFile()
+assert sourceReleaseAscFile.exists() && sourceReleaseAscFile.isFile()
+
+// The local repo should contain all expected files.
def jarLocalRepo = new File("target/maven-repos/local/org/apache/edgent/plugins/it/without-plugin/1.0-SNAPSHOT")
assert jarLocalRepo.exists()
def foundTestJarInLocal = false
+def foundTestJarAscInLocal = false
+def foundSourceReleaseZipInLocal = false
+def foundSourceReleaseZipAscInLocal = false
jarLocalRepo.eachFileRecurse (FileType.FILES) { file ->
println file.name
if(file.name.endsWith("tests.jar")) {
foundTestJarInLocal = true
}
+ if(file.name.endsWith("tests.jar.asc")) {
+ foundTestJarAscInLocal = true
+ }
+ if(file.name.endsWith("source-release.zip")) {
+ foundSourceReleaseZipInLocal = true
+ }
+ if(file.name.endsWith("source-release.zip.asc")) {
+ foundSourceReleaseZipAscInLocal = true
+ }
}
-assert foundTestJarInLocal
+assert foundTestJarInLocal && foundTestJarAscInLocal && foundSourceReleaseZipInLocal && foundSourceReleaseZipAscInLocal
-// The remote repo should contain it too.
+// The remote repo should also contain all of them.
def jarRemoteRepo = new File("target/maven-repos/remote/org/apache/edgent/plugins/it/without-plugin/1.0-SNAPSHOT")
assert jarRemoteRepo.exists()
def foundTestJarInRemote = false
+def foundTestJarAscInRemote = false
+def foundSourceReleaseZipInRemote = false
+def foundSourceReleaseZipAscInRemote = false
jarRemoteRepo.eachFileRecurse (FileType.FILES) { file ->
println file.name
if(file.name.endsWith("tests.jar")) {
foundTestJarInRemote = true
}
+ if(file.name.endsWith("tests.jar.asc")) {
+ foundTestJarAscInRemote = true
+ }
+ if(file.name.endsWith("source-release.zip")) {
+ foundSourceReleaseZipInRemote = true
+ }
+ if(file.name.endsWith("source-release.zip.asc")) {
+ foundSourceReleaseZipAscInRemote = true
+ }
}
-assert foundTestJarInRemote
+assert foundTestJarInRemote && foundTestJarAscInLocal && foundSourceReleaseZipInLocal && foundSourceReleaseZipAscInLocal
diff --git a/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/FilterDeployArtifactsMojo.java b/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/FilterDeployArtifactsMojo.java
new file mode 100644
index 0000000..13b427e
--- /dev/null
+++ b/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/FilterDeployArtifactsMojo.java
@@ -0,0 +1,111 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+package org.apache.edgent.plugins.deploymentfilter;
+
+import org.apache.edgent.plugins.deploymentfilter.model.FilterRule;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.hamcrest.Matcher;
+import org.hamcrest.beans.HasPropertyWithValue;
+import org.hamcrest.core.AllOf;
+import org.hamcrest.core.AnyOf;
+import org.hamcrest.core.IsEqual;
+import org.sonatype.aether.util.StringUtils;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Goal which filters all 'test-jar' artifacts from installation and deployment.
+ * The goal is added to the 'install' phase as this way it is executed after the install plugin,
+ * but before the deploy, which is the phase we don't want the artifact to be handled.
+ */
+@Mojo( name = "filter-deploy-artifacts", defaultPhase = LifecyclePhase.INSTALL )
+public class FilterDeployArtifactsMojo
+ extends AbstractMojo
+{
+
+ @Parameter(defaultValue="${project}")
+ private MavenProject project;
+
+ @Parameter
+ private List<FilterRule> filterRules;
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ List<Matcher<? super Artifact>> filter = new LinkedList<Matcher<? super Artifact>>();
+ for (FilterRule filterRule : filterRules) {
+ List<Matcher<? super Artifact>> curFilter = new LinkedList<Matcher<? super Artifact>>();
+ if(!StringUtils.isEmpty(filterRule.getType())) {
+ curFilter.add(HasPropertyWithValue.hasProperty("type",
+ IsEqual.equalTo(filterRule.getType())));
+ }
+ if(!StringUtils.isEmpty(filterRule.getClassifier())) {
+ curFilter.add(HasPropertyWithValue.hasProperty("classifier",
+ IsEqual.equalTo(filterRule.getClassifier())));
+ }
+ if(!StringUtils.isEmpty(filterRule.getGroupId())) {
+ curFilter.add(HasPropertyWithValue.hasProperty("groupId",
+ IsEqual.equalTo(filterRule.getGroupId())));
+ }
+ if(!StringUtils.isEmpty(filterRule.getArtifactId())) {
+ curFilter.add(HasPropertyWithValue.hasProperty("artifactId",
+ IsEqual.equalTo(filterRule.getArtifactId())));
+ }
+ if(!StringUtils.isEmpty(filterRule.getVersion())) {
+ curFilter.add(HasPropertyWithValue.hasProperty("version",
+ IsEqual.equalTo(filterRule.getVersion())));
+ }
+ if(!StringUtils.isEmpty(filterRule.getScope())) {
+ curFilter.add(HasPropertyWithValue.hasProperty("scope",
+ IsEqual.equalTo(filterRule.getScope())));
+ }
+ if(!curFilter.isEmpty()) {
+ filter.add(new AllOf<Artifact>(curFilter));
+ }
+ }
+ AnyOf<Artifact> matcher = new AnyOf<Artifact>(filter);
+
+ // Find all 'test-jar' artifacts.
+ // (This has to be done in separate loops in order to prevent
+ // concurrent modification exceptions.
+ List<Artifact> toBeRemovedArtifacts = new LinkedList<Artifact>();
+ for(Artifact artifact : project.getAttachedArtifacts()) {
+ if(matcher.matches(artifact)) {
+ toBeRemovedArtifacts.add(artifact);
+ }
+ }
+
+ // Remove all of them from the list of attached artifacts.
+ if(!toBeRemovedArtifacts.isEmpty()) {
+ for (Artifact toBeRemovedArtifact : toBeRemovedArtifacts) {
+ getLog().info(" - Excluding artifact " + toBeRemovedArtifact.getArtifactId() +
+ " from deployment.");
+ project.getAttachedArtifacts().remove(toBeRemovedArtifact);
+ }
+ }
+ }
+}
diff --git a/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/FilterTestJarsMojo.java b/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/FilterTestJarsMojo.java
deleted file mode 100644
index 0315f19..0000000
--- a/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/FilterTestJarsMojo.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-package org.apache.edgent.plugins.deploymentfilter;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.MavenProject;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Goal which filters all 'test-jar' artifacts from installation and deployment.
- * The goal is added to the 'install' phase as this way it is executed after the install plugin,
- * but before the deploy, which is the phase we don't want the artifact to be handled.
- */
-@Mojo( name = "filter-test-jars", defaultPhase = LifecyclePhase.INSTALL )
-public class FilterTestJarsMojo
- extends AbstractMojo
-{
-
- @Parameter(defaultValue="${project}")
- private MavenProject project;
-
- public void execute()
- throws MojoExecutionException
- {
- // Find all 'test-jar' artifacts.
- // (This has to be done in separate loops in order to prevent
- // concurrent modification exceptions.
- List<Artifact> toBeRemovedArtifacts = new LinkedList<Artifact>();
- for(Artifact artifact : project.getAttachedArtifacts()) {
- if("test-jar".equals(artifact.getType()) ||
- ("jar.asc".equals(artifact.getType()) && "tests".equals(artifact.getClassifier()))) {
- toBeRemovedArtifacts.add(artifact);
- }
- }
-
- // Remove all of them from the list of attached artifacts.
- if(!toBeRemovedArtifacts.isEmpty()) {
- for (Artifact toBeRemovedArtifact : toBeRemovedArtifacts) {
- getLog().info(" - Excluding test-jar artifact " + toBeRemovedArtifact.getArtifactId() +
- " from deployment.");
- project.getAttachedArtifacts().remove(toBeRemovedArtifact);
- }
- }
- }
-}
diff --git a/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/model/FilterRule.java b/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/model/FilterRule.java
new file mode 100644
index 0000000..e5c72ad
--- /dev/null
+++ b/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/model/FilterRule.java
@@ -0,0 +1,58 @@
+package org.apache.edgent.plugins.deploymentfilter.model;
+
+public class FilterRule {
+ private String groupId;
+ private String artifactId;
+ private String version;
+ private String type;
+ private String classifier;
+ private String scope;
+
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(String groupId) {
+ this.groupId = groupId;
+ }
+
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ public void setArtifactId(String artifactId) {
+ this.artifactId = artifactId;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getClassifier() {
+ return classifier;
+ }
+
+ public void setClassifier(String classifier) {
+ this.classifier = classifier;
+ }
+
+ public String getScope() {
+ return scope;
+ }
+
+ public void setScope(String scope) {
+ this.scope = scope;
+ }
+}