You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2010/08/01 15:23:31 UTC

svn commit: r981220 - in /axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo: AbstractCreateRepositoryMojo.java CreateRepositoryMojo.java CreateTestRepositoryMojo.java

Author: veithen
Date: Sun Aug  1 13:23:31 2010
New Revision: 981220

URL: http://svn.apache.org/viewvc?rev=981220&view=rev
Log:
Some improvements to the new axis2-repo-maven-plugin. In particular, collect AAR and MAR files not only from project dependencies, but also from submodules in a multimodule project.

Modified:
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/AbstractCreateRepositoryMojo.java
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateRepositoryMojo.java
    axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateTestRepositoryMojo.java

Modified: axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/AbstractCreateRepositoryMojo.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/AbstractCreateRepositoryMojo.java?rev=981220&r1=981219&r2=981220&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/AbstractCreateRepositoryMojo.java (original)
+++ axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/AbstractCreateRepositoryMojo.java Sun Aug  1 13:23:31 2010
@@ -22,7 +22,6 @@ package org.apache.axis2.maven2.repo;
 import java.io.File;
 import java.io.IOException;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -43,13 +42,6 @@ import org.codehaus.plexus.util.FileUtil
 
 public abstract class AbstractCreateRepositoryMojo extends AbstractMojo {
     /**
-     * @parameter expression="${project}"
-     * @readonly
-     * @required
-     */
-    private MavenProject project;
-    
-    /**
      * @component
      */
     private ArtifactFactory factory;
@@ -60,11 +52,18 @@ public abstract class AbstractCreateRepo
     private ArtifactResolver resolver;
     
     /**
+     * @parameter expression="${project.artifacts}"
+     * @readonly
+     * @required
+     */
+    private Set<Artifact> projectArtifacts;
+    
+    /**
      * @parameter expression="${project.remoteArtifactRepositories}"
      * @readonly
      * @required
      */
-    protected List remoteRepositories;
+    private List remoteRepositories;
     
     /**
      * @parameter expression="${localRepository}"
@@ -74,6 +73,13 @@ public abstract class AbstractCreateRepo
     private ArtifactRepository localRepository;
     
     /**
+     * @parameter expression="${project.collectedProjects}"
+     * @required
+     * @readonly
+     */
+    private List<MavenProject> collectedProjects;
+    
+    /**
      * The directory (relative to the repository root) where AAR files are copied. This should be
      * set to the same value as the <tt>ServicesDirectory</tt> property in <tt>axis2.xml</tt>.
      * 
@@ -105,12 +111,36 @@ public abstract class AbstractCreateRepo
      */
     private String configurationDirectory;
     
+    /**
+     * Specifies whether the plugin should scan the project dependencies for AAR and MAR artifacts.
+     * 
+     * @parameter default-value="true"
+     */
+    private boolean useDependencies;
+    
+    /**
+     * Specifies whether the plugin should scan Maven modules for AAR and MAR artifacts. This
+     * parameter only has an effect for multimodule projects.
+     * 
+     * @parameter default-value="true"
+     */
+    private boolean useModules;
+    
     protected abstract String getScope();
     
     protected abstract File getOutputDirectory();
 
     public void execute() throws MojoExecutionException, MojoFailureException {
-        Set artifacts = project.getArtifacts();
+        Set<Artifact> artifacts = new HashSet<Artifact>();
+        if (useDependencies) {
+            artifacts.addAll(projectArtifacts);
+        }
+        if (useModules) {
+            for (MavenProject project : collectedProjects) {
+                artifacts.add(project.getArtifact());
+                artifacts.addAll(project.getAttachedArtifacts());
+            }
+        }
         FilterArtifacts filter = new FilterArtifacts();
         filter.addFilter(new ScopeFilter(getScope(), null));
         filter.addFilter(new TypeFilter("aar,mar", null));
@@ -123,8 +153,7 @@ public abstract class AbstractCreateRepo
         File outputDirectory = getOutputDirectory();
         File servicesDirectory = new File(outputDirectory, this.servicesDirectory);
         File modulesDirectory = new File(outputDirectory, this.modulesDirectory);
-        for (Iterator it = artifacts.iterator(); it.hasNext(); ) {
-            Artifact artifact = (Artifact)it.next();
+        for (Artifact artifact : artifacts) {
             String type = artifact.getType();
             String destFileName = artifact.getArtifactId() + "-" + artifact.getVersion() + "." + type;
             File targetDir = type.equals("mar") ? modulesDirectory : servicesDirectory;
@@ -157,10 +186,9 @@ public abstract class AbstractCreateRepo
      * @return a set of {@link Artifact} objects built as described above
      * @throws MojoExecutionException
      */
-    private Set replaceIncompleteArtifacts(Set artifacts) throws MojoExecutionException {
-        Set result = new HashSet();
-        for (Iterator it = artifacts.iterator(); it.hasNext(); ) {
-            Artifact artifact = (Artifact)it.next();
+    private Set<Artifact> replaceIncompleteArtifacts(Set<Artifact> artifacts) throws MojoExecutionException {
+        Set<Artifact> result = new HashSet<Artifact>();
+        for (Artifact artifact : artifacts) {
             File file = artifact.getFile();
             if (file != null && file.isDirectory()) {
                 artifact = factory.createDependencyArtifact(artifact.getGroupId(), artifact.getArtifactId(),

Modified: axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateRepositoryMojo.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateRepositoryMojo.java?rev=981220&r1=981219&r2=981220&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateRepositoryMojo.java (original)
+++ axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateRepositoryMojo.java Sun Aug  1 13:23:31 2010
@@ -24,10 +24,11 @@ import java.io.File;
 import org.apache.maven.artifact.Artifact;
 
 /**
- * Creates an Axis2 repository from the project's runtime dependencies.
+ * Creates an Axis2 repository from the project's runtime dependencies. This goal is typically
+ * used to build an Axis2 repository that will be packaged into some kind of distribution.
  * 
  * @goal create-repository
- * @phase generate-resources
+ * @phase package
  * @requiresDependencyResolution runtime
  */
 public class CreateRepositoryMojo extends AbstractCreateRepositoryMojo {

Modified: axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateTestRepositoryMojo.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateTestRepositoryMojo.java?rev=981220&r1=981219&r2=981220&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateTestRepositoryMojo.java (original)
+++ axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/CreateTestRepositoryMojo.java Sun Aug  1 13:23:31 2010
@@ -26,7 +26,8 @@ import org.apache.maven.plugin.MojoExecu
 import org.apache.maven.plugin.MojoFailureException;
 
 /**
- * Creates an Axis2 repository from the project's dependencies in scope test. Note that this goal
+ * Creates an Axis2 repository from the project's dependencies in scope test. This goal is
+ * typically used to build an Axis2 repository for use during unit tests. Note that this goal
  * is skipped if the <code>maven.test.skip</code> property is set to <code>true</code>.
  * 
  * @goal create-test-repository