Author: dims Date: Mon Mar 3 08:01:34 2008 New Revision: 633148 URL: http://svn.apache.org/viewvc?rev=633148&view=rev Log: Fix for AXIS2-3487 - Dependency resolution mess with axis2-wsdl2code-maven-plugin
Modified: webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/main/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojo.java Modified: webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/main/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojo.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/main/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojo.java?rev=633148&r1=633147&r2=633148&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/main/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojo.java (original) +++ webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/main/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojo.java Mon Mar 3 08:01:34 2008 @@ -24,7 +24,6 @@ import org.apache.axis2.wsdl.codegen.CodeGenerationEngine; import org.apache.axis2.wsdl.codegen.CodeGenerationException; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -32,15 +31,9 @@ import org.apache.maven.project.MavenProject; import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; -import java.util.List; import java.util.Map; -import java.util.Set; import java.util.Properties; @@ -61,24 +54,6 @@ private MavenProject project; /** - * The artifact factory. - * - * @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}" - * @read-only - * @required - */ - private ArtifactFactory artifactFactory; - - /** - * The plugins artifact list. - * - * @parameter expression="${plugin.artifacts}" - * @read-only - * @required - */ - private List pluginArtifacts; - - /** * The WSDL file, which is being read. * * @parameter expression="${axis2.wsdl2code.wsdl}" default-value="src/main/axis2/service.wsdl" @@ -264,55 +239,6 @@ /** @parameter */ private NamespaceURIMapping[] namespaceURIs = null; - private static class InheritedArtifact { - private final String groupId, artifactId; - private boolean added; - - InheritedArtifact(String pGroupId, String pArtifactId) { - groupId = pGroupId; - artifactId = pArtifactId; - } - - String getGroupId() { - return groupId; - } - - String getArtifactId() { - return artifactId; - } - - boolean isAdded() { - return added; - } - - void setAdded() { - if (added) { - throw new IllegalStateException("This artifact was already added: " + - groupId + ":" + artifactId); - } - } - } - - private static final InheritedArtifact[] inheritedArtifacts = - { - new InheritedArtifact("org.apache.ws.commons.axiom", "axiom-api"), - new InheritedArtifact("org.apache.ws.commons.axiom", "axiom-impl"), - new InheritedArtifact("org.apache.ws.commons", "neethi"), - new InheritedArtifact("wsdl4j", "wsdl4j"), - new InheritedArtifact("commons-httpclient", "commons-httpclient") - }; - - private static final InheritedArtifact[] adbArtifacts = - { - new InheritedArtifact("org.apache.axis2", "axis2-adb") - }; - - private static final InheritedArtifact[] xmlbeansArtifacts = - { - new InheritedArtifact("org.apache.axis2", "axis2-xmlbeans"), - new InheritedArtifact("org.apache.xmlbeans", "xmlbeans") - }; - /** Fills the option map. This map is passed onto the code generation API to generate the code. */ private Map fillOptionMap() throws MojoFailureException { Map optionMap = new HashMap(); @@ -620,7 +546,6 @@ public void execute() throws MojoFailureException, MojoExecutionException { fixCompileSourceRoots(); - fixDependencies(); showDependencies(); Map commandLineOptions = this.fillOptionMap(); @@ -657,71 +582,6 @@ ":" + artifact.getVersion() + ":" + artifact.getClassifier() + ":" + artifact.getScope() + ":" + artifact.getType()); } - } - - private Artifact findArtifact(Collection pCollection, String pGroupId, String pArtifactId) { - for (Iterator iter = pCollection.iterator(); iter.hasNext();) { - Artifact artifact = (Artifact)iter.next(); - if (pGroupId.equals(artifact.getGroupId()) && - pArtifactId.equals(artifact.getArtifactId())) { - return artifact; - } - } - return null; - } - - private InheritedArtifact[] getInheritedArtifacts() { - final List list = new ArrayList(); - list.addAll(Arrays.asList(inheritedArtifacts)); - if ("adb".equals(databindingName)) { - list.addAll(Arrays.asList(adbArtifacts)); - } else if ("xmlbeans".equals(databindingName)) { - list.addAll(Arrays.asList(xmlbeansArtifacts)); - } - - return (InheritedArtifact[])list.toArray(new InheritedArtifact[ list.size() ]); - } - - private InheritedArtifact getInheritedArtifact(InheritedArtifact[] pInheritedArtifacts, - Artifact pArtifact) { - for (int i = 0; i < pInheritedArtifacts.length; i++) { - InheritedArtifact iArtifact = pInheritedArtifacts[i]; - if (iArtifact.getGroupId().equals(pArtifact.getGroupId()) && - iArtifact.getArtifactId().equals(pArtifact.getArtifactId())) { - return iArtifact; - } - } - return null; - } - - private void fixDependencies() { - final Set set = new HashSet(project.getDependencyArtifacts()); - final InheritedArtifact[] inhArtifacts = getInheritedArtifacts(); - for (Iterator iter = pluginArtifacts.iterator(); iter.hasNext();) { - final Artifact artifact = (Artifact)iter.next(); - final InheritedArtifact iArtifact = getInheritedArtifact(inhArtifacts, artifact); - if (iArtifact != null) { - iArtifact.setAdded(); - final String groupId = artifact.getGroupId(); - final String artifactId = artifact.getArtifactId(); - if (findArtifact(project.getArtifacts(), groupId, artifactId) - == null) { - getLog().debug("Adding artifact " + groupId + ":" + artifactId); - Artifact artfct = - artifactFactory.createArtifactWithClassifier(groupId, artifactId, - artifact.getVersion(), - artifact.getType(), - artifact.getClassifier()); - artfct.setScope(Artifact.SCOPE_COMPILE); - set.add(artfct); - } else { - getLog().debug("The artifact " + artifact.getGroupId() + ":" + - artifact.getArtifactId() + " is already present " + - " in the project and will not be added."); - } - } - } - project.setDependencyArtifacts(set); } private void fixCompileSourceRoots() { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]