You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2006/09/08 01:33:33 UTC
svn commit: r441303 [1/2] - in /webservices/axis2/trunk/java/modules/tool:
./ axis2-aar-maven-plugin/ axis2-aar-maven-plugin/src/
axis2-aar-maven-plugin/src/main/ axis2-aar-maven-plugin/src/main/java/
axis2-aar-maven-plugin/src/main/java/org/ axis2-aar...
Author: dims
Date: Thu Sep 7 16:33:30 2006
New Revision: 441303
URL: http://svn.apache.org/viewvc?view=rev&rev=441303
Log:
fix for AXIS2-1111 - Add Maven 2 Plugins
Added:
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/pom.xml
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AarExplodedMojo.java
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AarInPlaceMojo.java
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AarMojo.java
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AbstractAarMojo.java
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/FileSet.java
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/resources/
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/resources/META-INF/
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/resources/META-INF/plexus/
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/resources/META-INF/plexus/components.xml
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/apt/
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/apt/howto.apt
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/apt/introduction.apt
webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/site.xml
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/pom.xml
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/main/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/main/java/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/main/java/org/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/main/java/org/apache/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/main/java/org/apache/axis2/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/main/java/org/apache/axis2/maven2/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/main/java/org/apache/axis2/maven2/java2wsdl/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/main/java/org/apache/axis2/maven2/java2wsdl/Java2WSDLMojo.java
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/apache/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/apache/axis2/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/apache/axis2/maven2/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/apache/axis2/maven2/java2wsdl/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/apache/axis2/maven2/java2wsdl/Java2WSDLMojoTest.java
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/apache/axis2/maven2/java2wsdl/test/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/apache/axis2/maven2/java2wsdl/test/Adder.java
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/test1/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/test1/pom.xml
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/test1/target/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/test1/target/generated-sources/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/test1/target/generated-sources/java2wsdl/
webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/test1/target/generated-sources/java2wsdl/service.xml
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/pom.xml
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/main/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/main/java/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/main/java/org/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/main/java/org/apache/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/main/java/org/apache/axis2/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/main/java/org/apache/axis2/maven2/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/main/java/org/apache/axis2/maven2/wsdl2code/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/main/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojo.java
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/org/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/org/apache/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/org/apache/axis2/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/org/apache/axis2/maven2/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/org/apache/axis2/maven2/wsdl2code/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojoTest.java
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/resources/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/resources/log4j.properties
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/test1/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/test1/pom.xml
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/test1/src/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/test1/src/main/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/test1/src/main/axis2/
webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/test1/src/main/axis2/service.wsdl
webservices/axis2/trunk/java/modules/tool/pom.xml
Added: webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/pom.xml?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/pom.xml (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/pom.xml Thu Sep 7 16:33:30 2006
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ !
+ ! Copyright 2006 The Apache Software Foundation.
+ !
+ ! Licensed 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/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.axis2.maven2</groupId>
+ <artifactId>axis2-maven-tools</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>axis2-aar-maven-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+ <name>Axis 2 Aar Maven Plugin</name>
+ <description>
+ A Maven 2 plugin for creating Axis 2 service archives (aar files)
+ </description>
+ <repositories>
+ <repository>
+ <id>repo1</id>
+ <name>maven repository</name>
+ <url>http://repo1.maven.org/maven2/</url>
+ </repository>
+ <repository>
+ <id>ibiblio</id>
+ <name>ibiblio repository</name>
+ <url>http://ibiblio.org/maven/</url>
+ <layout>legacy</layout>
+ </repository>
+ <repository>
+ <id>apache-m1</id>
+ <name>apache m1-ibiblio-rsync repository</name>
+ <url>http://people.apache.org/repo/m1-ibiblio-rsync-repository/</url>
+ <layout>legacy</layout>
+ </repository>
+ <repository>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>apache-people-repo</id>
+ <name>apache people maven repository</name>
+ <url>http://people.apache.org/repository/</url>
+ <layout>legacy</layout>
+ </repository>
+ <repository>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>ws-zones</id>
+ <name>ws.zones maven repository</name>
+ <url>http://ws.zones.apache.org/~dims/maven/</url>
+ <layout>legacy</layout>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-archiver</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.0.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>2.0</version>
+ </dependency>
+ </dependencies>
+</project>
Added: webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AarExplodedMojo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AarExplodedMojo.java?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AarExplodedMojo.java (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AarExplodedMojo.java Thu Sep 7 16:33:30 2006
@@ -0,0 +1,36 @@
+package org.apache.axis2.maven2.aar;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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 org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * Generate the exploded aar
+ *
+ * @goal exploded
+ * @phase package
+ * @requiresDependencyResolution runtime
+ */
+public class AarExplodedMojo
+ extends AbstractAarMojo
+{
+ public void execute()
+ throws MojoExecutionException
+ {
+ buildExplodedAar();
+ }
+}
Added: webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AarInPlaceMojo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AarInPlaceMojo.java?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AarInPlaceMojo.java (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AarInPlaceMojo.java Thu Sep 7 16:33:30 2006
@@ -0,0 +1,38 @@
+package org.apache.axis2.maven2.aar;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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 org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * Generates aar in the source directory
+ *
+ * @goal inplace
+ * @requiresDependencyResolution runtime
+ */
+public class AarInPlaceMojo
+ extends AbstractAarMojo
+{
+
+ public void execute()
+ throws MojoExecutionException
+ {
+
+ getLog().debug("Generating aar in source directory... " + aarDirectory);
+ buildExplodedAar();
+ }
+}
Added: webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AarMojo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AarMojo.java?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AarMojo.java (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AarMojo.java Thu Sep 7 16:33:30 2006
@@ -0,0 +1,162 @@
+package org.apache.axis2.maven2.aar;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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 java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.archiver.MavenArchiveConfiguration;
+import org.apache.maven.archiver.MavenArchiver;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.archiver.jar.ManifestException;
+
+/**
+ * Build a aar.
+ *
+ * @goal aar
+ * @phase package
+ * @requiresDependencyResolution runtime
+ */
+public class AarMojo extends AbstractAarMojo
+{
+
+ /**
+ * The directory for the generated aar.
+ *
+ * @parameter expression="${project.build.directory}"
+ * @required
+ */
+ private String outputDirectory;
+
+ /**
+ * The name of the generated aar.
+ *
+ * @parameter expression="${project.build.finalName}"
+ * @required
+ */
+ private String aarName;
+
+ /**
+ * The Jar archiver.
+ *
+ * @parameter expression="${component.org.codehaus.plexus.archiver.Archiver#jar}"
+ * @required
+ */
+ private JarArchiver jarArchiver;
+
+ /**
+ * The maven archive configuration to use.
+ *
+ * @parameter
+ */
+ private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
+
+ /**
+ * Classifier to add to the artifact generated. If given, the artifact will be an attachment instead.
+ *
+ * @parameter
+ */
+ private String classifier;
+
+ /**
+ * Whether this is the main artifact being built. Set to <code>false</code> if you don't want to install or deploy
+ * it to the local repository instead of the default one in an execution.
+ *
+ * @parameter expression="${primaryArtifact}" default-value="true"
+ */
+ private boolean primaryArtifact;
+
+ /**
+ * @component
+ */
+ private MavenProjectHelper projectHelper;
+
+ /**
+ * Executes the AarMojo on the current project.
+ *
+ * @throws MojoExecutionException
+ * if an error occured while building the webapp
+ */
+ public void execute() throws MojoExecutionException
+ {
+
+ File aarFile = new File( outputDirectory, aarName + ".aar" );
+
+ try
+ {
+ performPackaging( aarFile );
+ }
+ catch ( Exception e )
+ {
+ throw new MojoExecutionException( "Error assembling aar", e );
+ }
+ }
+
+ /**
+ * Generates the aar.
+ *
+ * @param aarFile
+ * the target aar file
+ * @throws IOException
+ * @throws ArchiverException
+ * @throws ManifestException
+ * @throws DependencyResolutionRequiredException
+ */
+ private void performPackaging( File aarFile )
+ throws IOException, ArchiverException, ManifestException, DependencyResolutionRequiredException,
+ MojoExecutionException
+ {
+
+ buildExplodedAar( );
+
+ // generate aar file
+ getLog().info( "Generating aar " + aarFile.getAbsolutePath() );
+ MavenArchiver archiver = new MavenArchiver();
+ archiver.setArchiver( jarArchiver );
+ archiver.setOutputFile( aarFile );
+ jarArchiver.addDirectory( aarDirectory );
+
+ // create archive
+ archiver.createArchive( project, archive );
+
+ if ( classifier != null )
+ {
+ projectHelper.attachArtifact( project, "aar", classifier, aarFile );
+ }
+ else
+ {
+ Artifact artifact = project.getArtifact();
+ if ( primaryArtifact )
+ {
+ artifact.setFile( aarFile );
+ }
+ else if ( artifact.getFile() == null || artifact.getFile().isDirectory() )
+ {
+ artifact.setFile( aarFile );
+ }
+ else
+ {
+ projectHelper.attachArtifact( project, "aar", aarFile );
+ }
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AbstractAarMojo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AbstractAarMojo.java?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AbstractAarMojo.java (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AbstractAarMojo.java Thu Sep 7 16:33:30 2006
@@ -0,0 +1,223 @@
+package org.apache.axis2.maven2.aar;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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 java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.FileUtils;
+
+
+
+/**
+ * Abstract base class of all the mojos in the axis2-aar-maven-plugin.
+ */
+public abstract class AbstractAarMojo
+ extends AbstractMojo
+{
+
+ /**
+ * The projects base directory.
+ *
+ * @parameter expression="${project.basedir}"
+ * @required
+ * @readonly
+ */
+ protected File baseDir;
+
+ /**
+ * The maven project.
+ *
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * The directory containing generated classes.
+ *
+ * @parameter expression="${project.build.outputDirectory}"
+ * @required
+ */
+ private File classesDirectory;
+
+ /**
+ * The directory where the aar is built.
+ *
+ * @parameter expression="${project.build.directory}/aar"
+ * @required
+ */
+ protected File aarDirectory;
+
+ /**
+ * The location of the services.xml file. If it is present in the META-INF
+ * directory in src/main/resources with that name then it will automatically be
+ * included. Otherwise this parameter must be set.
+ *
+ * @parameter
+ */
+ private File servicesXmlFile;
+
+ /**
+ * The location of the WSDL file, if any. By default, no WSDL file is added
+ * and it is assumed, that Axis 2 will automatically generate a WSDL file.
+ *
+ * @parameter
+ */
+ private File wsdlFile;
+
+ /**
+ * Name, to which the wsdl file shall be mapped. By default, the name will
+ * be computed from the files path by removing the directory.
+ *
+ * @parameter default-value="service.wsdl"
+ */
+ private String wsdlFileName;
+
+ /**
+ * Additional file sets, which are being added to the archive.
+ *
+ * @parameter
+ */
+ private FileSet[] fileSets;
+
+ /**
+ * Builds the exploded AAR file.
+ * @throws MojoExecutionException
+ */
+ protected void buildExplodedAar( )
+ throws MojoExecutionException
+ {
+ getLog().debug( "Exploding aar..." );
+
+ aarDirectory.mkdirs();
+ getLog().debug( "Assembling aar " + project.getArtifactId() + " in " + aarDirectory );
+
+ try
+ {
+ final File metaInfDir = new File( aarDirectory, "META-INF" );
+ final File servicesFileTarget = new File( metaInfDir, "services.xml" );
+ boolean existsBeforeCopyingClasses = servicesFileTarget.exists();
+
+ String wsdlName = wsdlFileName;
+ if ( wsdlName == null && wsdlFile != null )
+ {
+ wsdlName = wsdlFile.getName();
+ }
+ File wsdlFileTarget = null;
+ if ( wsdlFile != null )
+ {
+ wsdlFileTarget = new File( metaInfDir, wsdlFileName );
+ }
+ boolean wsdlExistsBeforeCopyingClasses = wsdlFileTarget == null ? false : wsdlFileTarget.exists();
+
+ if ( classesDirectory.exists() && ( !classesDirectory.equals( aarDirectory ) ) )
+ {
+ FileUtils.copyDirectoryStructure( classesDirectory, aarDirectory );
+ }
+
+ if ( fileSets != null )
+ {
+ for ( int i = 0; i < fileSets.length; i++ )
+ {
+ FileSet fileSet = fileSets[i];
+ copyFileSet( fileSet, aarDirectory );
+ }
+ }
+
+ copyMetaInfFile( servicesXmlFile, servicesFileTarget, existsBeforeCopyingClasses, "services.xml file" );
+ copyMetaInfFile( wsdlFile, wsdlFileTarget, wsdlExistsBeforeCopyingClasses, "WSDL file" );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Could not explode aar...", e );
+ }
+ }
+
+
+ private void copyFileSet( FileSet fileSet, File targetDirectory )
+ throws IOException
+ {
+ File dir = fileSet.getDirectory();
+ if ( dir == null )
+ {
+ dir = baseDir;
+ }
+ File targetDir = targetDirectory;
+ if ( fileSet.getOutputDirectory() != null )
+ {
+ targetDir = new File( targetDir, fileSet.getOutputDirectory() );
+ }
+ if ( targetDir.equals( dir ) )
+ {
+ return;
+ }
+
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setBasedir( dir );
+ if ( !fileSet.isSuppressDefaultExcludes() )
+ {
+ ds.addDefaultExcludes();
+ }
+ final String[] excludes = fileSet.getExcludes();
+ if ( excludes != null )
+ {
+ ds.setExcludes( excludes );
+ }
+ final String[] includes = fileSet.getIncludes();
+ if ( includes != null )
+ {
+ ds.setIncludes( includes );
+ }
+ ds.scan();
+ String[] files = ds.getIncludedFiles();
+ for ( int i = 0; i < files.length; i++ )
+ {
+ File sourceFile = new File( dir, files[i] );
+ File targetFile = new File( targetDir, files[i] );
+ FileUtils.copyFile( sourceFile, targetFile );
+ }
+ }
+
+
+ private void copyMetaInfFile( final File pSource, final File pTarget,
+ final boolean pExistsBeforeCopying,
+ final String pDescription )
+ throws MojoExecutionException, IOException
+ {
+ if ( pSource != null && pTarget != null )
+ {
+ if ( !pSource.exists() )
+ {
+ throw new MojoExecutionException( "The configured " + pDescription + " could not be found at "
+ + pSource );
+ }
+
+ if ( !pExistsBeforeCopying && pTarget.exists() )
+ {
+ getLog().warn( "The configured " + pDescription + " overwrites another file from the classpath." );
+ }
+
+ FileUtils.copyFile( pSource, pTarget );
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/FileSet.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/FileSet.java?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/FileSet.java (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/FileSet.java Thu Sep 7 16:33:30 2006
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.maven2.aar;
+
+import java.io.File;
+
+
+/**
+ * A FileSet defines additional files, which are being added to the
+ * Axis application archive. The objects structure follows the
+ * FileSet object from the maven-assembly-plugin, see the
+ * <a href="http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html">plugin documentation</a>
+ * for details.
+ */
+public class FileSet
+{
+ private File directory;
+ private String outputDirectory;
+ private String[] includes, excludes;
+ private boolean suppressDefaultExcludes;
+
+ /**
+ * Returns the file sets base directory. May be omitted, in which
+ * case the projects base directory is assumed.
+ */
+ public File getDirectory()
+ {
+ return directory;
+ }
+
+ /**
+ * Sets the file sets base directory. May be omitted, in which
+ * case the projects base directory is assumed.
+ */
+ public void setDirectory( File directory )
+ {
+ this.directory = directory;
+ }
+
+ /**
+ * Returns the file sets exclusion list.
+ */
+ public String[] getExcludes()
+ {
+ return excludes;
+ }
+
+ /**
+ * Sets the file sets exclusion list.
+ */
+ public void setExcludes( String[] excludes )
+ {
+ this.excludes = excludes;
+ }
+
+ /**
+ * Returns the file sets inclusion list.
+ */
+ public String[] getIncludes()
+ {
+ return includes;
+ }
+
+ /**
+ * Sets the file sets inclusion list.
+ */
+ public void setIncludes( String[] includes )
+ {
+ this.includes = includes;
+ }
+
+ /**
+ * Sets a prefix, which the included files should have
+ * when being added to the Axis application archive.
+ */
+ public String getOutputDirectory()
+ {
+ return outputDirectory;
+ }
+
+ /**
+ * Returns a prefix, which the included files should have
+ * when being added to the Axis application archive.
+ */
+ public void setOutputDirectory( String outputDirectory )
+ {
+ this.outputDirectory = outputDirectory;
+ }
+
+ /**
+ * Returns, whether the default excludes should be used. Defaults
+ * to true.
+ */
+ public boolean isSuppressDefaultExcludes()
+ {
+ return suppressDefaultExcludes;
+ }
+
+ /**
+ * Sets, whether the default excludes should be used. Defaults to
+ * true.
+ */
+ public void setSuppressDefaultExcludes( boolean suppressDefaultExcludes )
+ {
+ this.suppressDefaultExcludes = suppressDefaultExcludes;
+ }
+}
Added: webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/resources/META-INF/plexus/components.xml?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/resources/META-INF/plexus/components.xml (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/resources/META-INF/plexus/components.xml Thu Sep 7 16:33:30 2006
@@ -0,0 +1,34 @@
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+ <role-hint>aar</role-hint>
+ <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+ <configuration>
+ <classifier></classifier>
+ <extension>aar</extension>
+ <type>aar</type>
+ <packaging>jar</packaging>
+ <language>java</language>
+ <addedToClasspath>false</addedToClasspath>
+ </configuration>
+ </component>
+ <component>
+ <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
+ <role-hint>aar</role-hint>
+ <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
+ <configuration>
+ <phases>
+ <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
+ <compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile>
+ <process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources</process-test-resources>
+ <test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
+ <test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
+ <package>org.apache.axis2.maven2:axis2-aar-maven-plugin:aar</package>
+ <install>org.apache.maven.plugins:maven-install-plugin:install</install>
+ <deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
+ </phases>
+ </configuration>
+ </component>
+ </components>
+</component-set>
Added: webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/apt/howto.apt
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/apt/howto.apt?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/apt/howto.apt (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/apt/howto.apt Thu Sep 7 16:33:30 2006
@@ -0,0 +1,23 @@
+ ------
+ Maven 2 Aar Plugin: configuration examples
+ ------
+ Jochen Wiedmann
+ <jo...@gmail.com>
+ ------
+
+Introduction
+
+ The Aar plugin allows the packaging of an Axis 2 service aar in 3 different modes:
+
+ * aar (default): generates the aar artifact
+
+ * inplace: package the aar in the source tree
+
+ * exploded : package an exploded aar application
+
+ Each mode is materialized by a goal. For instance, to generate an exploded
+ sar from the current project, one would type
+
++--------
+ mvn aar:exploded
++---------
Added: webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/apt/introduction.apt
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/apt/introduction.apt?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/apt/introduction.apt (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/apt/introduction.apt Thu Sep 7 16:33:30 2006
@@ -0,0 +1,15 @@
+ ------
+ Maven 2 Aar Plugin
+ ------
+ Jochen Wiedmann
+ <jo...@gmail.com>
+ ------
+
+Introduction
+
+ This plugin generates an Axis 2 service file (AAR file).
+
+ The full description of goals is available {{{howto.html}here}}.
+
+
+
Added: webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/site.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/site.xml?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/site.xml (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/site/site.xml Thu Sep 7 16:33:30 2006
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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 name="Maven Axis 2 AAR Plugin">
+ <bannerLeft>
+ <name>Maven Axis 2 AAR Plugin</name>
+ <src>http://maven.apache.org/images/apache-maven-project.png</src>
+ <href>http://maven.apache.org/</href>
+ </bannerLeft>
+ <bannerRight>
+ <src>http://maven.apache.org/images/maven-small.gif</src>
+ </bannerRight>
+ <body>
+ <links>
+ <item name="Maven 2" href="http://maven.apache.org/maven2/"/>
+ </links>
+
+ <menu name="Overview">
+ <item name="Introduction" href="introduction.html"/>
+ <item name="How to Use" href="howto.html"/>
+ </menu>
+ ${reports}
+ </body>
+</project>
Added: webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/pom.xml?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/pom.xml (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/pom.xml Thu Sep 7 16:33:30 2006
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ !
+ ! Copyright 2006 The Apache Software Foundation.
+ !
+ ! Licensed 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/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.axis2.maven2</groupId>
+ <artifactId>axis2-maven-tools</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>axis2-java2wsdl-maven-plugin</artifactId>
+ <name>Axis 2 Java2WSDL Maven Plugin</name>
+ <description>
+ A Maven 2 plugin for creating WSDL files from Java source.
+ </description>
+ <packaging>maven-plugin</packaging>
+ <repositories>
+ <repository>
+ <id>repo1</id>
+ <name>maven repository</name>
+ <url>http://repo1.maven.org/maven2/</url>
+ </repository>
+ <repository>
+ <id>ibiblio</id>
+ <name>ibiblio repository</name>
+ <url>http://ibiblio.org/maven/</url>
+ <layout>legacy</layout>
+ </repository>
+ <repository>
+ <id>ibiblio</id>
+ <name>ibiblio repository</name>
+ <url>http://ibiblio.org/maven2/</url>
+ </repository>
+ <repository>
+ <id>apache-m1</id>
+ <name>apache m1-ibiblio-rsync repository</name>
+ <url>http://people.apache.org/repo/m1-ibiblio-rsync-repository/</url>
+ <layout>legacy</layout>
+ </repository>
+ <repository>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>apache-people-repo</id>
+ <name>apache people maven repository</name>
+ <url>http://people.apache.org/repository/</url>
+ <layout>legacy</layout>
+ </repository>
+ <repository>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>ws-zones</id>
+ <name>ws.zones maven repository</name>
+ <url>http://ws.zones.apache.org/~dims/maven/</url>
+ <layout>legacy</layout>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-java2wsdl</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-plugin-testing-harness</artifactId>
+ <version>1.0-beta-1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>annogen</groupId>
+ <artifactId>annogen</artifactId>
+ <version>0.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons</groupId>
+ <artifactId>XmlSchema</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>ws-commons</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>ws-commons</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx</artifactId>
+ <version>asl-3.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+ </dependencies>
+</project>
Added: webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/main/java/org/apache/axis2/maven2/java2wsdl/Java2WSDLMojo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/main/java/org/apache/axis2/maven2/java2wsdl/Java2WSDLMojo.java?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/main/java/org/apache/axis2/maven2/java2wsdl/Java2WSDLMojo.java (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/main/java/org/apache/axis2/maven2/java2wsdl/Java2WSDLMojo.java Thu Sep 7 16:33:30 2006
@@ -0,0 +1,152 @@
+package org.apache.axis2.maven2.java2wsdl;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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 java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.ws.java2wsdl.Java2WSDLCodegenEngine;
+import org.apache.ws.java2wsdl.Java2WSDLConstants;
+import org.apache.ws.java2wsdl.utils.Java2WSDLCommandLineOption;
+
+
+/**
+ * Takes a Java class as input and converts it into an equivalent
+ * WSDL file.
+ *
+ * @goal java2wsdl
+ * @phase generate-resources
+ * @requiresDependencyResolution compile
+ */
+public class Java2WSDLMojo extends AbstractMojo {
+ /**
+ * The maven project.
+ * @parameter expression="${project}"
+ * @read-only
+ * @required
+ */
+ private MavenProject project;
+
+ /**
+ * Fully qualified name of the class, which is being inspected.
+ * @parameter
+ * @required
+ */
+ private String className;
+
+ /**
+ * Target namespace of the generated WSDL.
+ * @parameter
+ */
+ private String targetNamespace;
+
+ /**
+ * The namespace prefix, which is being used for the WSDL's
+ * target namespace.
+ * @parameter
+ */
+ private String targetNamespacePrefix;
+
+ /**
+ * The generated schemas target namespace.
+ * @parameter
+ */
+ private String schemaTargetNamespace;
+
+ /**
+ * The generated schemas target namespace prefix.
+ * @parameter
+ */
+ private String schemaTargetNamespacePrefix;
+
+ /**
+ * Name of the generated service.
+ * @parameter
+ */
+ private String serviceName;
+
+ /**
+ * Name of the service file, which is being generated.
+ * @parameter default-value="target/generated-sources/java2wsdl/service.xml"
+ */
+ private String outputFileName;
+
+ private void addToOptionMap(Map map, String option, String value) {
+ if (value != null) {
+ map.put(option,
+ new Java2WSDLCommandLineOption(option, new String[]{value}));
+ }
+ }
+
+ /**
+ * 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();
+
+ if (className == null) {
+ throw new MojoFailureException("You must specify a classname");
+ }
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.CLASSNAME_OPTION,
+ className);
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.TARGET_NAMESPACE_OPTION,
+ targetNamespace);
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.TARGET_NAMESPACE_PREFIX_OPTION,
+ targetNamespacePrefix);
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.SCHEMA_TARGET_NAMESPACE_OPTION,
+ schemaTargetNamespace);
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.SCHEMA_TARGET_NAMESPACE_PREFIX_OPTION,
+ schemaTargetNamespacePrefix);
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.SERVICE_NAME_OPTION,
+ serviceName);
+ File f = new File(project.getBasedir(), outputFileName);
+ File dir = f.getParentFile();
+ if (!dir.isDirectory()) {
+ dir.mkdirs();
+ }
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.OUTPUT_LOCATION_OPTION,
+ dir.getPath() );
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.OUTPUT_FILENAME_OPTION,
+ f.getName() );
+
+ return optionMap;
+ }
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ Map commandLineOptions = fillOptionMap();
+ try {
+ new Java2WSDLCodegenEngine(commandLineOptions).generate();
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new MojoExecutionException(e.getMessage(), e);
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/apache/axis2/maven2/java2wsdl/Java2WSDLMojoTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/apache/axis2/maven2/java2wsdl/Java2WSDLMojoTest.java?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/apache/axis2/maven2/java2wsdl/Java2WSDLMojoTest.java (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/apache/axis2/maven2/java2wsdl/Java2WSDLMojoTest.java Thu Sep 7 16:33:30 2006
@@ -0,0 +1,58 @@
+package org.apache.axis2.maven2.java2wsdl;
+
+/*
+ * Copyright 2006 Apache Software Foundation.
+ *
+ * Licensed 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 java.io.File;
+
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+
+
+/**
+ * Test case for running the java2wsdl goal.
+ */
+public class Java2WSDLMojoTest extends AbstractMojoTestCase {
+ private static final String WSDL_FILE = "target/generated-sources/java2wsdl/service.xml";
+
+ /**
+ * Tests running the WSDL generator.
+ */
+ public void testJava() throws Exception {
+ final String dir = "src/test/test1";
+ runTest(dir , "java2wsdl" );
+ assertTrue( new File(dir, WSDL_FILE).exists());
+ }
+
+ protected Java2WSDLMojo newMojo( String pDir, String pGoal ) throws Exception
+ {
+ final File baseDir = new File(new File(getBasedir()), pDir);
+ File testPom = new File( baseDir, "pom.xml" );
+ Java2WSDLMojo mojo = (Java2WSDLMojo) lookupMojo( pGoal, testPom );
+ MavenProjectStub project = new MavenProjectStub(){
+ public File getBasedir() { return baseDir; }
+ };
+ setVariableValueToObject(mojo, "project", project);
+ setVariableValueToObject(mojo, "outputFileName", WSDL_FILE);
+ return mojo;
+ }
+
+ protected void runTest( String pDir, String pGoal )
+ throws Exception
+ {
+ newMojo( pDir, pGoal ).execute();
+ }
+}
Added: webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/apache/axis2/maven2/java2wsdl/test/Adder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/apache/axis2/maven2/java2wsdl/test/Adder.java?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/apache/axis2/maven2/java2wsdl/test/Adder.java (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/java/org/apache/axis2/maven2/java2wsdl/test/Adder.java Thu Sep 7 16:33:30 2006
@@ -0,0 +1,29 @@
+package org.apache.axis2.maven2.java2wsdl.test;
+
+/*
+ * Copyright 2006 Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * A dummy service class
+ */
+public class Adder {
+ /**
+ * Returns the sum of its parameters.
+ */
+ public int add(int p1, int p2) {
+ return p1 + p2;
+ }
+}
Added: webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/test1/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/test1/pom.xml?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/test1/pom.xml (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/test1/pom.xml Thu Sep 7 16:33:30 2006
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.axis2.maven2</groupId>
+ <artifactId>axis2-wsdl2code-maven-plugin-test1</artifactId>
+ <version>1.0</version>
+ <name>Test 1 of the axis2-wsdl2code-maven-plugin</name>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.axis2.maven2</groupId>
+ <artifactId>axis2-java2wsdl-maven-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <configuration>
+ <className>org.apache.axis2.maven2.java2wsdl.test.Adder</className>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/test1/target/generated-sources/java2wsdl/service.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/test1/target/generated-sources/java2wsdl/service.xml?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/test1/target/generated-sources/java2wsdl/service.xml (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-java2wsdl-maven-plugin/src/test/test1/target/generated-sources/java2wsdl/service.xml Thu Sep 7 16:33:30 2006
@@ -0,0 +1,17 @@
+<wsdl:definitions xmlns:axis2="http://test.java2wsdl.maven2.axis2.apache.org" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns1="http://test.java2wsdl.maven2.axis2.apache.org/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://test.java2wsdl.maven2.axis2.apache.org"><wsdl:types><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax21="http://test.java2wsdl.maven2.axis2.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://test.java2wsdl.maven2.axis2.apache.org/xsd">
+<xs:element name="add">
+<xs:complexType>
+<xs:sequence>
+<xs:element name="p1" type="xs:int" />
+<xs:element name="p2" type="xs:int" />
+</xs:sequence>
+</xs:complexType>
+</xs:element>
+<xs:element name="addResponse">
+<xs:complexType>
+<xs:sequence>
+<xs:element name="return" type="xs:int" />
+</xs:sequence>
+</xs:complexType>
+</xs:element>
+</xs:schema></wsdl:types><wsdl:message name="addMessage"><wsdl:part name="part1" element="ns1:add" /></wsdl:message><wsdl:message name="addResponseMessage"><wsdl:part name="part1" element="ns1:addResponse" /></wsdl:message><wsdl:portType name="AdderPortType"><wsdl:operation name="add"><wsdl:input message="axis2:addMessage" /><wsdl:output message="axis2:addResponseMessage" /></wsdl:operation></wsdl:portType><wsdl:binding name="AdderSOAP11Binding" type="axis2:AdderPortType"><soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /><wsdl:operation name="add"><soap:operation soapAction="urn:add" style="document" /><wsdl:input><soap:body use="literal" namespace="http://test.java2wsdl.maven2.axis2.apache.org" /></wsdl:input><wsdl:output><soap:body use="literal" namespace="http://test.java2wsdl.maven2.axis2.apache.org" /></wsdl:output></wsdl:operation></wsdl:binding><wsdl:binding name="AdderSOAP12Binding" type="axis2:AdderPortType"><soap12:binding transport=
"http://schemas.xmlsoap.org/soap/http" style="document" /><wsdl:operation name="add"><soap12:operation soapAction="urn:add" style="document" /><wsdl:input><soap12:body use="literal" namespace="http://test.java2wsdl.maven2.axis2.apache.org" /></wsdl:input><wsdl:output><soap12:body use="literal" namespace="http://test.java2wsdl.maven2.axis2.apache.org" /></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="Adder"><wsdl:port name="AdderSOAP11port" binding="axis2:AdderSOAP11Binding"><soap:address location="http://localhost:8080/axis2/services/Adder" /></wsdl:port><wsdl:port name="AdderSOAP12port" binding="axis2:AdderSOAP12Binding"><soap12:address location="http://localhost:8080/axis2/services/Adder" /></wsdl:port></wsdl:service></wsdl:definitions>
\ No newline at end of file
Added: webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/pom.xml?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/pom.xml (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/pom.xml Thu Sep 7 16:33:30 2006
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ !
+ ! Copyright 2006 The Apache Software Foundation.
+ !
+ ! Licensed 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/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.axis2.maven2</groupId>
+ <artifactId>axis2-maven-tools</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
+ <name>Axis 2 WSDL2Code Maven Plugin</name>
+ <packaging>maven-plugin</packaging>
+ <description>The Axis 2 Plugin for Maven allows client side and server side sources from a WSDL.</description>
+ <repositories>
+ <repository>
+ <id>repo1</id>
+ <name>maven repository</name>
+ <url>http://repo1.maven.org/maven2/</url>
+ </repository>
+ <repository>
+ <id>ibiblio</id>
+ <name>ibiblio repository</name>
+ <url>http://ibiblio.org/maven/</url>
+ <layout>legacy</layout>
+ </repository>
+ <repository>
+ <id>ibiblio</id>
+ <name>ibiblio repository</name>
+ <url>http://ibiblio.org/maven2/</url>
+ </repository>
+ <repository>
+ <id>apache-m1</id>
+ <name>apache m1-ibiblio-rsync repository</name>
+ <url>http://people.apache.org/repo/m1-ibiblio-rsync-repository/</url>
+ <layout>legacy</layout>
+ </repository>
+ <repository>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>apache-people-repo</id>
+ <name>apache people maven repository</name>
+ <url>http://people.apache.org/repository/</url>
+ <layout>legacy</layout>
+ </repository>
+ <repository>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>ws-zones</id>
+ <name>ws.zones maven repository</name>
+ <url>http://ws.zones.apache.org/~dims/maven/</url>
+ <layout>legacy</layout>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-codegen</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-common</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-adb</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-adb-codegen</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-java2wsdl</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-plugin-testing-harness</artifactId>
+ <version>1.0-beta-1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ <version>1.5.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.0.1</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons</groupId>
+ <artifactId>neethi</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons</groupId>
+ <artifactId>XmlSchema</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>ws-commons</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>ws-commons</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx</artifactId>
+ <version>asl-3.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.0.5</version>
+ </dependency>
+ </dependencies>
+</project>
Added: 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?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/main/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojo.java (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/main/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojo.java Thu Sep 7 16:33:30 2006
@@ -0,0 +1,483 @@
+package org.apache.axis2.maven2.wsdl2code;
+
+/*
+ * Copyright 2006 Apache Software Foundation.
+ *
+ * Licensed 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 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 org.apache.axis2.wsdl.codegen.CodeGenerationEngine;
+import org.apache.axis2.wsdl.codegen.CodeGenerationException;
+import org.apache.axis2.wsdl.util.CommandLineOption;
+import org.apache.axis2.wsdl.util.CommandLineOptionConstants;
+import org.apache.axis2.wsdl.util.CommandLineOptionParser;
+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;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+
+
+/**
+ * @description A Mojo for generating Java sources from a WSDL.
+ * @goal wsdl2code
+ * @phase generate-sources
+ * @requiresDependencyResolution test
+ */
+public class WSDL2CodeMojo extends AbstractMojo
+{
+ /**
+ * The maven project.
+ * @parameter expression="${project}"
+ * @read-only
+ * @required
+ */
+ 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"
+ */
+ private File wsdlFile;
+
+ /**
+ * The output directory, where the generated sources are being created.
+ * @parameter expression="${axis2.wsdl2code.target}" default-value="${project.build.directory}/generated-sources/axis2/wsdl2code"
+ */
+ private File outputDirectory;
+
+ /**
+ * Package name of the generated sources; will be used to create a package structure
+ * below the output directory.
+ * @parameter expression="${axis2.wsdl2code.package}"
+ * @required
+ */
+ private String packageName;
+
+ /**
+ * The programming language of the generated sources.
+ * @parameter expression="${axis2.wsdl2code.language}" default-value="java"
+ */
+ private String language;
+
+ /**
+ * The databinding framework, which is being used.
+ * @parameter expression="${axis2.wsdl2code.databindingName}" default-value="adb"
+ */
+ private String databindingName;
+
+ /**
+ * Port name, for which to generate sources. By default, sources will
+ * be generated for all ports.
+ * @parameter expression="${axis2.wsdl2code.portName}"
+ */
+ private String portName;
+
+ /**
+ * Service name, for which to generate sources. By default, sources will
+ * be generated for all services.
+ * @parameter expression="${axis2.wsdl2code.serviceName}"
+ */
+ private String serviceName;
+
+ /**
+ * Mode, for which sources are being generated; either of "sync", "async" or "both".
+ * @parameter expression="${axis2.wsdl2code.syncMode}" default-value="both"
+ */
+ private String syncMode;
+
+ /**
+ * Whether server side sources are being generated.
+ * @parameter expression="${axis2.wsdl2code.generateServerSide}" default-value="false"
+ */
+ private boolean generateServerSide;
+
+ /**
+ * Whether to generate sources for a test case.
+ * @parameter expression="${axis2.wsdl2code.generateTestCase}" default-value="false"
+ */
+ private boolean generateTestcase;
+
+ /**
+ * Whether to generate a "services.xml" file.
+ * @parameter expression="${axis2.wsdl2code.generateServicesXml}" default-value="false"
+ */
+ private boolean generateServiceXml;
+
+ /**
+ * Whether to generate simply all classes. This is only valid in conjunction with
+ * "generateServerSide".
+ * @parameter expression="${axis2.wsdl2code.generateAllClasses}" default-value="false"
+ */
+ private boolean generateAllClasses;
+
+ /**
+ * Whether to unpack classes.
+ * @parameter expression="${axis2.wsdl2code.unpackClasses}" default-value="false"
+ */
+ private boolean unpackClasses;
+
+ /**
+ * Whether to generate the server side interface.
+ * @parameter expression="${axis2.wsdl2code.generateServerSideInterface}" default-value="false"
+ */
+ private boolean generateServerSideInterface = false;
+
+ /**
+ * @parameter
+ */
+ private String namespaceToPackages = 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.axis2", "axis2-common" ),
+ new InheritedArtifact( "org.apache.axis2", "axis2-core" ),
+ 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" )
+ };
+
+ /**
+ * 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();
+
+ ////////////////////////////////////////////////////////////////
+ //WSDL file name
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants.WSDL_LOCATION_URI_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants.WSDL_LOCATION_URI_OPTION,
+ getStringArray(wsdlFile.getPath())));
+ //output location
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants.OUTPUT_LOCATION_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants.OUTPUT_LOCATION_OPTION,
+ getStringArray(outputDirectory.getPath())));
+ //////////////////////////////////////////////////////////////////
+ // Databinding type
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants.DATA_BINDING_TYPE_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants.DATA_BINDING_TYPE_OPTION,
+ getStringArray(databindingName)));
+
+ if ("async".equals(syncMode)) {
+ // Async only option - forcing to generate async methods only
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants.CODEGEN_ASYNC_ONLY_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants.CODEGEN_ASYNC_ONLY_OPTION,
+ new String[0]));
+ } else if ("sync".equals(syncMode)) {
+ // Sync only option - forcing to generate Sync methods only
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants.CODEGEN_SYNC_ONLY_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants.CODEGEN_SYNC_ONLY_OPTION,
+ new String[0]));
+ } else if ("both".equals(syncMode)) {
+ // Do nothing
+ } else {
+ throw new MojoFailureException("Invalid syncMode: " + syncMode +
+ ", expected either of 'sync', 'async' or 'both'.");
+ }
+
+ //Package
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants.PACKAGE_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants.PACKAGE_OPTION,
+ getStringArray(packageName)));
+
+ //stub language
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants.STUB_LANGUAGE_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants.STUB_LANGUAGE_OPTION,
+ getStringArray(language)));
+
+
+ //server side and generate services.xml options
+ if (generateServerSide) {
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants.SERVER_SIDE_CODE_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants.SERVER_SIDE_CODE_OPTION,
+ new String[0]));
+
+ //services XML generation - effective only when specified as the server side
+ if (generateServiceXml) {
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants
+ .GENERATE_SERVICE_DESCRIPTION_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants
+ .GENERATE_SERVICE_DESCRIPTION_OPTION,
+ new String[0]));
+ }
+ //generate all option - Only valid when generating serverside code
+ if (generateAllClasses) {
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants.GENERATE_ALL_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants.GENERATE_ALL_OPTION,
+ new String[0]));
+ }
+
+ }
+
+ //generate the test case
+ if (generateTestcase) {
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants.GENERATE_TEST_CASE_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants.GENERATE_TEST_CASE_OPTION,
+ new String[0]));
+ }
+
+ //Unwrap classes option - this determines whether the generated classes are inside the stub/MR
+ //or gets generates as seperate classes
+ if (unpackClasses) {
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants.UNPACK_CLASSES_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants.UNPACK_CLASSES_OPTION,
+ new String[0]));
+ }
+
+ //server side interface option
+ if (generateServerSideInterface) {
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants.SERVER_SIDE_INTERFACE_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants.SERVER_SIDE_INTERFACE_OPTION,
+ new String[0]));
+ }
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants.SERVICE_NAME_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants.SERVICE_NAME_OPTION,
+ new String[]{serviceName}));
+
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants.PORT_NAME_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants.PORT_NAME_OPTION,
+ new String[]{portName}));
+ // set the namespaces
+ optionMap.put(
+ CommandLineOptionConstants.WSDL2JavaConstants.NAME_SPACE_TO_PACKAGE_OPTION,
+ new CommandLineOption(
+ CommandLineOptionConstants.WSDL2JavaConstants.NAME_SPACE_TO_PACKAGE_OPTION,
+ new String[]{namespaceToPackages}));
+
+ return optionMap;
+ }
+
+ /**
+ * Utility method to convert a string into a single item string[]
+ * @param value
+ * @return Returns String[].
+ */
+ private String[] getStringArray(String value) {
+ String[] values = new String[1];
+ values[0] = value;
+ return values;
+ }
+
+ public void execute() throws MojoFailureException, MojoExecutionException {
+ Map commandLineOptions = this.fillOptionMap();
+ CommandLineOptionParser parser =
+ new CommandLineOptionParser(commandLineOptions);
+ try {
+ new CodeGenerationEngine(parser).generate();
+ } catch (CodeGenerationException e) {
+ Throwable t = e;
+ while (t.getCause() != null)
+ {
+ t = t.getCause();
+ }
+ t.printStackTrace();
+ throw new MojoExecutionException(e.getMessage(), e);
+ }
+
+ fixCompileSourceRoots();
+ fixDependencies();
+ showDependencies();
+ }
+
+ private void showDependencies()
+ {
+ Log log = getLog();
+ if ( !log.isDebugEnabled() )
+ {
+ return;
+ }
+ log.debug( "The projects dependency artifacts are: " );
+ for (Iterator iter = project.getDependencyArtifacts().iterator(); iter.hasNext(); )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ log.debug( " " + artifact.getGroupId() + ":" + artifact.getArtifactId() +
+ ":" + artifact.getVersion() + ":" + artifact.getClassifier() +
+ ":" + artifact.getScope() + ":" + artifact.getType() );
+ }
+ log.debug( "The projects transitive artifacts are: " );
+ for (Iterator iter = project.getArtifacts().iterator(); iter.hasNext(); )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ log.debug( " " + artifact.getGroupId() + ":" + artifact.getArtifactId() +
+ ":" + 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 ) );
+ }
+ 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()
+ {
+ File srcDir = new File(outputDirectory, "src");
+ project.addCompileSourceRoot(srcDir.getPath());
+ }
+}
Added: webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojoTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojoTest.java?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojoTest.java (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojoTest.java Thu Sep 7 16:33:30 2006
@@ -0,0 +1,62 @@
+package org.apache.axis2.maven2.wsdl2code;
+
+/*
+ * Copyright 2006 Apache Software Foundation.
+ *
+ * Licensed 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 java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+
+import org.apache.axis2.maven2.wsdl2code.WSDL2CodeMojo;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * Test class for running the wsdl2code mojo.
+ */
+public class WSDL2CodeMojoTest extends AbstractMojoTestCase {
+ /**
+ * Tests running the java generator.
+ */
+ public void testJava() throws Exception {
+ runTest( "src/test/test1", "wsdl2code" );
+ }
+
+ protected WSDL2CodeMojo newMojo( String pDir, String pGoal ) throws Exception
+ {
+ File baseDir = new File(new File(getBasedir()), pDir);
+ File testPom = new File( baseDir, "pom.xml" );
+ WSDL2CodeMojo mojo = (WSDL2CodeMojo) lookupMojo( pGoal, testPom );
+ MavenProjectStub project = new MavenProjectStub();
+ project.setDependencyArtifacts( new HashSet() );
+ setVariableValueToObject(mojo, "project", project);
+ setVariableValueToObject(mojo, "pluginArtifacts", new ArrayList());
+ setVariableValueToObject(mojo, "wsdlFile", new File(baseDir, "src/main/axis2/service.wsdl"));
+ setVariableValueToObject(mojo, "outputDirectory", new File(baseDir, "target/generated-sources/axis2/wsdl2code"));
+ setVariableValueToObject(mojo, "syncMode", "both");
+ setVariableValueToObject(mojo, "databindingName", "adb");
+ setVariableValueToObject(mojo, "language", "java");
+ return mojo;
+ }
+
+ protected void runTest( String pDir, String pGoal )
+ throws Exception
+ {
+ newMojo( pDir, pGoal ).execute();
+ }
+}
Added: webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/resources/log4j.properties?view=auto&rev=441303
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/resources/log4j.properties (added)
+++ webservices/axis2/trunk/java/modules/tool/axis2-wsdl2code-maven-plugin/src/test/resources/log4j.properties Thu Sep 7 16:33:30 2006
@@ -0,0 +1,21 @@
+# Set root category priority to INFO and its only appender to CONSOLE.
+log4j.rootCategory=INFO, CONSOLE
+#log4j.rootCategory=INFO, CONSOLE, LOGFILE
+
+# Set the enterprise logger priority to FATAL
+log4j.logger.org.apache.axis2.enterprise=FATAL
+log4j.logger.de.hunsicker.jalopy.io=FATAL
+log4j.logger.httpclient.wire.header=FATAL
+log4j.logger.org.apache.commons.httpclient=FATAL
+
+# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p %c - %m%n
+
+# LOGFILE is set to be a File appender using a PatternLayout.
+log4j.appender.LOGFILE=org.apache.log4j.FileAppender
+log4j.appender.LOGFILE.File=axis2.log
+log4j.appender.LOGFILE.Append=true
+log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org