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>
Related
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 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.
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.
I created an ant build for my cordova project as following:
<project default="build">
<target name="init-android">
<exec executable="cordova">
<arg value="platform"/>
<arg value="add"/>
<arg value="android"/>
</exec>
<exec executable="cordova">
<arg value="build"/>
</exec>
</target>
</project>
But I got this error:
C:\path_to_project\build.xml:3: Execute failed: java.io.IOException:
Cannot run program "cordova": CreateProcess error=2, The system cannot
find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
at java.lang.Runtime.exec(Runtime.java:615)
at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Jav
a13CommandLauncher.java:41)
I can run cordova command with no problem from the command prompt, I have:
JAVA_HOME = C:/Program Files/Java/jdk1.7.0_10/
ANT_HOME = C:\Program Files\Java\apache-ant-1.9.2
NODEJS_HOME = C:\Program Files\nodejs
and they are all in my path. I don't understand why it doesn't work. Please help. Thanks
Generally when working with a Java application to launch programs in Windows, I often have to execute cmd.exe and pass it the full path to the program I actually want to run. This allows system environment variables and such to be set up the way you expect. Try this:
<project default="build">
<target name="init-android">
<exec executable="cmd.exe">
<arg value="/C"/>
<arg value="cordova"/>
<arg value="platform"/>
<arg value="add"/>
<arg value="android"/>
</exec>
<exec executable="cmd.exe">
<arg value="/C"/>
<arg value="cordova"/>
<arg value="build"/>
</exec>
</target>
</project>
If that still doesn't work, give the full path for cordova. An environment variable should work if you have one defined.
I can't run the windows 'start' using ant exec. Ant version 1.7.1.
Here is sample build.xml to recreate the problem
<project name="test" basedir="." default="test-target">
<target name="test-target">
<exec executable="start">
<arg line="cmd /c notepad" />
</exec>
</target>
</project>
getting the following error when I execute this build file:
Execute failed: java.io.IOException: Cannot run program "start": Cre
ateProcess error=2, The system cannot find the file specified
My env is Windows XP, Ant 1.7.1
I am trying to run this from DOS prompt.
I rule out any PATH related issues, as I could run 'start cmd /c notepad' from DOS promt manually.
Any suggestions on how to fix this?
cheers
a s
start is not an executable but is an internal command of the cmd.exe shell, so to start something you'd have to:
<exec executable="cmd.exe">
<arg line="/c start notepad" />
</exec>
EDIT:
For spawning multiple windows, this should work:
<target name="spawnwindows">
<exec executable="cmd.exe" spawn="yes">
<arg line="/c start cmd.exe /k echo test1" />
</exec>
<exec executable="cmd.exe" spawn="yes">
<arg line="/c start cmd.exe /k echo test2" />
</exec>
</target>
but you mentioned that spawn="true" is not applicable for your environment, why is that?
my solution
<project name="test" basedir="." default="test-target">
<target name="start-init">
<exec executable="where" outputproperty="START">
<arg line="start" />
</exec>
</target>
<target name="test-target">
<exec executable="${START}">
<arg line="cmd /c notepad" />
</exec>
</target>
</project>
How about <exec executable="start.exe"> ? Or start.bat ?
Also, where is basedir="." pointing to? If you place a <echo message="basedir = ${basedir}"/> just before your <exec> tag, does it print the correct folder (the one with the "start" program in it)?
Additionally, you could add <echoproperties /> before <exec> to see all visible properties.