WSDL2Java in Ant - maven

What is the exact way of generating a Java code using WSDL in a ant build file? There were so many ways given, but most of them are not reorganized by Ant.

There is Axis Ant Task for this. There is also CXF way of doing things. I would use Apache CXF, like this:
<target name="cxfWSDLToJava">
<java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true">
<arg value="-client"/>
<arg value="-d"/>
<arg value="src"/>
<arg value="MyWSDL.wsdl"/>
<classpath>
<path refid="cxf.classpath"/>
</classpath>
</java>
</target>

Related

How to run Maven command in ant script?

I am trying to create an ant task to execute a maven command, but I am getting error while running the ant task
<target name="Junit">
<exec dir="./MServer/BuildServer/Workspc/CustMgmt" executable="cmd">
<arg value="/C"/>
<arg value="E:\EOM Setup\maven-3.3.9\bin\mvn.bat"/>
<arg value="test" />
</exec>
</target>
While am running this, am getting an error:
'E:\EOM' is not recognized as internal or external command, operable program or batch file
(I am running on Windows 7)
You can get around this issue by using Ant's property task with the location attribute (as opposed to the more common value attribute). This will store the value as a properly formatted path. In addition, you can use this to reference mvn.bat instead of typing out the entire path every time.
<target name="Junit">
<property name="mvn.executable" location="E:\EOM Setup\maven-3.3.9\bin\mvn.bat" />
<exec dir="./MServer/BuildServer/Workspc/CustMgmt" executable="cmd">
<arg value="/C"/>
<arg value="${mvn.executable}"/>
<arg value="test" />
</exec>
</target>

how to deploy to Glassfish with Gradle?

How does Gradle deploy to Glassfish?
Ant example:
<target name="deploy"
description="deploys application to glassfish">
<exec failonerror="true" executable="cmd">
<arg value="/c" />
<arg value="asadmin --user ${gfUser} --passwordfile ${gfPassFile} --host ${host} deploy build/${war}" />
</exec>
</target>
Yes, I could use asadmin but doing so from Gradle would be so much more Groovy.

install highcharts exporting server

I'm trying to install highcharts exporting server(by java). I want to write below maven command line in build.xml file of my project. Not run from cmd.
$ cd highcharts-export/
$ mvn install
How should I do that in build.xml file?
I wrote following in build.xml file and run by ANT. But nothing happens. And idea?
<target name="buildHighchartsExporting" description="Builds highcharts exporting">
<exec dir="${basedir}/highcharts-export" executable="cmd">
<arg value="mvn" />
<arg line="-f highcharts-export/pom.xml install" />
</exec>
<target name="buildWarFile" description="Builds highcharts exporting War">
<exec dir="${basedir}/highcharts-export/highcharts-export-web" executable="cmd">
<arg value="mvn" />
<arg line="clean package" />
</exec>
If you are just trying to execute a project where the pom.xml is at another folder, you can use the -f parameter:
6.1.6. Using a Custom POM or Custom Settings File
If you don’t like the pom.xml file name, the location of your user-specific Maven
settings, or the default location of your global settings file, you
can customize any of these things with the following options:
-f, --file <file>
Forces the use of an alternate POM file
This way, from where you'd execute:
$ cd highcharts-export/
$ mvn install
You can just use:
$ mvn -f highcharts-export/pom.xml install
Running mvn from an ANT build.xml file
You can use the Ant Exec Task:
<target name="buildProject" description="Builds the project">
<exec dir="${source.dir}\${projectName}" executable="cmd">
<arg value="mvn" />
<arg line="-f highcharts-export/pom.xml install" />
</exec>
</target>
Or, more specifically (to your example):
<target name="buildWarFile" description="Builds highcharts exporting War">
<exec dir="${basedir}/highcharts-export" executable="cmd">
<arg value="mvn" />
<arg line="clean package" />
</exec>

How can I run perl and ruby scripts as tasks in ant?

I would like to be able to run ruby and perl scripts from build.xml in ant.
Languages like Ruby have Java implementations.
<project name="RunRubyExample">
<property environment="env" />
<script language="ruby" manager="bsf">
<classpath>
<fileset dir="${env.JRUBY_HOME}/lib" includes="*.jar" />
</classpath>
print 'hello world'
</script>
</project>
See the list of languages supporting the JSR233 standard.
Unfortunately no Java version of Perl is available. The only way to run Perl scripts is to invoke the interpreter directly:
<project name="RunPerlExample">
<exec executable="perl" failonerror="true">
<arg value="-e" />
<arg value="print 'hello world'" />
</exec>
</project>
You can always use the ant`s exec task to run arbitrary programs, such as ruby and perl. For example and from the docs:
<target name="help">
<exec executable="cmd">
<arg value="/c"/>
<arg value="ant.bat"/>
<arg value="-p"/>
</exec>
</target>

Deploying non Maven based module src and tests jar to Archiva in a single transaction

Is it possible to use Maven deploy:deploy-file or similar to deploy your main src jar snapshot and the test src jar snapshot to Archiva so that it results in a single entry?
Currently I have an Ant project which has jars I want publishing to Archiva and here is how I am doing it:
<!--Main Src Jar-->
<exec executable="${maven.bin}" dir="../lib">
<arg value="deploy:deploy-file" />
<arg value="-DgroupId=com.xxx.gt" />
<arg value="-DartifactId=${ant.project.name}" />
<arg value="-Dversion=${manifest.implementation.version}-SNAPSHOT" />
<arg value="-Dpackaging=jar" />
<arg value="-Dfile=../lib/${ant.project.name}-${manifest.implementation.version}-SNAPSHOT.jar" />
<arg value="-Durl=http://archiva.xxx.com/archiva/repository/snapshots" />
<arg value="-DrepositoryId=snapshots" />
</exec>
<!--Test Src Jar-->
<exec executable="${maven.bin}" dir="../lib">
<arg value="deploy:deploy-file" />
<arg value="-DgroupId=com.xxx.gt" />
<arg value="-DartifactId=${ant.project.name}" />
<arg value="-Dversion=${manifest.implementation.version}-SNAPSHOT" />
<arg value="-Dpackaging=jar" />
<arg value="-Dfile=../lib/${ant.project.name}-${manifest.implementation.version}-SNAPSHOT-tests.jar" />
<arg value="-Durl=http://archiva.xxx.com/archiva/repository/snapshots" />
<arg value="-DrepositoryId=snapshots" />
<arg value="-Dclassifier=tests" />
</exec>
The above Ant script will result in two snapshots on Archiva, 1 with the main src jar and the other with the test src jar.
Using mvn deploy on a typical Maven project will group the artifacts together.
Non Grouped Archiva Image
Has a sanpshot entry per deploy:deploy-file command
Grouped Archiva Image
Has a single sanpshot entry grouping src and tests jars.
Here's my earlier post which will help explain how I got to this point.
If anyone knows how to solve this I'd appreciate it.
Thank You
I think that the maven-deploy-plugin has evolved a lot. Right now it is possible to deploy multiple files within a single execution. See http://maven.apache.org/plugins/maven-deploy-plugin/examples/deploying-with-classifiers.html for the description.

Resources