ant builds running through maven issue - ant

So I'm building a project with maven, and in this maven pom we have a reference to an ant build script. The maven pom triggers this ant build to build a project (an install of alfresco with mysql database and tomcat server packed up with it).
The issue seems to be when you try to set up a database for alfresco to use through the ant build. This is the part of the ant build.
<target name="createDatabase">
<exec spawn="false" executable="${mysql.home}/bin/mysql" failonerror="true">
<arg value="-u" />
<arg value="root" />
<arg value="-e" />
<arg value="source ${alfresco.home}\mysql\db_setup.sql" />
</exec>
</target>
I'm getting 'unknown command '\U' sent back to me as an error on this. Of course you can install the DB manually but I want it as part of this ant script. SOmeone I work with runs this successfully on XP, but I'm getting that error on win7. Any ideas?

Related

RTC checkout using Ant

Is there a way to checkout files from RTC using Ant scripts?. I have a scenario where i need to checkout the files from RTC and build an app using Ant.
It should be possible to invoke scm command through <exec> ant task.
You can see some examples in "Using the SCM Command Line Interface in builds"
<property name="run" value="/path/to/run_and_filter.pl"/>
<property name="scm" value="/path/to/scm"/>
<target name="__scm-checkin">
<!-- Do the initial commit -->
<exec executable="${run}" failonerror="true" outputproperty="cs">
<arg value="${scm} --non-interactive -a n -u y checkin ${roots}"/>
<arg value=" \(([^)]+)\)"/>
</exec>
<!-- Deliver -->
<exec executable="${scm}" failonerror="true">
<arg value="--non-interactive"/>
<arg value="deliver"/>
<arg value="${cs}"/>
</exec>
</target>
Make sure to use scm though, not lscm which starts a damon and can cause the ant task to hang: see "Calling lscm.bat from a build script causes a hang".
RTC does not have a "check-out" operation, which is implicit. It only has a check-in operation. If you want to get code from a repository workspace you can load it using scm command, as described before, or creating a java standalone using Plain API.

Jenkins Phing Plugin - Resource Temporarily Unavailable

I have just started getting Jenkins setup with Phing as the build tool. Although I have used Jenkins before, I'm new to Phing.
I have a project setup in Jenkins that has a Mercurial Repository setup and a Phing Build step.
The build.xml file simply archives the existing file, deletes them and copies the new files from the repository.
I have run phing from the terminal and everything works as planned. However, when running from within Jenkins, I'm getting the following in the Console Output:
[workspace] $ /usr/local/pear/bin/phing -buildfile /Users/Shared/Jenkins/Home/jobs/Project/workspace/build.xml "-Dwebroot=/Volumes/Websites/Project/ -Dcheckoutroot=/Users/Shared/Jenkins/Home/jobs/Project/workspace -Drevision=5" -logger phing.listener.DefaultLogger
/usr/local/pear/bin/phing: fork: Resource temporarily unavailable
Build step 'Invoke Phing targets' marked build as failure
My first thought was that it was permission related, but I've changed Jenkins to run as the same user that I ran Phing manually as and it still got the same issue.
Does anybody have any thoughts as to what might be causing the problem?
I can't find anything related to this error anywhere that isn't related to Cygwin...
The system is running on OS X 10.7.5 with Jenkins 1.518 and Phing 2.5.1
The build.xml file looks like:
<?xml version="1.0" encoding="UTF-8"?>
<project name="Project" default="dist">
<property name="revision" value="old" />
<property name="webroot" value="/Volumes/Websites/${phing.project.name}" />
<property name="checkoutroot" value="./" />
<target name="clean">
<echo msg="Backing up old site to ${phing.project.name}-${revision}..." />
<tar destfile="${webroot}/../${phing.project.name}-${revision}.tar.gz" basedir="${webroot}" compression="gzip" />
<echo msg="Deleting site from ${webroot}..." />
<delete>
<fileset dir="${webroot}" />
</delete>
</target>
<target name="dist" depends="clean">
<echo msg="Copying files to website at ${webroot}..." />
<copy todir="${webroot}">
<fileset dir="${checkoutroot}/Website">
<exclude name="**/.hg/**" />
</fileset>
</copy>
</target>
</project>
I've managed to resolve this issue by removing all of the path details in the Phing configuration section within Jenkins.
This makes absolutely no sense to me as to why it's working without these details as I definitely only have one Phing install, so it's not as if it was picking up the wrong one or something.
However, by not specifying anything in the Phing section of the Jenkins project config so it picks up the default path, default build target etc. and this is working flawlessly now!

ant java jar classpath problem

<target name="results">
<echo message="Calculating QI" />
<java jar="jmt.jar" fork="true" failonerror="true" maxmemory="1024m" classpath="jmt/jmt">
<arg value="-name:KIS"/>
<arg value="-results:CONSOLE"/>
<arg value="../allJavas.jar"/>
</java>
</target>
i want from folder tmp run jar file in folder jmt/jmt. It must be run inside jmt/jmt folder becouse of dependencies files.
i can run it like <java jar="jmt/jmt/jmt.jar" but then dependencies files are not ok. I try to use classpath but not working. What i am doing wrong?
Use the dir="jmt/jmt" attribute to specify the folder to launch the java process in, and use jar="jmt/jmt/jmt.jar" to specify the jar. You probably don't need to classpath attribute at all.
See http://ant.apache.org/manual/Tasks/java.html
The java ant task takes an option parameter dir="jmt/jmt" that will tell the forked VM where to execute.

How to execute the JAXB compiler from ANT

I am using JAXB on a project. the attraction of JAXB is that it is bundled with the JDK, I have been to use xjc.exe on the command line to generate the .java files from a schema. I can't seem to find the JAXB ant task, sure there is a download at http://jaxb.java.net however i want to use the JAXB that is bundled into the JDK is there some way to call JAXB from ant what class does the xjc.exe call on?
<target name="generate-jaxb-code">
<java classname="com.sun.tools.internal.xjc.XJCFacade">
<arg value="-p" />
<arg value="com.example"/>
<arg value="xsd/sample.xsd" />
</java>
</target>
Just went hunting in the tools.jar and found the XJCFacade.class in com.sun.tools.internal tested the above code it works it produces the output as xjc.exe It seems that XJC.exe calls this code com.sun.tools.internal.xjc.XJCFacade
One of my key requirements was that the ant file had work within eclipse without having to include a path name to the JDK that way the file would be portable across operating systems. I am assuming that tools.jar is included on the classpath via the installed JRE preferences options.
Here is a helpful link:
https://jaxb.java.net/nonav/2.0.2/docs/xjcTask.html
Java SE 6 does not ship the Ant task (see 7.1.3):
https://jaxb.java.net/guide/Migrating_JAXB_2_0_applications_to_JavaSE_6.html
Essentially they do the following:
<target name="xjc" description="....">
<exec executable="${jdk.dir}/bin/xjc.exe">
<arg value="-d"/>
<arg value="${src.dir}"/>
<arg value="-p"/>
<arg value="com.mydomain.jaxb"/>
<arg value="${etc.dir}/myschema.xsd"/>
</exec>
</target>

Maven deploy:deploy-file not found due to version/timestamp appended to jar

I'm having a problem using deploy:deploy-file with snapshots I'd like some advice on please.
I have 2 projects; 1) Ant based and 2) the other Maven based that consumes the jars of the other project via Archiva.
I've added a target to the Ant project to deploy snapshots on every successful build during our iteration.
The problem is the Maven project cannot find them because the name of the dependency has a timestamp appended like so:
someJar-1.0-20100407.171211-1.jar
Here is the Ant target:
<exec executable="${maven.bin}" dir="../lib">
<arg value="deploy:deploy-file" />
<arg value="-DgroupId=com.my.package" /><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>
I have a similar Ant target for releases and this works fine.
Other pure Maven projects which deploy snapshosts via mvn deploy work fine.
Does anyone know where I am going wrong?
Thank You
Update
Figured out the answer, see below.
Figured out the answer.
In my Ant target I was deploying the file as you can see. I also then did the same thing but with the -tests jar.
This resulted in 2 snapshots in Archiva, not the usual 1 has you'd expect if you did mvn deploy.
Therefore the non test dependency could not be found because the latest snapshot was the -test jar.
Would be great to know how to solve this problem.
see Deploying non Maven based module src and tests jar to Archiva in a single transaction

Resources