- Added a testsuite for the plugin
- Some cleaning up and documenting of the code.
diff --git a/pom.xml b/pom.xml
index ddd6b28..bbe6867 100644
--- a/pom.xml
+++ b/pom.xml
@@ -505,7 +505,7 @@
<version>1.0.0-SNAPSHOT</version>
<executions>
<execution>
- <id>strip-test-jars</id>
+ <id>filter-test-jars</id>
<phase>install</phase>
<goals>
<goal>filter-test-jars</goal>
diff --git a/utils/edgent-deployment-filter-maven-plugin/pom.xml b/utils/edgent-deployment-filter-maven-plugin/pom.xml
index 4036b21..a3ed058 100644
--- a/utils/edgent-deployment-filter-maven-plugin/pom.xml
+++ b/utils/edgent-deployment-filter-maven-plugin/pom.xml
@@ -77,7 +77,7 @@
<artifactId>maven-plugin-plugin</artifactId>
<version>3.2</version>
<configuration>
- <goalPrefix>edgent-deployment-filter-maven-plugin</goalPrefix>
+ <goalPrefix>edgent-deployment-filter</goalPrefix>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
@@ -95,26 +95,32 @@
<profile>
<id>run-its</id>
<build>
-
<plugins>
<plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>mrm-maven-plugin</artifactId>
+ <version>1.1.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>start</goal>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <propertyName>mrm.distribution.url</propertyName>
+ <repositories>
+ <hostedRepo>
+ <target>${project.build.directory}/maven-repos/remote</target>
+ </hostedRepo>
+ </repositories>
+ </configuration>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
- <version>1.7</version>
- <configuration>
- <debug>true</debug>
- <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
- <pomIncludes>
- <pomInclude>*/pom.xml</pomInclude>
- </pomIncludes>
- <postBuildHookScript>verify</postBuildHookScript>
- <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
- <settingsFile>src/it/settings.xml</settingsFile>
- <goals>
- <goal>clean</goal>
- <goal>test-compile</goal>
- </goals>
- </configuration>
+ <version>3.0.1</version>
<executions>
<execution>
<id>integration-test</id>
@@ -125,9 +131,25 @@
</goals>
</execution>
</executions>
+ <configuration>
+ <debug>false</debug>
+ <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+ <pomIncludes>
+ <pomInclude>*/pom.xml</pomInclude>
+ </pomIncludes>
+ <postBuildHookScript>verify</postBuildHookScript>
+ <localRepositoryPath>${project.build.directory}/maven-repos/local</localRepositoryPath>
+ <settingsFile>src/it/settings.xml</settingsFile>
+ <goals>
+ <goal>clean</goal>
+ <goal>deploy</goal>
+ </goals>
+ <filterProperties>
+ <mrm.distribution.url>${mrm.distribution.url}</mrm.distribution.url>
+ </filterProperties>
+ </configuration>
</plugin>
</plugins>
-
</build>
</profile>
</profiles>
diff --git a/utils/edgent-deployment-filter-maven-plugin/src/it/simple-it/verify.groovy b/utils/edgent-deployment-filter-maven-plugin/src/it/simple-it/verify.groovy
deleted file mode 100644
index de904ae..0000000
--- a/utils/edgent-deployment-filter-maven-plugin/src/it/simple-it/verify.groovy
+++ /dev/null
@@ -1,22 +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.
-*/
-
-File touchFile = new File( basedir, "target/touch.txt" );
-
-assert touchFile.isFile()
diff --git a/utils/edgent-deployment-filter-maven-plugin/src/it/simple-it/pom.xml b/utils/edgent-deployment-filter-maven-plugin/src/it/with-plugin/pom.xml
similarity index 65%
copy from utils/edgent-deployment-filter-maven-plugin/src/it/simple-it/pom.xml
copy to utils/edgent-deployment-filter-maven-plugin/src/it/with-plugin/pom.xml
index aff476c..b59f56f 100644
--- a/utils/edgent-deployment-filter-maven-plugin/src/it/simple-it/pom.xml
+++ b/utils/edgent-deployment-filter-maven-plugin/src/it/with-plugin/pom.xml
@@ -21,8 +21,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>19</version>
+ </parent>
+
<groupId>org.apache.edgent.plugins.it</groupId>
- <artifactId>simple-it</artifactId>
+ <artifactId>with-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<description>A simple IT verifying the basic use case.</description>
@@ -31,18 +37,43 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
+ <distributionManagement>
+ <repository>
+ <id>mrm</id>
+ <url>@mrm.distribution.url@</url>
+ </repository>
+ <snapshotRepository>
+ <id>mrm</id>
+ <url>@mrm.distribution.url@</url>
+ </snapshotRepository>
+ </distributionManagement>
+
<build>
<plugins>
+ <!-- Create a test-jar -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Ensure it's not deployed -->
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
- <id>touch</id>
- <phase>validate</phase>
+ <id>filter-test-jars</id>
+ <phase>install</phase>
<goals>
- <goal>touch</goal>
+ <goal>filter-test-jars</goal>
</goals>
</execution>
</executions>
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
new file mode 100644
index 0000000..c376a30
--- /dev/null
+++ b/utils/edgent-deployment-filter-maven-plugin/src/it/with-plugin/verify.groovy
@@ -0,0 +1,53 @@
+/*
+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.
+*/
+
+import groovy.io.FileType
+
+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")
+
+// The jar file should exist
+assert jarFile.exists() && jarFile.isFile()
+
+// The test-jar should also exist
+assert testJarFile.exists() && testJarFile.isFile()
+
+// The local repo should contain the test-jar.
+def jarLocalRepo = new File("target/maven-repos/local/org/apache/edgent/plugins/it/with-plugin/1.0-SNAPSHOT")
+assert jarLocalRepo.exists()
+def foundTestJarInLocal = false
+jarLocalRepo.eachFileRecurse (FileType.FILES) { file ->
+ println file.name
+ if(file.name.endsWith("tests.jar")) {
+ foundTestJarInLocal = true
+ }
+}
+assert foundTestJarInLocal
+
+// The remote repo shouldn't contain it.
+def jarRemoteRepo = new File("target/maven-repos/remote/org/apache/edgent/plugins/it/with-plugin/1.0-SNAPSHOT")
+assert jarRemoteRepo.exists()
+def foundTestJarInRemote = false
+jarRemoteRepo.eachFileRecurse (FileType.FILES) { file ->
+ println file.name
+ if(file.name.endsWith("tests.jar")) {
+ foundTestJarInRemote = true
+ }
+}
+assert !foundTestJarInRemote
diff --git a/utils/edgent-deployment-filter-maven-plugin/src/it/simple-it/pom.xml b/utils/edgent-deployment-filter-maven-plugin/src/it/without-plugin/pom.xml
similarity index 68%
rename from utils/edgent-deployment-filter-maven-plugin/src/it/simple-it/pom.xml
rename to utils/edgent-deployment-filter-maven-plugin/src/it/without-plugin/pom.xml
index aff476c..cea659b 100644
--- a/utils/edgent-deployment-filter-maven-plugin/src/it/simple-it/pom.xml
+++ b/utils/edgent-deployment-filter-maven-plugin/src/it/without-plugin/pom.xml
@@ -21,28 +21,43 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>19</version>
+ </parent>
+
<groupId>org.apache.edgent.plugins.it</groupId>
- <artifactId>simple-it</artifactId>
+ <artifactId>without-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
- <description>A simple IT verifying the basic use case.</description>
+ <description>A simple IT verifying a build without the plugin.</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
+ <distributionManagement>
+ <repository>
+ <id>mrm</id>
+ <url>@mrm.distribution.url@</url>
+ </repository>
+ <snapshotRepository>
+ <id>mrm</id>
+ <url>@mrm.distribution.url@</url>
+ </snapshotRepository>
+ </distributionManagement>
+
<build>
<plugins>
+ <!-- Create a test-jar -->
<plugin>
- <groupId>@project.groupId@</groupId>
- <artifactId>@project.artifactId@</artifactId>
- <version>@project.version@</version>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
- <id>touch</id>
- <phase>validate</phase>
<goals>
- <goal>touch</goal>
+ <goal>test-jar</goal>
</goals>
</execution>
</executions>
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
new file mode 100644
index 0000000..e294108
--- /dev/null
+++ b/utils/edgent-deployment-filter-maven-plugin/src/it/without-plugin/verify.groovy
@@ -0,0 +1,53 @@
+/*
+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.
+*/
+
+import groovy.io.FileType
+
+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")
+
+// The jar file should exist
+assert jarFile.exists() && jarFile.isFile()
+
+// The test-jar should also exist
+assert testJarFile.exists() && testJarFile.isFile()
+
+// The local repo should contain the test-jar.
+def jarLocalRepo = new File("target/maven-repos/local/org/apache/edgent/plugins/it/without-plugin/1.0-SNAPSHOT")
+assert jarLocalRepo.exists()
+def foundTestJarInLocal = false
+jarLocalRepo.eachFileRecurse (FileType.FILES) { file ->
+ println file.name
+ if(file.name.endsWith("tests.jar")) {
+ foundTestJarInLocal = true
+ }
+}
+assert foundTestJarInLocal
+
+// The remote repo should contain it too.
+def jarRemoteRepo = new File("target/maven-repos/remote/org/apache/edgent/plugins/it/without-plugin/1.0-SNAPSHOT")
+assert jarRemoteRepo.exists()
+def foundTestJarInRemote = false
+jarRemoteRepo.eachFileRecurse (FileType.FILES) { file ->
+ println file.name
+ if(file.name.endsWith("tests.jar")) {
+ foundTestJarInRemote = true
+ }
+}
+assert foundTestJarInRemote
diff --git a/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/DeploymentFilterMojo.java b/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/FilterTestJarsMojo.java
similarity index 76%
rename from utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/DeploymentFilterMojo.java
rename to utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/FilterTestJarsMojo.java
index 978b219..7e90550 100644
--- a/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/DeploymentFilterMojo.java
+++ b/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/FilterTestJarsMojo.java
@@ -36,7 +36,7 @@
* 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 DeploymentFilterMojo
+public class FilterTestJarsMojo
extends AbstractMojo
{
@@ -46,16 +46,23 @@
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())) {
toBeRemovedArtifacts.add(artifact);
}
}
- for(Artifact toBeRemovedArtifact : toBeRemovedArtifacts) {
- getLog().info(" - Excluding test-jar artifact " + toBeRemovedArtifact.getArtifactId() +
- " from deployment.");
- project.getAttachedArtifacts().remove(toBeRemovedArtifact);
+
+ // 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);
+ }
}
}
}