- Added a testsuite for the plugin
- Some cleaning up and documenting of the code.


Project: http://git-wip-us.apache.org/repos/asf/incubator-edgent/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-edgent/commit/c7185534
Tree: http://git-wip-us.apache.org/repos/asf/incubator-edgent/tree/c7185534
Diff: http://git-wip-us.apache.org/repos/asf/incubator-edgent/diff/c7185534

Branch: refs/heads/develop
Commit: c7185534d739265791d02a7b99a51aa074e3344d
Parents: c522bdf
Author: Christofer Dutz <christofer.d...@c-ware.de>
Authored: Thu Feb 1 17:07:34 2018 +0100
Committer: Christofer Dutz <christofer.d...@c-ware.de>
Committed: Thu Feb 1 17:07:34 2018 +0100

----------------------------------------------------------------------
 pom.xml                                         |  2 +-
 .../pom.xml                                     | 56 +++++++++----
 .../src/it/simple-it/pom.xml                    | 52 ------------
 .../src/it/simple-it/verify.groovy              | 22 ------
 .../src/it/with-plugin/pom.xml                  | 83 ++++++++++++++++++++
 .../src/it/with-plugin/verify.groovy            | 53 +++++++++++++
 .../src/it/without-plugin/pom.xml               | 67 ++++++++++++++++
 .../src/it/without-plugin/verify.groovy         | 53 +++++++++++++
 .../deploymentfilter/DeploymentFilterMojo.java  | 61 --------------
 .../deploymentfilter/FilterTestJarsMojo.java    | 68 ++++++++++++++++
 10 files changed, 364 insertions(+), 153 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/c7185534/pom.xml
----------------------------------------------------------------------
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>

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/c7185534/utils/edgent-deployment-filter-maven-plugin/pom.xml
----------------------------------------------------------------------
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,39 +95,61 @@
     <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>
+            <version>3.0.1</version>
+            <executions>
+              <execution>
+                <id>integration-test</id>
+                <goals>
+                  <goal>install</goal>
+                  <goal>integration-test</goal>
+                  <goal>verify</goal>
+                </goals>
+              </execution>
+            </executions>
             <configuration>
-              <debug>true</debug>
+              <debug>false</debug>
               <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
               <pomIncludes>
                 <pomInclude>*/pom.xml</pomInclude>
               </pomIncludes>
               <postBuildHookScript>verify</postBuildHookScript>
-              
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+              
<localRepositoryPath>${project.build.directory}/maven-repos/local</localRepositoryPath>
               <settingsFile>src/it/settings.xml</settingsFile>
               <goals>
                 <goal>clean</goal>
-                <goal>test-compile</goal>
+                <goal>deploy</goal>
               </goals>
+              <filterProperties>
+                
<mrm.distribution.url>${mrm.distribution.url}</mrm.distribution.url>
+              </filterProperties>
             </configuration>
-            <executions>
-              <execution>
-                <id>integration-test</id>
-                <goals>
-                  <goal>install</goal>
-                  <goal>integration-test</goal>
-                  <goal>verify</goal>
-                </goals>
-              </execution>
-            </executions>
           </plugin>
         </plugins>
-
       </build>
     </profile>
   </profiles>

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/c7185534/utils/edgent-deployment-filter-maven-plugin/src/it/simple-it/pom.xml
----------------------------------------------------------------------
diff --git 
a/utils/edgent-deployment-filter-maven-plugin/src/it/simple-it/pom.xml 
b/utils/edgent-deployment-filter-maven-plugin/src/it/simple-it/pom.xml
deleted file mode 100644
index aff476c..0000000
--- a/utils/edgent-deployment-filter-maven-plugin/src/it/simple-it/pom.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-  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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-  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>
-
-  <groupId>org.apache.edgent.plugins.it</groupId>
-  <artifactId>simple-it</artifactId>
-  <version>1.0-SNAPSHOT</version>
-
-  <description>A simple IT verifying the basic use case.</description>
-
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>@project.groupId@</groupId>
-        <artifactId>@project.artifactId@</artifactId>
-        <version>@project.version@</version>
-        <executions>
-          <execution>
-            <id>touch</id>
-            <phase>validate</phase>
-            <goals>
-              <goal>touch</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/c7185534/utils/edgent-deployment-filter-maven-plugin/src/it/simple-it/verify.groovy
----------------------------------------------------------------------
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()

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/c7185534/utils/edgent-deployment-filter-maven-plugin/src/it/with-plugin/pom.xml
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..b59f56f
--- /dev/null
+++ b/utils/edgent-deployment-filter-maven-plugin/src/it/with-plugin/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  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>with-plugin</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <description>A simple IT verifying the basic use case.</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>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>filter-test-jars</id>
+            <phase>install</phase>
+            <goals>
+              <goal>filter-test-jars</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/c7185534/utils/edgent-deployment-filter-maven-plugin/src/it/with-plugin/verify.groovy
----------------------------------------------------------------------
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

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/c7185534/utils/edgent-deployment-filter-maven-plugin/src/it/without-plugin/pom.xml
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..cea659b
--- /dev/null
+++ b/utils/edgent-deployment-filter-maven-plugin/src/it/without-plugin/pom.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  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>without-plugin</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <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>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/c7185534/utils/edgent-deployment-filter-maven-plugin/src/it/without-plugin/verify.groovy
----------------------------------------------------------------------
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

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/c7185534/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/DeploymentFilterMojo.java
----------------------------------------------------------------------
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/DeploymentFilterMojo.java
deleted file mode 100644
index 978b219..0000000
--- 
a/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/DeploymentFilterMojo.java
+++ /dev/null
@@ -1,61 +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 DeploymentFilterMojo
-    extends AbstractMojo
-{
-
-    @Parameter(defaultValue="${project}")
-    private MavenProject project;
-
-    public void execute()
-        throws MojoExecutionException
-    {
-        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);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/c7185534/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/FilterTestJarsMojo.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..7e90550
--- /dev/null
+++ 
b/utils/edgent-deployment-filter-maven-plugin/src/main/java/org/apache/edgent/plugins/deploymentfilter/FilterTestJarsMojo.java
@@ -0,0 +1,68 @@
+/*
+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())) {
+                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);
+            }
+        }
+    }
+}

Reply via email to