Author: veithen Date: Sun Aug 1 09:30:32 2010 New Revision: 981188 URL: http://svn.apache.org/viewvc?rev=981188&view=rev Log: Use the new axis2-repo-maven-plugin to simplify the fastinfoset build. Also fixed MDEP-259 for axis2-repo-maven-plugin.
Modified: axis/axis2/java/core/trunk/modules/fastinfoset/pom.xml axis/axis2/java/core/trunk/modules/tool/axis2-repo-maven-plugin/src/main/java/org/apache/axis2/maven2/repo/AbstractCreateRepositoryMojo.java Modified: axis/axis2/java/core/trunk/modules/fastinfoset/pom.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/fastinfoset/pom.xml?rev=981188&r1=981187&r2=981188&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/fastinfoset/pom.xml (original) +++ axis/axis2/java/core/trunk/modules/fastinfoset/pom.xml Sun Aug 1 09:30:32 2010 @@ -172,38 +172,16 @@ </configuration> </plugin> <plugin> - <artifactId>maven-dependency-plugin</artifactId> + <groupId>org.apache.axis2</groupId> + <artifactId>axis2-repo-maven-plugin</artifactId> <executions> <execution> - <phase>generate-test-resources</phase> <goals> - <goal>copy</goal> + <goal>create-test-repository</goal> </goals> <configuration> - <artifactItems> - <artifactItem> - <groupId>org.apache.axis2</groupId> - <artifactId>addressing</artifactId> - <version>${project.version}</version> - <type>mar</type> - </artifactItem> - </artifactItems> - <outputDirectory>${project.build.directory}/repo/modules</outputDirectory> + <outputDirectory>${project.build.directory}/repo</outputDirectory> </configuration> - <!-- The following configuration doesn't work as expected if the addressing module - is part of the same reactor build. Probably this is due to the fact that in - this case, maven-dependency-plugin tries to retrieve the artifact from the - module (instead of the local repository) but fails to do so because it doesn't - know how to construct a MAR file. See http://jira.codehaus.org/browse/MDEP-259 - for more details. --> - <!-- goals> - <goal>copy-dependencies</goal> - </goals> - <configuration> - <outputDirectory>${project.build.directory}/repo/modules</outputDirectory> - <includeTypes>mar</includeTypes> - <includeScopes>test</includeScopes> - </configuration --> </execution> </executions> </plugin> 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=981188&r1=981187&r2=981188&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 09:30:32 2010 @@ -21,10 +21,16 @@ 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; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.factory.ArtifactFactory; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -44,6 +50,30 @@ public abstract class AbstractCreateRepo private MavenProject project; /** + * @component + */ + private ArtifactFactory factory; + + /** + * @component + */ + private ArtifactResolver resolver; + + /** + * @parameter expression="${project.remoteArtifactRepositories}" + * @readonly + * @required + */ + protected List remoteRepositories; + + /** + * @parameter expression="${localRepository}" + * @readonly + * @required + */ + private ArtifactRepository localRepository; + + /** * 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>. * @@ -89,6 +119,7 @@ public abstract class AbstractCreateRepo } catch (ArtifactFilterException ex) { throw new MojoExecutionException(ex.getMessage(), ex); } + artifacts = replaceIncompleteArtifacts(artifacts); File outputDirectory = getOutputDirectory(); File servicesDirectory = new File(outputDirectory, this.servicesDirectory); File modulesDirectory = new File(outputDirectory, this.modulesDirectory); @@ -115,4 +146,33 @@ public abstract class AbstractCreateRepo } } } + + /** + * Replace artifacts that have not been packaged yet. This occurs if the artifact is + * part of the reactor build and the compile phase has been executed, but not the + * the package phase. These artifacts will be replaced by new artifact objects + * resolved from the repository. + * + * @param artifacts the original sets of {...@link Artifact} objects + * @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(); + File file = artifact.getFile(); + if (file != null && file.isDirectory()) { + artifact = factory.createDependencyArtifact(artifact.getGroupId(), artifact.getArtifactId(), + artifact.getVersionRange(), artifact.getType(), artifact.getClassifier(), artifact.getScope()); + try { + resolver.resolve(artifact, remoteRepositories, localRepository); + } catch (AbstractArtifactResolutionException ex) { + throw new MojoExecutionException(ex.getMessage(), ex); + } + } + result.add(artifact); + } + return result; + } }