Author: mmao
Date: Tue May 8 23:21:02 2007
New Revision: 536436
URL: http://svn.apache.org/viewvc?view=rev&rev=536436
Log:
CXF-438, CXF-635
Apply patch 'Maven 2 Plugin for Java2WSDL'
contriuted by Chris Moesel
Added:
incubator/cxf/trunk/wsdlgen-plugin/
incubator/cxf/trunk/wsdlgen-plugin/pom.xml
incubator/cxf/trunk/wsdlgen-plugin/src/
incubator/cxf/trunk/wsdlgen-plugin/src/main/
incubator/cxf/trunk/wsdlgen-plugin/src/main/java/
incubator/cxf/trunk/wsdlgen-plugin/src/main/java/org/
incubator/cxf/trunk/wsdlgen-plugin/src/main/java/org/apache/
incubator/cxf/trunk/wsdlgen-plugin/src/main/java/org/apache/cxf/
incubator/cxf/trunk/wsdlgen-plugin/src/main/java/org/apache/cxf/maven_plugin/
incubator/cxf/trunk/wsdlgen-plugin/src/main/java/org/apache/cxf/maven_plugin/Java2WSDLMojo.java
Modified:
incubator/cxf/trunk/pom.xml
Modified: incubator/cxf/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/pom.xml?view=diff&rev=536436&r1=536435&r2=536436
==============================================================================
--- incubator/cxf/trunk/pom.xml (original)
+++ incubator/cxf/trunk/pom.xml Tue May 8 23:21:02 2007
@@ -132,6 +132,7 @@
<module>api</module>
<module>tools</module>
<module>codegen-plugin</module>
+ <module>wsdlgen-plugin</module>
<module>testutils</module>
<module>rt</module>
<module>integration</module>
Added: incubator/cxf/trunk/wsdlgen-plugin/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/wsdlgen-plugin/pom.xml?view=auto&rev=536436
==============================================================================
--- incubator/cxf/trunk/wsdlgen-plugin/pom.xml (added)
+++ incubator/cxf/trunk/wsdlgen-plugin/pom.xml Tue May 8 23:21:02 2007
@@ -0,0 +1,72 @@
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-wsdlgen-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+ <version>2.0-incubator-SNAPSHOT</version>
+ <name>Apache CXF WSDL Generation Maven2 Plugin</name>
+ <url>http://cwiki.apache.org/CXF</url>
+
+
+ <parent>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-parent</artifactId>
+ <version>2.0-incubator-SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-tools-java2wsdl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ </dependency>
+ </dependencies>
+
+ <!-- will remove this after it is got sync to central repository -->
+ <repositories>
+ <repository>
+ <id>java.net</id>
+ <url>https://maven-repository.dev.java.net/repository/</url>
+ <layout>legacy</layout>
+ </repository>
+ </repositories>
+
+ <scm>
+
<connection>scm:svn:http://svn.apache.org/repos/asf/incubator/cxf/trunk/wsdlgen-plugin</connection>
+
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/cxf/trunk/wsdlgen-plugin</developerConnection>
+
<url>http://svn.apache.org/viewvc/incubator/cxf/trunk/cxf-parent/cxf-wsdlgen-plugin</url>
+ </scm>
+
+</project>
\ No newline at end of file
Added:
incubator/cxf/trunk/wsdlgen-plugin/src/main/java/org/apache/cxf/maven_plugin/Java2WSDLMojo.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/wsdlgen-plugin/src/main/java/org/apache/cxf/maven_plugin/Java2WSDLMojo.java?view=auto&rev=536436
==============================================================================
---
incubator/cxf/trunk/wsdlgen-plugin/src/main/java/org/apache/cxf/maven_plugin/Java2WSDLMojo.java
(added)
+++
incubator/cxf/trunk/wsdlgen-plugin/src/main/java/org/apache/cxf/maven_plugin/Java2WSDLMojo.java
Tue May 8 23:21:02 2007
@@ -0,0 +1,196 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.maven_plugin;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cxf.helpers.FileUtils;
+import org.apache.cxf.tools.java2wsdl.JavaToWSDL;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.tools.ant.ExitException;
+import org.apache.tools.ant.util.optional.NoExitSecurityManager;
+
+/**
+ * @goal java2wsdl
+ * @description CXF Java To WSDL Tool
+ */
+public class Java2WSDLMojo extends AbstractMojo {
+ /**
+ * @parameter
+ * @required
+ */
+ String className;
+
+ /**
+ * @parameter expression="${project.build.outputDirectory}"
+ * @required
+ */
+ String classpath;
+
+ /**
+ * @parameter
+ */
+ String outputFile;
+
+ /**
+ * @parameter
+ */
+ Boolean soap12;
+
+ /**
+ * @parameter
+ */
+ String targetNamespace;
+
+ /**
+ * @parameter
+ */
+ String serviceName;
+
+ /**
+ * @parameter
+ */
+ Boolean verbose;
+
+ /**
+ * @parameter
+ */
+ Boolean quiet;
+
+ /**
+ * @parameter expression="${project.compileClasspathElements}"
+ * @required
+ */
+ List classpathElements;
+
+ /**
+ * @parameter expression="${project}"
+ * @required
+ */
+ MavenProject project;
+
+ public void execute() throws MojoExecutionException {
+ File classesDir = new File(classpath);
+ FileUtils.mkDir(classesDir);
+
+ StringBuffer buf = new StringBuffer();
+ for (Object classpathElement : classpathElements) {
+ buf.append(classpathElement.toString());
+ buf.append(File.pathSeparatorChar);
+ }
+ String newCp = buf.toString();
+
+ String cp = System.getProperty("java.class.path");
+ SecurityManager oldSm = System.getSecurityManager();
+ try {
+ System.setProperty("java.class.path", newCp);
+ System.setSecurityManager(new NoExitSecurityManager());
+ processJavaClass();
+ } finally {
+ System.setSecurityManager(oldSm);
+ System.setProperty("java.class.path", cp);
+ }
+
+ System.gc();
+ }
+
+ private void processJavaClass() throws MojoExecutionException {
+ List<String> args = new ArrayList<String>();
+
+ // outputfile arg
+ if (outputFile == null && project != null) {
+ // Put the wsdl in target/generated/wsdl
+ int i = className.lastIndexOf('.');
+ // Prone to OoBE, but then it's wrong anyway
+ String name = className.substring(i + 1);
+ outputFile = (project.getBuild().getDirectory() +
"/generated/wsdl/" + name + ".wsdl")
+ .replace("/", File.separator);
+ }
+ if (outputFile != null) {
+ // JavaToWSDL freaks out if the directory of the outputfile
doesn't exist, so lets
+ // create it since there's no easy way for the user to create it
beforehand in maven
+ FileUtils.mkDir(new File(outputFile).getParentFile());
+ args.add("-o");
+ args.add(outputFile);
+
+ /*
+ Contributor's comment:
+ Sometimes JavaToWSDL creates Java code for the wrappers. I
don't *think* this is
+ needed by the end user.
+ */
+
+ // Commiter's comment:
+ // Yes, it's required, it's defined in the JAXWS spec.
+
+ if (project != null) {
+ project.addCompileSourceRoot(new
File(outputFile).getParentFile().getAbsolutePath());
+ }
+ }
+
+ // classpath arg
+ args.add("-cp");
+ args.add(classpath);
+
+ // soap12 arg
+ if (soap12 != null && soap12.booleanValue()) {
+ args.add("-soap12");
+ }
+
+ // target namespace arg
+ if (targetNamespace != null) {
+ args.add("-t");
+ args.add(targetNamespace);
+ }
+
+ // servicename arg
+ if (serviceName != null) {
+ args.add("-servicename");
+ args.add(serviceName);
+ }
+
+ // verbose arg
+ if (verbose != null && verbose.booleanValue()) {
+ args.add("-verbose");
+ }
+
+ // quiet arg
+ if (quiet != null && quiet.booleanValue()) {
+ args.add("-quiet");
+ }
+
+ // classname arg
+ args.add(className);
+
+ String exitOnFinish = System.getProperty("exitOnFinish", "");
+ try {
+ JavaToWSDL.main(args.toArray(new String[args.size()]));
+ } catch (ExitException e) {
+ if (e.getStatus() != 0) {
+ throw e;
+ }
+ } finally {
+ System.setProperty("exitOnFinish", exitOnFinish);
+ }
+ }
+}