Where do I put my credentials when using Ivy and a private company repository?

Use a settings file with properties controlling the Nexus credentials: <ivysettings> <property name=”repo.host” value=”default.mycompany.com” override=”false”/> <property name=”repo.realm” value=”Sonatype Nexus Repository Manager” override=”false”/> <property name=”repo.user” value=”deployment” override=”false”/> <property name=”repo.pass” value=”deployment123″ override=”false”/> <credentials host=”${repo.host}” realm=”${repo.realm}” username=”${repo.user}” passwd=”${repo.pass}”/> .. .. </ivysettings> When you run the build you can then specify the true username and password: ant -Drepo.user=mark -Drepo.pass=s3Cret … Read more

Running ant build gives “package org.junit does not exist”

You should add your junit.jar into the classpath definition in your ant file. There are many way to do it, one example is: <junit printsummary=”yes” haltonfailure=”yes”> <classpath> <path refid=”your.classpath.refid” /> <fileset dir=”${junit.dir}”> <include name=”**/junit.jar” /> </fileset> </classpath> … </junit> See Ant Manual for details on setting up your classpath.

How to pull out a substring in Ant

I use scriptdef to create a javascript tag to substring, for exemple: <project> <scriptdef name=”substring” language=”javascript”> <attribute name=”text” /> <attribute name=”start” /> <attribute name=”end” /> <attribute name=”property” /> <![CDATA[ var text = attributes.get(“text”); var start = attributes.get(“start”); var end = attributes.get(“end”) || text.length(); project.setProperty(attributes.get(“property”), text.substring(start, end)); ]]> </scriptdef> …….. <target …> <substring text=”asdfasdfasdf” start=”2″ end=”10″ … Read more

Multiple Android Application Package .apk files from single source code

I’m generating 2 different APK’s (demo and production) from one single source tree with 3 small modifications: 1) I have public static final DEMO=true; //false; in my Application class and depending on that value I used to switch code between demo/production features 2) There are 2 main activities, like: package mypackage; public class MyProduction extends … Read more

How to lookup the latest git commit hash from an ant build script

I wrote the following ant target for a project on github. Usage: stores version in property “repository.version” works if no git is installed or no .git directory is present (fallback) other targets must depend on this target if they need the git version only one git command gets executed (–always) <available file=”.git” type=”dir” property=”git.present”/> <target … Read more

SASS implementation for Java? [closed]

With ANT: Download JRuby complete jar file (JRuby Complete jar download page) Download the latest HAML/SASS code (HAML/SASS tarball), and extract it. Put it in “/libs/sass-[VERSION]” Add the following to an ant build file. Replace [VERSION] in the script to the corresponding versions of JRuby and SASS Run the ant script, and the sass or … Read more

Linux removing folders older than 1 year and more than 3 files

ANT selectors enable you to customize the fileset to delete. Try the following: <target name=”purge”> <tstamp> <format property=”touch.time” pattern=”MM/dd/yyyy hh:mm aa” offset=”-300″ unit=”day”/> </tstamp> <delete> <fileset dir=”${src.dir}”> <date datetime=”${touch.time}” when=”before”/> <scriptselector language=”javascript”><![CDATA[ if (file.getParentFile().list().length > 3) { self.setSelected(true); } else { self.setSelected(false); } ]]> </scriptselector> </fileset> </delete> </target>

CreateProcess error=206, The filename or extension is too long

I had the same problem. I used <fileset dir=”${basedir}/build”> <include name=”**/*.class”/> </fileset> inside findbugs target and it seems that there is too much .class files to be passed to findbug (?via command line?) because when I used <fileset dir=”${basedir}/build/com/domain/package”> <include name=”**/*.class”/> </fileset> that had low number of classes, the error was gone. So, I solved … Read more