Does anyone know of a GUI written for Apache ANT. We're looking into developing a GUI to execute some of our developer tools for some of the designers and artists on our team.
I found a couple on the Ant External website but most of them are used for creating ANT files not simply listing the public targets available.
http://ant.apache.org/external.html
The ANT forms project has some tasks that enable you to generate simple forms that can be used to invoke ANT targets.
Here's an example with three buttons:
<project default="menu">
<property environment="env"/>
<path id="runtime.cp">
<pathelement location="${env.ANTFORM_HOME}/lib/antform.jar"/>
</path>
<target name="menu">
<taskdef name="antmenu" classname="com.sardak.antform.AntMenu" classpathref="runtime.cp"/>
<antmenu image="${env.ANTFORM_HOME}/doc/images/logo-small.jpg" title="My simple form" stylesheet="${env.ANTFORM_HOME}/style.test">
<label>A short label with a few explanatory words concerning the menu at hand.</label>
<button label="Echo 1 target" target="echo1"/>
<button label="Echo 2 target" target="echo2"/>
<button label="Echo 3 target" target="echo3"/>
</antmenu>
</target>
<target name="echo1">
<echo>DO SOMETHING</echo>
</target>
<target name="echo2">
<echo>DO SOMETHING</echo>
</target>
<target name="echo3">
<echo>DO SOMETHING</echo>
</target>
</project>
Usually most of the GUI for Ant or Maven are part of the IDE. I use IntelliJ that has an excellent support for Ant and Maven. Lists all my goals and I easily view any of them.
Antelope is a pretty excellent standalone GUI.
http://antelope.tigris.org/
I always quite liked this project, its implemented with xsl and requires no other dependencies.
http://antprettybuild.sourceforge.net/
Related
I have several Java components all are built by Ant, however I would like to add one more component (written in C++) and compile/build it in Ant as well.
Is there a tutorial which I can follow or a short way to achieve this?
Thanks in advance.
Call make as ant exec task
You can pass env variables to the make
<exec executable="make" dir="${cpp.project.dir}">
<env key="KEY" value="VALUE"/>
</exec>
Ant is ancient, but you still can do this with a lot of pain.
I would recommend to use modern build system Gradle which has C++ support as well. You can find tutorials on their web-site.
It seems like you are not the first trying to accomplish this kind of task:
Building C++ projects with ANT
Axis C++ ANT Build Guide
cpptasks for Apache Ant
Use this:
<?xml version="1.0"?>
<project name="hello" default="compile">
<taskdef resource="cpptasks.tasks"/>
<target name="compile">
<cc outfile="main" objdir="obj" outtype="executable">
<fileset dir="./" includes="*.cpp"/>
<compiler id="Linuxgcc" name="g++">
<compilerarg value="-fPIC"/>
</compiler>
<linker id="LinuxLinker" name="g++" libtool="true">
<linkerarg value="-g" if="debug"/>
<linkerarg value="-fPIC"/>
<libset libs="stdc++"/>
</linker>
</cc>
</target>
</project>
Make sure you place cpptasks.jar(http://www.java2s.com/Code/Jar/c/Downloadcpptasksjar.htm) in your ant's lib folder
I am having some trouble (annoyance really) with ANT editor in Eclipse where it is displaying me a warning "Reference build.classpath not found." on the following block:
<target name="generate" depends="..., mvn-depends">
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
<classpath refid="build.classpath" />
</taskdef>
...
</target>
With mvn-depends target looking like this:
<target name="mvn-depends">
<artifact:dependencies pathId="build.classpath">
<pom refid="my.pom" />
</artifact:dependencies>
</target>
The rest of the references to build.classpath in the build file are not throwing any warnings and the and build runs just fine without any errors, so it does not seem to be amounting to much.
Still, ignoring a warning makes me feel sort of dirty every time I have to edit that file. Specifically, not knowing if this is a bug in Eclipse ant build file validation code or a potential problem in the way the build file has been structured, that Eclipse has identified.
If anyone has any ideas on why this warning is being shown and whether it is safe to ignore or maybe even disable from preferences and would care to share that knowledge, I would definitely be grateful for the knowledge.
Edit:
As requested, here is an example of a reference to build.classpath that does not cause any warnings:
<javac deprecation="off" debug="on" source="1.7" target="1.7" encoding="UTF-8"
includeantruntime="false" memoryMaximumSize="512M" fork="true">
<classpath refid="build.classpath" />
</javac>
As the editor could recognize refids and other elements that Ant specifies, I guess that the editor does something similar to Ant's build file parsing process.
That is, parse this ant build file into a Project object, and references in <taskdef> may be checked, while <javac> may not.
Since the build.classpath is set during runtime and it is set by something other than things like <classpath>, Eclipse may not find it.
I don't have strong prove about this. But something can be done to make us know more.
First, copy the <javac> to the same target where the warned
<taskdef> exists, to see if the <javac> gets a warning;
Then, copy the <taskdef> to the same target where the presetdefed
<javac> exists, to see if the <taskdef> still gets a warning;
Third, in target "generate", comment out the <taskdef> part, and
check if the <xjc ... /> call gets a warning.
For the first one, I expect "NO", while for the other two, I expect "YES". Otherwise, my guess is wrong.
And it makes sense that it is just a warning -- things Eclipse can't find in editing time could exist during runtime.
Make sure you have given the path element location correctly as bellow.
<property name="dependencyfinder.home" value="C:/DependencyFinder"/>
<path id="dependencyfinder">
<pathelement location="${dependencyfinder.home}/lib/aaa.jar"/>
</path>
<taskdef classname="com.sun.tools.xjc.XJCTask">
<classpath refid="dependencyfinder"/>
</taskdef>
Note: DependencyFinder has a folder lib and lib has aaa.jar
Please check the bellow link for more information
Click here
In my ant build, I am using maven-ant-tasks to pull dependencies for my project. The build is relatively complicated and moves/manipulates different artifacts in different places. To make my life easier, I want to remove the maven version labels from my dependencies within my ant script. The maven-ant documentation says that we can use the versionsId property of the dependencies task to accomplish this but I am not sure how to do it in ant.
The relevant part of my build is
<artifact:pom id="mypom" file="pom.xml"/>
<artifact:dependencies pathId="dep.classpath" filesetId="dep.fileset" pomRefId="mypom" useScope="compile" settingsFile="${maven.home}\conf\settings.xml" versionsId="dep.versions"/>
<copy todir="${lib.dir}" flatten="true" overwrite="true">
<fileset refid="${dep.fileset}"/>
</copy>
After this call, the dep.versions variable holds a semi-colon separated list of all the version labels. However, I'm not sure how to remove labels in a nice/clean way.
Thanks
Ok, guys, here's how I solved this
Maven has a custom mapper that is distributed with the maven-ant-tasks that will remove the version labels. You can pass in the versionIds variable from the dependencies tag.
<artifact:pom id="mypom" file="pom.xml"/>
<artifact:dependencies pathId="dep.classpath" filesetId="dep.fileset" pomRefId="mypom" useScope="compile" settingsFile="${maven.home}\conf\settings.xml" versionsId="dep.versions"/>
<copy todir="${lib.dir}" flatten="true" overwrite="true">
<fileset refid="${dep.fileset}"/>
<mapper classname="org.apache.maven.artifact.ant.VersionMapper" from="${dep.versions}" to="flatten" />
</copy>
If you didn't install the maven-ant-tasks in ANT_HOME/lib, you will have to define the classpath on the mapper as well.
I have a ant file that runs JUnits tests. These tests rely on a relative path to certain configuration files. I've tried to set the working directory for the batch test, but fail.
I want the working directory to be ${plugins.dir}/${name}
The JUnit part of the ant script:
<junit haltonfailure="no" printsummary="on" fork="true" showoutput="true" dir="${plugins.dir}/${name}">
<jvmarg value="-Duser.dir=${plugins.dir}/${name}"/>
<classpath>
<path refid="project.classpath"/>
<pathelement location="${plugins.dir}/${dependency}/#dot/"/>
<pathelement location="${plugins.dir}/${name}/" />
</classpath>
<formatter type="xml" />
<sysproperty key="basedir" value="${plugins.dir}/${name}"/>
<sysproperty key="dir" value="${plugins.dir}/${name}"/>
<batchtest todir="${junit.output}">
<fileset dir="${dir}">
<include name="**\*AllTests.class" />
</fileset>
</batchtest>
</junit>
I've googled and searched but the workarounds I've found have been to set the "dir", "sysproperty" or "jvmarg". As you can see I've tried them all :)
Is there a way to print the current dir in the tag? It doesnt support . That would allow me to verify if the dir is actually changed and to what.
One wildcard in this equation is that this is being run in Hudson that starts upp an eclipse process that starts antrunner. This is so we can run both junit and eclipse plugin junit tests. Shouldn't have anything to do with the problem I think.
I think you are right with setting the basedir property (see projects attributes). However, since it is a property of ANT (and not of the JVM) it is READ ONLY!
Does it effect other target if you set the basedir when calling your ant task? See Command Line reference.
ant -Dbasedir=somedir
Alternatively, span a new ant process to call your junit target. See the AntCall task or Ant task. Following examples assumes that the junit target contains your junit task. I used this task for other properties (never needed the basedir property so far.
<antcall target="junit">
<param name="basedir" value="${plugins.dir}/${name}"/>
</antcall>
<ant dir="${plugins.dir}/${name}" target="junit" />
I had the same scenario and in my case I saw that dir="...." is ignored if run in same jvm so I simply added fork='true' and it worked.
Quote from Apache's documentation site "dir - The directory in which to invoke the VM. Ignored if fork is disabled.". More here.
I'm using NetBeans. When I add to Ant properties (from Tools, Options, Java, Ant) work.dir=C:/MyWorkingDir/ it executes ant with the following command and changes the working dir to C:\MyWorkingDir:
ant -f D:\\workspace\\lib\\project -Dfork=true -Djavac.includes=com/myapp/MyTest.java -Dtest.includes=com/myapp/MyTest.java "-Dwork.dir=C:/MyWorkingDir/" test-single
I have the problem that an specific step in Ant can only be executed when we have Java 1.5 installed in the build computer. The task definition uses uses a jar file that was compiled using 1.5, so running with a 1.4 virtual machine will throw an IncompatibleClassVersion exception.
I have to find a solution meanwhile to have this task working for this specific project that requires 1.4, but a question came to me. How can I avoid defining this task and executing this optional step if I don't have a specific java version?
I could use the "if" or "unless" tags on the target tag, but those only check if a property is set or not. I also would like to have a solution that doesn't require extra libraries, but I don't know if the build-in functionality in standard is enough to perform such a task.
The Java version is exposed via the ant.java.version property. Use a condition to set a property and execute the task only if it is true.
<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="default">
<target name="default" depends="javaCheck" if="isJava6">
<echo message="Hello, World!" />
</target>
<target name="javaCheck">
<echo message="ant.java.version=${ant.java.version}" />
<condition property="isJava6">
<equals arg1="${ant.java.version}" arg2="1.6" />
</condition>
</target>
</project>
The property to check in the buildfile is ${ant.java.version}.
You could use the <condition> element to make a task conditional when a property equals a certain value:
<condition property="legal-java">
<matches pattern="1.[56].*" string="${ant.java.version}"/>
</condition>