how to deploy to Glassfish with Gradle? - 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.

Related

Specifying maven project directory in exec tag

I am running this in Bamboo using command task executable=Gradle.
<target name="deploy-jar">
<exec executable="${maven.bin}" >
<arg value="deploy:deploy-file" />
<arg value="-DgroupId=${groupid}" />
<arg value="-DartifactId=${artifact}" />
<arg value="-Dversion=${version}" />
<arg value="-Dpackaging=jar" />
<arg value="-Dfile=${file}" />
<arg value="-Durl=${maven.repo.url}"/>
<arg value="-DrepositoryId=${maven.repo.id}" />
</exec>
</target>
The build is failing due to incorrect executable="${maven.bin}"
Would someone be able to give me the proper maven project location for it to run in Bamboo successfully? or at least an idea.
Thank you!!

How to use skipTests option when using mvn-ant-tasks in ant

I am using mvn-ant-task in a build file to clean and install the Maven projects.
Below is the configuration I did
<project name="maven-project"
default="default"
xmlns:artifact="antlib:org.apache.maven.artifact.ant">
and in the target, I have added something like this
<target name="CleanInstall">
<echo message="Building the project using maven and skipping tests if any in ${RepoFolder}" />
<artifact:mvn pom="${GIT_REPO_HOME}\${RepoFolder}\pom.xml">
<arg value="clean:clean" />
</artifact:mvn>
<artifact:mvn pom="${GIT_REPO_HOME}\${RepoFolder}\pom.xml">
<arg value="install:install -DskipTests=true" />
</artifact:mvn>
</target>
When I run this build, clean is processing properly, but I am unable to send the arguments skipTests in the install plugin.
Is there any other way to execute the Maven commands from Ant? I also tried
<exec command="mvn install -DskipTests=true" dir=""${GIT_REPO_HOME}\${RepoFolder}\pom.xml"/>
Its failing with error given below
C:\Users\sharath\Desktop\devsetup\build.xml:102: Execute failed:
java.io.IOException: Cannot run program "mvn" (in directory
"D:\sbhaskara\GIT\connectmodel"): CreateProcess error=2, The system
cannot find the file specified
You are not building the argument for the task correctly, it should be:
<target name="CleanInstall">
<echo message="Building the project using maven and skipping tests if any in ${RepoFolder}" />
<artifact:mvn pom="${GIT_REPO_HOME}\${RepoFolder}\pom.xml" >
<arg value="-Dmaven.test.skip=true" />
<arg value="clean" />
<arg value="install" />
</artifact:mvn>
</target>
i.e. each argument must be in its own <arg> tag. Note that I collapsed all the calls to Maven inside a single task.

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>

WSDL2Java in Ant

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>

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