I have some RAML files sitting in a folder, and I'm setting up an ANT script to "build" them into HTML documentation using the raml2html package featured on the raml.org site.
I'm new to ANT, so I'm probably not making the most efficient use of it, but that is of secondary concern. I use two targets to accomplish this goal, and they look like this (I've ommitted clean and init):
<!-- Look for the RAML, send them one at a time to post-build -->
<target name="build" depends="clean, init">
<echo message="searching for raml source in ${src}"/>
<foreach param="file" target="post-build">
<fileset dir="${src}">
<include name="**/*.raml"/>
</fileset>
</foreach>
</target>
<!-- Run raml2html on each of them, saving output in build/ -->
<target name="post-build" depends="">
<echo>file: ${file}</echo>
<substring text="${file}" parent-dir="${src}/" property="filename" />
<echo>filename: ${filename}</echo>
<echo>build-to: ${build}/${filename}</echo>
<exec executable="raml2html" failonerror="true">
<arg value="-i ${file}" />
<arg value="-o ${build}/${filename}" />
</exec>
</target>
When I run the ANT script: $ant build, those two targets return this:
build:
[echo] searching for raml source in /home/ryan/workspace/RAMLValidator/src
[foreach] The nested fileset element is deprectated, use a nested path instead
post-build:
[echo] file: /home/ryan/workspace/RAMLValidator/src/sample.raml
[echo] filename: sample.html
[echo] build-to: /home/ryan/workspace/RAMLValidator/build/sample.html
[exec] 2.0.2
It appears as though the arguments I supplied to the <exec> translated into raml2html's -V option somewhere along the way, as its version is 2.0.2 when I run $raml2html -V from the terminal.
When I run this same command explicitly from the terminal: $raml2html -i src/sample.raml -o build/sample.html, it generates the HTML exactly as expected... How did I mess this up?
The problem is that ANT treats the option flag and the flag's argument as separate entities, each needing their own <arg /> tag in order to function properly.
Modifying the exec task in the "post-build" target like so fixed the problem:
<exec executable="raml2html" failonerror="true">
<arg value="-o" />
<arg value="${build}/${filename}"/>
<arg value="${file}" />
</exec>
Hopefully that saves someone a fraction of the time it cost me!
Related
I am running a SoapUI project using Ant to get a JUnit report.
Here is my build.xml:
<project basedir="." default="testreport" name="APIAutomation">
<target name="SoapUI">
<exec dir="." executable="C:\Program Files (x86)\SmartBear\SoapUI-5.0.0\bin\testrunner.bat">
<arg line="-r -j -a -f 'C:\Users\F3020722\Desktop\Notification\New folder' -sFirstLoginTest 'C:\Users\F3020722\Desktop\Notification\New folder\APIRegression.xml'"></arg>
</exec>
</target>
<target name="testreport" depends="SoapUI">
<junitreport todir="C:\Users\F3020722\Desktop\Notification\New folder\API">
<fileset dir="C:\Users\F3020722\Desktop\Notification\New folder\API">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames"
todir="C:\Users\F3020722\Desktop\Notification\New folder\reports\html">
</report>
</junitreport>
</target>
</project>
I am getting an XML report properly. However, the JUnit report is empty. all contains 0 and successrate is Nan.
Can anyone check the build.xml is correct?
Looks build script seems ok
Avoid spaces in the directory names
Use forward slashes like unix style even on windows
Use property file or properties in build script so that other members do not have it edit the build scripts as paths might change machine to machine.
For now, added properties in the below script, you may externalize to a property file too.
build.xml
<project basedir="." default="testreport" name="APIAutomation">
<property name="test.suite" value="FirstLoginTest"/>
<property name="soapui.project" value="C:/Users/F3020722/Desktop/Notification/New folder/APIRegression.xml"/>
<property name="soapui.home" value="C:/Program Files (x86)/SmartBear/SoapUI-5.0.0"/>
<property name="results.dir" value="C:/Users/F3020722/Desktop/Notification/API/Results"/>
<property name="reports.dir" value="${results.dir}/Reports"/>
<property name="html.dir" value="${reports.dir}/html"/>
<target name="execute.project">
<exec dir="${soapui.home}/bin" executable="testrunner.bat">
<arg line="-raj -f ${results.dir} -s ${test.suite} ${soapui.project}" />
</exec>
</target>
<target name="testreport" depends="execute.project">
<mkdir dir="${reports.dir}"/>
<junitreport todir="${reports.dir}">
<fileset dir="${results.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${html.dir}" />
</junitreport>
</target>
</project>
You can also find a docker image for soapui and run tests & generate junit style html report as well. Refer soapui repository # hub.docker.com
Note: that build script used docker images is exactly the same as above except the machine path.
I'm attempting to use ANT to compile and package up an iOS IPA file using the Adobe SDK tools. I need to use ANT, because the build requires a tonne of RAM, and Flash Builder gets Java heap space issues when I compile (even though I've increased the max ram in the ini file).
This is what the core of my ANT build looks like:
<!-- Build the SWF and save it in the publish directory -->
<target name="3. Compile SWF" depends="2. Build New Directories">
<mxmlc
file="${MAIN_CLASS}"
output="${OUTPUT_SWF}"
debug="${DEBUG_FLAG}"
failonerror="true">
<load-config filename="${MOBI_CONFIG_FILE}"/>
<define name="MOBI_PROJECT::IS_iOS_BUILD" value="${IS_iOS_BUILD}" />
<define name="MOBI_PROJECT::DEBUG" value="${DEBUG_FLAG}" />
<source-path path-element="${MOBI_DIR}/src"/>
<library-path file="${FLEX_HOME}/frameworks/locale/en_US" append="true"/>
<library-path dir="${MOBI_LIB_RELEASE_DIR}" includes="*.swc" append="true"/>
<compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs/*" />
</compiler.library-path>
<compiler.external-library-path dir="${FLEX_HOME}/frameworks/libs/air">
<include name="**/*.swc" />
</compiler.external-library-path>
<compiler.external-library-path dir="${FLEX_HOME}/frameworks/libs">
<include name="**/*.swc" />
</compiler.external-library-path>
<compiler.external-library-path dir="${FLEX_HOME}/frameworks/libs/mx">
<include name="**/*.swc" />
</compiler.external-library-path>
</mxmlc>
</target>
<!-- Package the application to an ipa file & save it in the publish directory -->
<target name="4. Package Application" depends="3. Compile SWF">
<java jar="${ADT}" fork="true" failonerror="true">
<arg value="-package"/>
<arg value="-target"/>
<arg value="ipa-test"/>
<arg value="-provisioning-profile"/>
<arg value="${iOS_PROVISIONING}"/>
<arg value="-storetype"/>
<arg value="pkcs12"/>
<arg value="-keystore"/>
<arg value="${iOS_KEYSTORE}"/>
<arg value="-storepass"/>
<arg value="${iOS_PASS}"/>
<arg value="${IPA_FILE}"/>
<arg value="${APP_DESCRIPTOR}"/>
<arg value="${OUTPUT_SWF}"/>
</java>
</target>
I'm using Flex 4.6 SDK with Air 3.4 beta SDK and using airmobile-config.xml from the SDK as my config file.
But when I run this I get the following error:
4. Package Application:
[java] Exception in thread "main" java.lang.Error: Unable to find named traits: mx.core::SoundAsset
[java] at adobe.abc.Domain.resolveTypeName(Domain.java:232)
[java] at adobe.abc.Domain.resolveTypeName(Domain.java:149)
[java] at adobe.abc.GlobalOptimizer$InputAbc.resolveTypeName(GlobalOptimizer.java:272)
[java] at adobe.abc.GlobalOptimizer$InputAbc.readInstance(GlobalOptimizer.java:1000)
[java] at adobe.abc.GlobalOptimizer$InputAbc.readAbc(GlobalOptimizer.java:390)
[java] at adobe.abc.GlobalOptimizer$InputAbc.readAbc(GlobalOptimizer.java:278)
[java] at adobe.abc.LLVMEmitter.generateBitcode(LLVMEmitter.java:320)
[java] at com.adobe.air.ipa.AOTCompiler.convertAbcToLlvmBitcodeImpl(AOTCompiler.java:516)
[java] at com.adobe.air.ipa.BitcodeGenerator.main(BitcodeGenerator.java:80)
[java] Compilation failed while executing : ADT
If I remove all my [Embed] tags of audio, then the error is still there, but it complains about 'mx.core::ByteArrayAsset'. If I remove every single [Embed] tag in the project, then it compiles ok.
I've tried to force the SoundAsset class to be embedded by putting this line in my code:
import mx.core.SoundAsset;
...
new SoundAsset();
I've even gone into the Flex SDK and copied out the SoundAsset and ByteArrayAsset classes and put them in my project, but none of these things help.
Can anyone please tell me how to compile an IPA file via ANT while still keeping my [Embed] tags?
I've fixed the problem!
I think the problem was in the way I was linking to the libraries. I ended up deleting all my hand made ANT settings and instead exporting the settings from my Flash Builder project, and just using those.
Full details in this article here, it saved my life:
http://helpx.adobe.com/x-productkb/multi/compilation-results-flex-builder-flex.html
I need to start and stop mysql 5.5 using ant task.
The earlier ANT script was doing it for hsqldb database for which the class it was using was org.hsqldb.Server. Could someone tell me which class to use for mysql 5.5.
Following was being use in case of hsqldb for mydb:
<java fork="true" spawn="true" classname="org.hsqldb.Server" classpathref="build.runtime.classpath">
<arg line="-database.0 file:data/mydb -dbname.0 mydb"/>
</java>
I need to have the eqivalant for mysql 5.5. I know a connector is used to connect to mysql 5.5 database, I use mysql-connector-java-5.1.15-bin.jar.
Could someone just tell me how to start and stop mysql database using an ant script.
Thanks.
It would be more normal to configure MySQL to automatically start when the machine boots. MySQL is designed to run continually in the background.
If you really want to stop and start MySQL from within ANT it's possible to invoke the server scripts (Assuming of course MySQL is running on the same machine as the build).
<target name="start-db">
<exec executable="C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" osfamily="windows">
</exec>
<exec executable="mysql.server" osfamily="unix">
<arg value="start"/>
</exec>
</target>
<target name="stop-db">
<exec executable="C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" osfamily="windows">
<arg value="-u"/>
<arg value="root"/>
<arg value="shutdown"/>
</exec>
<exec executable="mysql.server" osfamily="unix">
<arg value="stop"/>
</exec>
</target>
Note:
This script contains commands to start/stop on both windows and unix.
The MySQL documentation describes how to start Mysql from the windows command line
I am trying to use javac to compile a set of java files to .class files and then subsequently use iajc to compile and weave all the aspects. My ant build.xml looks like this.
The compile part:
<target name="compile" depends="init" description="compile the source ">
<!-- Compile the java code from ${src} into ${target} -->
<javac srcdir="${src}" destdir="${target}" debug="true">
<classpath refid="project.class.path" />
</javac>
</target>
The iajc part:
<target name="aspects">
<mkdir dir="dist"/>
<iajc source="1.6" target="${asptarget}">
<inpath>
<pathelement location="${target}"/>
</inpath>
<sourceroots>
<fileset dir="${src}">
<include name="**/*.aj"/>
</fileset>
</sourceroots>
<classpath>
<pathelement location="${aspectj.home}/lib/aspectjrt.jar"/>
</classpath>
</iajc>
</target>
Judging by the error message, I am not getting this correct. The sourceroots are wrong!
How can I compile just the .aj files with aspectj and then binary weave the class files and compiled .aj files? Is that possible without recompiling all the original java sources too?
If you want to use the regular compiler for building .java files and iajc to build .aj files you do this:
<target name="aspects" depends="compile" description="build binary aspects">
<fileset id="ajFileSet" dir="${src}" includes="**/*.aj"/>
<pathconvert pathsep="${line.separator}" property="ajFiles" refid="ajFileSet"/>
<echo file="${src}/aj-files.txt">${ajFiles}</echo>
<iajc source="1.6" target="${asptarget}">
<argfiles>
<pathelement location="${src}/aj-files.txt"/>
</argfiles>
<classpath>
<pathelement path="${target}"/>
<fileset dir="lib" includes="**/*.jar"/>
</classpath>
<classpath>
<pathelement location="${aspectj.home}/lib/aspectjrt.jar"/>
</classpath>
</iajc>
</target>
Works perfectly by building a file containing a list of the .aj files and compiling them. You can then use runtime OR binary weaving to finish the process.
I'm learning Java and Eclipse on a Mac. I have an Ant build file in a project that contains sql statements to create a MySql database and tables and insert rows to set up data for the project. I have MySql set up correctly and can use the "mysql" command in terminal with no problem, but when I run the Ant build.xml file in Eclipse, I get: "BUILD FAILED. Cannot run program "mysql": error=2, No such file or directory"
I have done the following without success:
Added /usr/local/mysql/bin to my path and verified with "echo $PATH".
Added /usr/local/mysql/bin to my classpath in Eclipse through "properties" on the project.
Added build.xml to the build path in Eclipse (just for grins.)
I am running:
Mac OS X 10.7.1
Eclipse Indigo Build id: 20110615-0604
MySql 5.5.15-osx10.6-x86_64
Thanks for your help!
Here is my build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="publisher" default="all" basedir=".">
<property name="mysql.params" value="-u publisher -ppublisher -D publisher" />
<target name="all" depends="cleandb, createdb, insertdb"></target>
<target name="cleandb">
<exec executable="mysql" input="cleandb.sql">
<arg line="${mysql.params}" />
</exec>
</target>
<target name="createdb">
<exec executable="mysql" input="createdb.sql">
<arg line="${mysql.params}" />
</exec>
</target>
<target name="insertdb">
<exec executable="mysql" input="insertdb.sql">
<arg line="${mysql.params}" />
</exec>
</target>
</project>
Does it work when you run the Ant build from the command line? If so, its probably the same problem described here:
Running ant through eclipse it doesn't find environment variables, but running ant through terminal is fine
Any reason not to just be using Ant's SQL task and Connector/J?
In any case, it sounds like you just haven't made sure that that /usr/local/mysql/bin is available on the PATH used when executing the Ant build. There's an Environment tab in the Ant build configuration that should allow you to modify the path for the environment Eclipse will run your Ant build file in.
There's a couple of things I would try:
Set the searchpath attribute to true (it is false by default):
<target name="cleandb">
<exec executable="mysql" input="cleandb.sql" searchpath="true">
<arg line="${mysql.params}" />
</exec>
</target>
Use a nested env element to set the path.
<property environment="env"/>
<exec ... >
<env key="PATH" path="${env.PATH}"/>
</exec>