Ant fails with liquibase path - ant

I am trying to get phing to work nice with liquibase. But pPing gives this illustrous error (which I honestly can't find online)
Execution of target "update-database" failed for the following reason: PathElement (unknown) doesn't support the 'location' attribute.
BUILD FAILED
PathElement (unknown) doesn't support the 'location' attribute.
Total time: 0.1206 seconds
the specific commands for that are:
<path id="liquibasepath">
<pathelement location="${basedir}/install/lib/liquibase.jar" />
<pathelement location="${basedir}/install/lib/jdbc-mysql.jar" />
</path>
I tried searching online but there is no good documentation for using phing with liquibase. and the error's neither turn up decent results.

Try using the "path" attribute in pathelement instead of location

The correct answer should be: This is ant, not phing. I was trying to run it with the wrong program. (there really should be some indication of this in build files ;)).
The person who commented got me on hte right track, can't accept that as an answer tho.

Related

Process leaked file descriptors jenkins ERROR on Jenkins

Can someone help me to solve an issue "process leaked file descriptors jenkins"?
I tried whit BUIL_ID = dontkillme but it doesnt work.
Thx
It would help to know more about what you're trying to run but this question came up as a result of troubleshooting an issue I was having so here's how I resolved it. I am using Windows so if you're using something else it may not work for you.
First of all you need to read and understand the Jenkins documentation on the issue: https://jenkins.io/redirect/troubleshooting/process-leaked-file-descriptors
I had to install Ant first since it was not installed.
https://ant.apache.org/bindownload.cgi
The Jenkins documentation gives you an example Ant script:
<exec executable="cscript.exe">
<env key="ANTRUN_TITLE" value="Title for Window" /> <!-- optional -->
<env key="ANTRUN_OUTPUT" value="output.log" /> <!-- optional -->
<arg value="//NoLogo" />
<arg value="antRunAsync.js" /> <!-- this script -->
<arg value="real executable" />
</exec>
You will change the "real executable" to be the executable you are wanting to run.
See that .js file in the 2nd arg value? You will need to create that. There's a link to this on the Jenkins documentation page too. Grab it here: https://wiki.jenkins.io/download/attachments/1835010/antRunAsync.js?version=1&modificationDate=1184046328000&api=v2
I didn't make any edits to the contents, just pasted it right in and saved it as antRunAsync.js
So now you take your Ant example script I posted above and throw that in a text editor, save as build.xml
From this point you should be able to test on the command line by typing ant and pressing enter. Your application should load in a different window.
If you haven't set up Ant in the Jenkins Global Tool Configuration do so now and point it to your Ant install (might have to uncheck the Install checkbox). In the Jenkins project add a build step Invoke Ant. Set that up how you like according to Ant documentation.
Hope this answer helps someone else who has stumbled across this problem and this question.

MobileFirst Platform native iOS app building have error while building .wlapp

I am working on MobileFirst Platform version7 using ant script to build the project .war, .wlapp, .adapter.
Everything was working fine while our project was a hybrid one. Now the project is migrated to native-iOS in.
I am using following code to build .wlapp.
<target name="build-wlapp">
<app-builder worklightServerHost="localhost:10080"
applicationFolder="//Users/admin/Documents/workspace/NewProj/apps/Try"
environments="iOSnative"
nativeProjectPrefix="NewProj"
outputFolder="/Users/admin/Documents/workspace/NewProj/bin"/>
it is throwing below error:
build.xml:66: Failed building application: The build could not be
completed due to invalid application-descriptor.xml.(cvc-elt.1: Cannot
find the declaration of element 'nativeIOSApp'.)
I am not getting where the flaw is...
Assuming the application-descriptor.xml you posted in your comment is complete, it looks like you have a stray semicolon after your xmlns declaration. That's not valid XML. Not sure how it got like that (check your source control system?), but you probably need to remove/revert it.
Sorry For the Wrong answer first.
You were using the wrong code to generate the .wlapp file the ant script is below.
<project default="change">
<target name="change">
<taskdef resource="com/worklight/ant/defaults.properties">
<classpath>
<pathelement location="worklight-ant-builder.jar"/>
</classpath>
</taskdef>
<native-app-builder
sourceFolder="C:\Workspace\Test\apps\Test" DestinationFolder="bin"
worklightServerHost="http://111.111.111.111:10080">
</native-app-builder>
</target>
</project>

ant copy task hanging when the source file is missing

In one of our build script, we have following simple copy task added ->
<copy todir="${targetdir}"
file="${sourcedir}/modules/glassfish.jaxb.xjc_1.0.0.0_2-1-12.jar"/>
This copy task started hanging when the glassfish jar name got changed (version upgrade which are not in our control) at the source location. I was expecting it to error out causing the build failure in that case. Actually at first I was not able to figure out at what particular step build was hanging. Then when I added "-debug" to the ant command and I realized its successfully completing a step prior to this copy task and still there was no trace of copy command that is hung. When I updated the new jar name, it worked fine and build was successful which proved that the copy task is hanging because of filename got changed. To make it easy to debug next time, I added an echo statement like below just prior to that copy task ->
<echo message="Copying glassfish jar to ${targetdir}.."/>
But I am still confused as to why it didn't give error with build failure? I am using Apache Ant version 1.7.1. Could this be a bug? How else I can avoid this situation in future with just the copy task (without using * in the jar name)? TIA
That worked for me. Well, didn't work for me. I got the error message. I am using Ant 1.8 and Ant 1.9.2. I didn't try it with Ant 1.7, but I doubt it's a bug.
Try to use the -v parameter in Ant:
$ ant -v target
And be prepared for a longwinded output. This will give you information what's going on with Ant, and may explain why it's freezing. There's a few things you could do: Use a fileset to specify the file.
<copy todir="${targetdir}">
<fileset dir="${sourcedir}/modules">
<include name="glassfish*.jar"/> <!-- Will catch any glassfish.jar -->
</fileset>
</copy>
Of course, if the file doesn't exist, you won't get an error or even a warning. However, a <fail/> before will detect the issue:
<fail message="missing file ${sourcedir}/modules/glassfish.jaxb.xjc_1.0.0.0_2-1-12.jar">
<condition>
<not>
<available
file="${sourcedir}/modules/glassfish.jaxb.xjc_1.0.0.0_2-1-12.jar"
type="file"/>
</not>
</condition>
</fail>
To force the build to quit, an alternative way
<available file="${sourcedir}/modules/glassfish.jaxb.xjc_1.0.0.0_2-1-12.jar"
property="glassfish.jaxb.xjc.jar.present"/>
<fail message="you message" unless="glassfish.jaxb.xjc.jar.present"/>
just a few lines less :)
If you want to dig into it, try this:
write a simple build file, which contains only one target with copy, and put it to the same place of your main build file.
<target name="test-copy">
<!-- here use an old (wrong) file name -->
<copy todir="${targetdir}"
file="${sourcedir}/modules/glassfish.jaxb.xjc_1.0.0.0_2-1-12.jar"/>
</target>
run it, check if it fails or hangs.
If this simple build file works, it's very possible that something else in your main build file is causing the bug.

ant-contrib installation failure on linux

I would like to use 'ant-contrib', but I could not use it. I tried to use 3 way, without success.
Apache Ant(TM) version 1.8.2
echo $ANT_HOME
/usr/share/ant
./usr/share/ant/lib/ant-contrib-1.0b2.jar
./usr/share/java/ant/ant-contrib-1.0b2.jar
./usr/share/java/ant.jar
*1.*
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
RESULT:
Buildfile: /home/username/build.xml
[taskdef] Could not load definitions from resource net/sf/antcontrib
/antcontrib.properties. It could not be found.
*2.*
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
RESULT:
Buildfile: /home/username/build.xml
[taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xml. It could not be found.
*3.* build.xml in my home, and ant-contrib in home/lib
<classpath id="contrib.classpath.ref">
<fileset dir="${basedir}/lib"/>
</classpath>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="contrib.classpath.ref"/>
RESULT:
Buildfile: /home/username/build.xml:2: Problem: failed to create task or type classpath
Cause: The name is undefined.
Action: Check the spelling.
I dont know other solution where I can iterate through a fileset/custom list doing something on them one by one. Thats why its important me.
Honestly, why there is no clear documentation ?
The problem was that YAN mentioned above. I have more ant in my system.
All in all, I removed them, a tried again my build xml with a brand new downloaded ant.
What is not on the PATH, and started from directory where it is.
I know this is not the best settings, but I could try it what I want, and solving the right setting is just question of time.
Thanks guys above your time and effort.

Passing "-J-Duser.language" into javac through ant to ensure compilation errors are reported in the correct language

My PC is currently set up as Japanese for testing purposes. If my java project has a compilation error the message is reported in Japanese.
e.g.
Compiling 1 source file to [...directory...]
[...class...].java:172: シンボルを見つけられません。
I would prefer to see the errors in english.
Without using ant the fix for this is to use
javac -J-Duser.language=en [..java files...]
which makes javac give english error messages (the -J tells javac to pass the rest of the argument to java)
My question is: how do I pass this to ant
[editted to remove options I tried that didn't work]
Try adding a <compilerarg> to your <javac> call. For example:
<javac srcdir="${src.dir}" destdir="${classes.dir}" fork="true">
<compilerarg value="-J-Duser.language=en"/>
<compilerarg value="-J-Duser.country=GB"/>
</javac>
EDIT Fixed the arg values. Also, this only works if the compiler is forked; I updated the example to reflect that.

Resources