Maven

Maven Antrun Plugin Example

In this example we are going to see how we can use the antrun maven plugin in order to run ant build files inside maven builds.

Maven is a build automation tool used mainly for java projects from apache.

Ant is a software tool for automating software build processes from apache originally created as a replacement for the unix make build tool. It originally come from Apache tomcat project in early 2000.

We are going to integrate an ant build file inside maven pom file in order to generate a SOAP Web Service artifacts that originally were created by ant tool.

For this example we use the following technologies:

  • MAC OSX
  • Eclipse Luna
  • Maven3
  • JDK 1.8.0_65 64bits
  • Maven antrun plugin 1.8

1. Introduction

For this example we are going to integrate an ant build file inside a maven build. Imagine that our boss come and he say to us that we have to move our actual project based on ant to a maven project, but we can not update yet the generate web services stuff process.

In this situation we have to continue using the actual ant build file to generate the web services base classes, but the project will not be an ant project anymore.

In this kind of situations the maven antrun plugin will help us to run ant build files inside maven lifecycle.

2. Example project

For this example, we are going to use a java project with maven nature that will be packaged as a jar file. Eclipse Luna comes with maven support out of the box, so you don´t have to install anything. Our project will look like this

Initial project, an empty maven project.
Initial project, an empty maven project.

At this point, we have an empty maven project. In order to generate web services artifacts we have to add the CXF dependency needed to run WSDLToJava in the pom.xml file (you can choose another Web Service framework if you want), so our pom.xml will look like this

pom.xml:

<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>com.javacodegeeks.examples</groupId>
	<artifactId>maven-antrun-plugin-example</artifactId>
	<version>1.0.0-SNAPSHOT</version>
	<name>Macen ant run ::  example</name>
	<url>http://maven.apache.org</url>

	<properties>
		<cxf.bundle.version>2.7.18</cxf.bundle.version>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-bundle</artifactId>
			<version>${cxf.bundle.version}</version>
		</dependency>
	</dependencies>
</project>

The next step is to create all the things needed to run the ant build file inside maven.

3. Configure maven antrun plugin

Once you have the maven project ready, you have to add the plugin for run ant build files. To do it you have to edit the pom.xml file.

Now the pom.xml file will look like this

pom.xml:

<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>com.javacodegeeks.examples</groupId>
	<artifactId>maven-antrun-plugin-example</artifactId>
	<version>1.0.0-SNAPSHOT</version>
	<name>Macen ant run ::  example</name>
	<url>http://maven.apache.org</url>

	<properties>
		<cxf.bundle.version>2.7.18</cxf.bundle.version>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-bundle</artifactId>
			<version>${cxf.bundle.version}</version>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<artifactId>maven-jar-plugin</artifactId>
				<version>2.4</version>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<version>1.8</version>
				<executions>
					<execution>
						<id>generate-sources</id>
						<phase>generate-sources</phase>
						<configuration>
							<target>
								<property name="compile_classpath" refid="maven.compile.classpath" />
								<property name="runtime_classpath" refid="maven.runtime.classpath" />
								<property name="test_classpath" refid="maven.test.classpath" />
								<property name="plugin_classpath" refid="maven.plugin.classpath" />
								<property name="outputDir" value="${project.build.outputDirectory}" />
								<property name="sourceDir" value="${project.build.sourceDirectory}" />

								<ant antfile="${basedir}/build.xml">
									<target name="generateWSClient" />
								</ant>
							</target>
						</configuration>
						<goals>
							<goal>run</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
		<pluginManagement>
			<plugins>
				<!--This plugin's configuration is used to store Eclipse m2e settings 
					only. It has no influence on the Maven build itself. -->
				<plugin>
					<groupId>org.eclipse.m2e</groupId>
					<artifactId>lifecycle-mapping</artifactId>
					<version>1.0.0</version>
					<configuration>
						<lifecycleMappingMetadata>
							<pluginExecutions>
								<pluginExecution>
									<pluginExecutionFilter>
										<groupId>
											org.apache.maven.plugins
										</groupId>
										<artifactId>
											maven-antrun-plugin
										</artifactId>
										<versionRange>
											[1.8,)
										</versionRange>
										<goals>
											<goal>run</goal>
										</goals>
									</pluginExecutionFilter>
									<action>
										<ignore></ignore>
									</action>
								</pluginExecution>
							</pluginExecutions>
						</lifecycleMappingMetadata>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>
</project>

We have added the org.eclipse.m2e:lifecycle-mapping in order to manage dependencies in m2e eclipse settings, this plugin have not influence on the maven build itself and is not necessary for this tutorial but will help you to avoid some errors from eclipse m2e lifecycle management.

The pom.xml file defines the antrun plugin in lines 30 to 32 and defines an execution phase inside the generate-sources maven phase, so when a maven execution triggers the generate-sources phase, the plugin will execute.

In the execution configuration tag (line 37 to 50) we are defining some properties, you can define all the properties that you need in order to run the ant task here. We are defining the ant build file we want to run in lines 46 to 48, so now we have to add the file to our project and all the files needed by the ant build file.

4. Import ant build file and wsdl file

In order to add the ant build file to our project, create a build.xml file in root folder and add the following content

build.xml:

<?xml version="1.0"?>
<project name="javacodegeeks-examples">

	<!-- property name="cxf.home" location="/usr/myapps/cxf-2.5.1" / -->

	<path id="cxf.classpath">
		<pathelement path="${runtime_classpath}"/>
	</path>

	<target name="generateWSClient">

		<echo message="compile classpath: ${compile_classpath}" />
		<echo message="runtime classpath: ${runtime_classpath}" />
		<echo message="test classpath:    ${test_classpath}" />
		<echo message="plugin classpath:  ${plugin_classpath}" />

		<java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true">
			<arg value="-client" />
			<arg value="-verbose" />
			<arg value="-d" />
			<arg value="src/main/java" />
			<arg value="${basedir}/wsdl/sayHello.wsdl" />
			<classpath>
				<path refid="cxf.classpath" />
			</classpath>
		</java>
	</target>

</project>

Let´s see the file content. We are defining a classpath resource called cxf.classpath in line 6, and we have commented the old CXF reference because we do not need it. We are using the maven runtime classpath inside ant, this is an antrun plugin feature. We can use the following classpaths in ant files:

  • compile_classpath
  • runtime_classpath
  • test_classpath
  • plugin_classpath

We have to explicity define in antrun plugin that it has to expose those classpaths as properties. We can see how those properties are defined in our pom.xml file in lines 39 to 42. The build file prints some echos in order to show those properties.

Now we have to create a new folder called wsdl in the root folder and copy to it our wsdl files, in this example we are going to define a SayHello service without any schema information for demostration purpose. Create inside the new folder a file called sayHello.wsdl with the following content

sayHello.wsdl:

<?xml version="1.0" encoding="UTF-8"?>

<definitions 
	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
	xmlns:tns="http://ws.javacodegeeks.com/" 
	xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
	xmlns="http://schemas.xmlsoap.org/wsdl/" 
	targetNamespace="http://ws.javacodegeeks.com/" 
	name="SayHelloImplService">

	<types></types>

	<message name="getSayHelloAsString">
		<part name="arg0" type="xsd:string"></part>
	</message>
	<message name="getSayHelloAsStringResponse">
		<part name="return" type="xsd:string"></part>
	</message>

	<portType name="SayHello">
		<operation name="getSayHelloAsString" parameterOrder="arg0">
			<input message="tns:getSayHelloAsString"></input>
			<output message="tns:getSayHelloAsStringResponse"></output>
		</operation>
	</portType>

	<binding name="SayHelloImplPortBinding" type="tns:SayHello">

		<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"></soap:binding>
		<operation name="getSayHelloAsString">
			<soap:operation soapAction=""></soap:operation>
			<input>
				<soap:body use="literal" namespace="http://ws.javacodegeeks.com/"></soap:body>
			</input>
			<output>
				<soap:body use="literal" namespace="http://ws.javacodegeeks.com/"></soap:body>
			</output>
		</operation>

	</binding>

	<service name="SayHelloImplService">
		<port name="SayHelloImplPort" binding="tns:SayHelloImplPortBinding">
			<soap:address location="http://localhost:8080/ws/hello"></soap:address>
		</port>
	</service>
</definitions>

Now, our project will look like this

final project, after all modfications
final project, after all modfications

5. Running the maven build

We are ready to go. We can build our maven project with mvn generate-sources or mvn clean install, we can see something like this

Output:

[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven ant run ::  example 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-antrun-plugin-example ---
[INFO] Deleting /Users/fhernandez/git/javacodegeeks-examples/maven-antrun-plugin/target
[INFO] 
[INFO] --- maven-antrun-plugin:1.8:run (generate-sources) @ maven-antrun-plugin-example ---
[INFO] Executing tasks

main:

generateWSClient:
     [echo] compile classpath: /Users/fhernandez/git/javacodegeeks-examples/maven-antrun-plugin/target/classes:/Users/fhernandez/.m2/repository/org/apache/cxf/cxf-bundle/2.7.18/cxf-bundle-2.7.18.jar:/Users/fhernandez/.m2/repository/org/apache/velocity/velocity/1.7/velocity-1.7.jar:/Users/fhernandez/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/Users/fhernandez/.m2/repository/wsdl4j/wsdl4j/1.6.3/wsdl4j-1.6.3.jar:/Users/fhernandez/.m2/repository/com/sun/xml/bind/jaxb-xjc/2.2.6/jaxb-xjc-2.2.6.jar:/Users/fhernandez/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.6/jaxb-impl-2.2.6.jar:/Users/fhernandez/.m2/repository/org/apache/ws/xmlschema/xmlschema-core/2.1.0/xmlschema-core-2.1.0.jar:/Users/fhernandez/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/fhernandez/.m2/repository/org/apache/xmlbeans/xmlbeans/2.6.0/xmlbeans-2.6.0.jar:/Users/fhernandez/.m2/repository/xml-resolver/xml-resolver/1.2/xml-resolver-1.2.jar:/Users/fhernandez/.m2/repository/org/apache/geronimo/specs/geronimo-jaxws_2.2_spec/1.1/geronimo-jaxws_2.2_spec-1.1.jar:/Users/fhernandez/.m2/repository/org/codehaus/woodstox/woodstox-core-asl/4.4.1/woodstox-core-asl-4.4.1.jar:/Users/fhernandez/.m2/repository/org/codehaus/woodstox/stax2-api/3.1.4/stax2-api-3.1.4.jar:/Users/fhernandez/.m2/repository/org/apache/geronimo/specs/geronimo-javamail_1.4_spec/1.7.1/geronimo-javamail_1.4_spec-1.7.1.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-server/8.1.15.v20140411/jetty-server-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-continuation/8.1.15.v20140411/jetty-continuation-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-http/8.1.15.v20140411/jetty-http-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-io/8.1.15.v20140411/jetty-io-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-util/8.1.15.v20140411/jetty-util-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-security/8.1.15.v20140411/jetty-security-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/slf4j/slf4j-api/1.7.9/slf4j-api-1.7.9.jar:/Users/fhernandez/.m2/repository/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0/geronimo-servlet_3.0_spec-1.0.jar:/Users/fhernandez/.m2/repository/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-jms/3.0.7.RELEASE/spring-jms-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-aop/3.0.7.RELEASE/spring-aop-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-beans/3.0.7.RELEASE/spring-beans-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-core/3.0.7.RELEASE/spring-core-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-context/3.0.7.RELEASE/spring-context-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-expression/3.0.7.RELEASE/spring-expression-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-asm/3.0.7.RELEASE/spring-asm-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-tx/3.0.7.RELEASE/spring-tx-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/Users/fhernandez/.m2/repository/org/apache/httpcomponents/httpcore-nio/4.2.4/httpcore-nio-4.2.4.jar:/Users/fhernandez/.m2/repository/org/apache/httpcomponents/httpcore/4.2.4/httpcore-4.2.4.jar:/Users/fhernandez/.m2/repository/org/apache/httpcomponents/httpasyncclient/4.0-beta3/httpasyncclient-4.0-beta3.jar:/Users/fhernandez/.m2/repository/org/apache/httpcomponents/httpclient/4.2.5/httpclient-4.2.5.jar:/Users/fhernandez/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:/Users/fhernandez/.m2/repository/org/apache/mina/mina-core/2.0.7/mina-core-2.0.7.jar:/Users/fhernandez/.m2/repository/asm/asm/3.3.1/asm-3.3.1.jar:/Users/fhernandez/.m2/repository/rhino/js/1.7R2/js-1.7R2.jar:/Users/fhernandez/.m2/repository/javax/ws/rs/javax.ws.rs-api/2.0-m10/javax.ws.rs-api-2.0-m10.jar:/Users/fhernandez/.m2/repository/net/oauth/core/oauth-provider/20100527/oauth-provider-20100527.jar:/Users/fhernandez/.m2/repository/net/oauth/core/oauth/20100527/oauth-20100527.jar:/Users/fhernandez/.m2/repository/net/sf/ehcache/ehcache-core/2.5.1/ehcache-core-2.5.1.jar:/Users/fhernandez/.m2/repository/org/apache/ws/security/wss4j/1.6.19/wss4j-1.6.19.jar:/Users/fhernandez/.m2/repository/org/apache/santuario/xmlsec/1.5.8/xmlsec-1.5.8.jar:/Users/fhernandez/.m2/repository/org/opensaml/opensaml/2.6.1/opensaml-2.6.1.jar:/Users/fhernandez/.m2/repository/org/opensaml/openws/1.5.1/openws-1.5.1.jar:/Users/fhernandez/.m2/repository/org/opensaml/xmltooling/1.4.1/xmltooling-1.4.1.jar:/Users/fhernandez/.m2/repository/joda-time/joda-time/2.2/joda-time-2.2.jar:/Users/fhernandez/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/Users/fhernandez/.m2/repository/org/apache/neethi/neethi/3.0.3/neethi-3.0.3.jar
     [echo] runtime classpath: /Users/fhernandez/git/javacodegeeks-examples/maven-antrun-plugin/target/classes:/Users/fhernandez/.m2/repository/org/apache/cxf/cxf-bundle/2.7.18/cxf-bundle-2.7.18.jar:/Users/fhernandez/.m2/repository/org/apache/velocity/velocity/1.7/velocity-1.7.jar:/Users/fhernandez/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/Users/fhernandez/.m2/repository/wsdl4j/wsdl4j/1.6.3/wsdl4j-1.6.3.jar:/Users/fhernandez/.m2/repository/com/sun/xml/bind/jaxb-xjc/2.2.6/jaxb-xjc-2.2.6.jar:/Users/fhernandez/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.6/jaxb-impl-2.2.6.jar:/Users/fhernandez/.m2/repository/org/apache/ws/xmlschema/xmlschema-core/2.1.0/xmlschema-core-2.1.0.jar:/Users/fhernandez/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/fhernandez/.m2/repository/org/apache/xmlbeans/xmlbeans/2.6.0/xmlbeans-2.6.0.jar:/Users/fhernandez/.m2/repository/xml-resolver/xml-resolver/1.2/xml-resolver-1.2.jar:/Users/fhernandez/.m2/repository/org/apache/geronimo/specs/geronimo-jaxws_2.2_spec/1.1/geronimo-jaxws_2.2_spec-1.1.jar:/Users/fhernandez/.m2/repository/org/codehaus/woodstox/woodstox-core-asl/4.4.1/woodstox-core-asl-4.4.1.jar:/Users/fhernandez/.m2/repository/org/codehaus/woodstox/stax2-api/3.1.4/stax2-api-3.1.4.jar:/Users/fhernandez/.m2/repository/org/apache/geronimo/specs/geronimo-javamail_1.4_spec/1.7.1/geronimo-javamail_1.4_spec-1.7.1.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-server/8.1.15.v20140411/jetty-server-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-continuation/8.1.15.v20140411/jetty-continuation-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-http/8.1.15.v20140411/jetty-http-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-io/8.1.15.v20140411/jetty-io-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-util/8.1.15.v20140411/jetty-util-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-security/8.1.15.v20140411/jetty-security-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/slf4j/slf4j-api/1.7.9/slf4j-api-1.7.9.jar:/Users/fhernandez/.m2/repository/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0/geronimo-servlet_3.0_spec-1.0.jar:/Users/fhernandez/.m2/repository/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-jms/3.0.7.RELEASE/spring-jms-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-aop/3.0.7.RELEASE/spring-aop-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-beans/3.0.7.RELEASE/spring-beans-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-core/3.0.7.RELEASE/spring-core-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-context/3.0.7.RELEASE/spring-context-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-expression/3.0.7.RELEASE/spring-expression-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-asm/3.0.7.RELEASE/spring-asm-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-tx/3.0.7.RELEASE/spring-tx-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/Users/fhernandez/.m2/repository/org/apache/httpcomponents/httpcore-nio/4.2.4/httpcore-nio-4.2.4.jar:/Users/fhernandez/.m2/repository/org/apache/httpcomponents/httpcore/4.2.4/httpcore-4.2.4.jar:/Users/fhernandez/.m2/repository/org/apache/httpcomponents/httpasyncclient/4.0-beta3/httpasyncclient-4.0-beta3.jar:/Users/fhernandez/.m2/repository/org/apache/httpcomponents/httpclient/4.2.5/httpclient-4.2.5.jar:/Users/fhernandez/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:/Users/fhernandez/.m2/repository/org/apache/mina/mina-core/2.0.7/mina-core-2.0.7.jar:/Users/fhernandez/.m2/repository/asm/asm/3.3.1/asm-3.3.1.jar:/Users/fhernandez/.m2/repository/rhino/js/1.7R2/js-1.7R2.jar:/Users/fhernandez/.m2/repository/javax/ws/rs/javax.ws.rs-api/2.0-m10/javax.ws.rs-api-2.0-m10.jar:/Users/fhernandez/.m2/repository/net/oauth/core/oauth-provider/20100527/oauth-provider-20100527.jar:/Users/fhernandez/.m2/repository/net/oauth/core/oauth/20100527/oauth-20100527.jar:/Users/fhernandez/.m2/repository/net/sf/ehcache/ehcache-core/2.5.1/ehcache-core-2.5.1.jar:/Users/fhernandez/.m2/repository/org/apache/ws/security/wss4j/1.6.19/wss4j-1.6.19.jar:/Users/fhernandez/.m2/repository/org/apache/santuario/xmlsec/1.5.8/xmlsec-1.5.8.jar:/Users/fhernandez/.m2/repository/org/opensaml/opensaml/2.6.1/opensaml-2.6.1.jar:/Users/fhernandez/.m2/repository/org/opensaml/openws/1.5.1/openws-1.5.1.jar:/Users/fhernandez/.m2/repository/org/opensaml/xmltooling/1.4.1/xmltooling-1.4.1.jar:/Users/fhernandez/.m2/repository/joda-time/joda-time/2.2/joda-time-2.2.jar:/Users/fhernandez/.m2/repository/xalan/serializer/2.7.1/serializer-2.7.1.jar:/Users/fhernandez/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/Users/fhernandez/.m2/repository/org/apache/neethi/neethi/3.0.3/neethi-3.0.3.jar
     [echo] test classpath:    /Users/fhernandez/git/javacodegeeks-examples/maven-antrun-plugin/target/test-classes:/Users/fhernandez/git/javacodegeeks-examples/maven-antrun-plugin/target/classes:/Users/fhernandez/.m2/repository/org/apache/cxf/cxf-bundle/2.7.18/cxf-bundle-2.7.18.jar:/Users/fhernandez/.m2/repository/org/apache/velocity/velocity/1.7/velocity-1.7.jar:/Users/fhernandez/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/Users/fhernandez/.m2/repository/wsdl4j/wsdl4j/1.6.3/wsdl4j-1.6.3.jar:/Users/fhernandez/.m2/repository/com/sun/xml/bind/jaxb-xjc/2.2.6/jaxb-xjc-2.2.6.jar:/Users/fhernandez/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.6/jaxb-impl-2.2.6.jar:/Users/fhernandez/.m2/repository/org/apache/ws/xmlschema/xmlschema-core/2.1.0/xmlschema-core-2.1.0.jar:/Users/fhernandez/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/fhernandez/.m2/repository/org/apache/xmlbeans/xmlbeans/2.6.0/xmlbeans-2.6.0.jar:/Users/fhernandez/.m2/repository/xml-resolver/xml-resolver/1.2/xml-resolver-1.2.jar:/Users/fhernandez/.m2/repository/org/apache/geronimo/specs/geronimo-jaxws_2.2_spec/1.1/geronimo-jaxws_2.2_spec-1.1.jar:/Users/fhernandez/.m2/repository/org/codehaus/woodstox/woodstox-core-asl/4.4.1/woodstox-core-asl-4.4.1.jar:/Users/fhernandez/.m2/repository/org/codehaus/woodstox/stax2-api/3.1.4/stax2-api-3.1.4.jar:/Users/fhernandez/.m2/repository/org/apache/geronimo/specs/geronimo-javamail_1.4_spec/1.7.1/geronimo-javamail_1.4_spec-1.7.1.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-server/8.1.15.v20140411/jetty-server-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-continuation/8.1.15.v20140411/jetty-continuation-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-http/8.1.15.v20140411/jetty-http-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-io/8.1.15.v20140411/jetty-io-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-util/8.1.15.v20140411/jetty-util-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/eclipse/jetty/jetty-security/8.1.15.v20140411/jetty-security-8.1.15.v20140411.jar:/Users/fhernandez/.m2/repository/org/slf4j/slf4j-api/1.7.9/slf4j-api-1.7.9.jar:/Users/fhernandez/.m2/repository/org/apache/geronimo/specs/geronimo-servlet_3.0_spec/1.0/geronimo-servlet_3.0_spec-1.0.jar:/Users/fhernandez/.m2/repository/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-jms/3.0.7.RELEASE/spring-jms-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-aop/3.0.7.RELEASE/spring-aop-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-beans/3.0.7.RELEASE/spring-beans-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-core/3.0.7.RELEASE/spring-core-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-context/3.0.7.RELEASE/spring-context-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-expression/3.0.7.RELEASE/spring-expression-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-asm/3.0.7.RELEASE/spring-asm-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/org/springframework/spring-tx/3.0.7.RELEASE/spring-tx-3.0.7.RELEASE.jar:/Users/fhernandez/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/Users/fhernandez/.m2/repository/org/apache/httpcomponents/httpcore-nio/4.2.4/httpcore-nio-4.2.4.jar:/Users/fhernandez/.m2/repository/org/apache/httpcomponents/httpcore/4.2.4/httpcore-4.2.4.jar:/Users/fhernandez/.m2/repository/org/apache/httpcomponents/httpasyncclient/4.0-beta3/httpasyncclient-4.0-beta3.jar:/Users/fhernandez/.m2/repository/org/apache/httpcomponents/httpclient/4.2.5/httpclient-4.2.5.jar:/Users/fhernandez/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:/Users/fhernandez/.m2/repository/org/apache/mina/mina-core/2.0.7/mina-core-2.0.7.jar:/Users/fhernandez/.m2/repository/asm/asm/3.3.1/asm-3.3.1.jar:/Users/fhernandez/.m2/repository/rhino/js/1.7R2/js-1.7R2.jar:/Users/fhernandez/.m2/repository/javax/ws/rs/javax.ws.rs-api/2.0-m10/javax.ws.rs-api-2.0-m10.jar:/Users/fhernandez/.m2/repository/net/oauth/core/oauth-provider/20100527/oauth-provider-20100527.jar:/Users/fhernandez/.m2/repository/net/oauth/core/oauth/20100527/oauth-20100527.jar:/Users/fhernandez/.m2/repository/net/sf/ehcache/ehcache-core/2.5.1/ehcache-core-2.5.1.jar:/Users/fhernandez/.m2/repository/org/apache/ws/security/wss4j/1.6.19/wss4j-1.6.19.jar:/Users/fhernandez/.m2/repository/org/apache/santuario/xmlsec/1.5.8/xmlsec-1.5.8.jar:/Users/fhernandez/.m2/repository/org/opensaml/opensaml/2.6.1/opensaml-2.6.1.jar:/Users/fhernandez/.m2/repository/org/opensaml/openws/1.5.1/openws-1.5.1.jar:/Users/fhernandez/.m2/repository/org/opensaml/xmltooling/1.4.1/xmltooling-1.4.1.jar:/Users/fhernandez/.m2/repository/joda-time/joda-time/2.2/joda-time-2.2.jar:/Users/fhernandez/.m2/repository/xalan/serializer/2.7.1/serializer-2.7.1.jar:/Users/fhernandez/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/Users/fhernandez/.m2/repository/org/apache/neethi/neethi/3.0.3/neethi-3.0.3.jar
     [echo] plugin classpath:  /Users/fhernandez/.m2/repository/org/apache/maven/plugins/maven-antrun-plugin/1.8/maven-antrun-plugin-1.8.jar:/Users/fhernandez/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar:/Users/fhernandez/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar:/Users/fhernandez/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar:/Users/fhernandez/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.20/plexus-utils-3.0.20.jar:/Users/fhernandez/.m2/repository/org/apache/ant/ant/1.9.4/ant-1.9.4.jar:/Users/fhernandez/.m2/repository/org/apache/ant/ant-launcher/1.9.4/ant-launcher-1.9.4.jar
      Loading FrontEnd jaxws ...
      Loading DataBinding jaxb ...
      wsdl2java -client -verbose -d src/main/java /Users/fhernandez/git/javacodegeeks-examples/maven-antrun-plugin/wsdl/sayHello.wsdl
      wsdl2java - Apache CXF 2.7.18
      
      nov 17, 2015 5:04:11 PM org.apache.cxf.wsdl11.WSDLServiceBuilder checkForWrapped
      INFORMACIÓN: Operation {http://ws.javacodegeeks.com/}getSayHelloAsString cannot be unwrapped, input message must reference global element declaration with same localname as operation
[INFO] Executed tasks
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-antrun-plugin-example ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ maven-antrun-plugin-example ---
[INFO] Compiling 3 source files to /Users/fhernandez/git/javacodegeeks-examples/maven-antrun-plugin/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-antrun-plugin-example ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ maven-antrun-plugin-example ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-antrun-plugin-example ---
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-antrun-plugin-example ---
[INFO] Building jar: /Users/fhernandez/git/javacodegeeks-examples/maven-antrun-plugin/target/maven-antrun-plugin-example-1.0.0-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ maven-antrun-plugin-example ---
[INFO] Installing /Users/fhernandez/git/javacodegeeks-examples/maven-antrun-plugin/target/maven-antrun-plugin-example-1.0.0-SNAPSHOT.jar to /Users/fhernandez/.m2/repository/com/javacodegeeks/examples/maven-antrun-plugin-example/1.0.0-SNAPSHOT/maven-antrun-plugin-example-1.0.0-SNAPSHOT.jar
[INFO] Installing /Users/fhernandez/git/javacodegeeks-examples/maven-antrun-plugin/pom.xml to /Users/fhernandez/.m2/repository/com/javacodegeeks/examples/maven-antrun-plugin-example/1.0.0-SNAPSHOT/maven-antrun-plugin-example-1.0.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.233 s
[INFO] Finished at: 2015-11-17T17:04:13+01:00
[INFO] Final Memory: 22M/217M
[INFO] ------------------------------------------------------------------------

After running mvn clean install, look the line 17 on previous output. You will see how maven calls the generateWSClient ant target.

6. See the result jar file

Now, after run mvn clean install, you can explode the generated jar and you can see inside it the generated and compiled classes, like this

Generated and compiled classes inside jar file
Generated and compiled classes inside jar file

7. Download the eclipse project

Download
You can download the full source code of this example here: maven-antrun-plugin-example.zip

Francisco Hernandez

JEE technologies geek and development engineer. I have over 13 years of experience as software engineer in JEE architectures: Design, development, improvement etc. Currently I work as software architect and consultant. I am mainly involved in projects related to the bank and energy sectors based on Java technologies and Oracle products. I am also very interested in open-source projects
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button