Showing posts with label Ant. Show all posts
Showing posts with label Ant. Show all posts

Tuesday, February 8, 2011

Ant OS specific value

<condition property="os.dep.value" value="value for MacOSX">
  <os family="mac" />
</condition>

<condition property="os.dep.value" value="value for Windows">
  <os family="windows" />
</condition>

<condition property="os.dep.value" value="value for Unix" >
  <os family="unix" />
</condition>

Use as "${os.dep.value}"

Creadit: Can I make the Ant copy task OS-specific? - Stack Overflow, How to make a conditional decision in an Ant build script based on operating system | java ant | devdaily.com

Wednesday, February 2, 2011

Generate current Git version in Ant for Hudson

At the time I wrote this blog there is no Git Ant task. Workaround for getting current commit version is to use exec directly invoke git describe as below.
<exec executable="git" outputproperty="build.commit">
    <arg value="describe"/>
    <arg value="--tags"/>
    <arg value="--abbrev=20"/>
</exec>

Now you can get result value of git describe from ${build.commit}.
Credit: How to lookup the latest git commit hash from an ant build script - Stack Overflow

But there is also some problems with Hudson's git plug-in which it always tags build revision that causes our git describe return the wrong result. There was someone send patch to fix this but this is not build to the plug-in yet. Currently workaround is provided in that patch page, add paramter to git describe, "--match=[^(hudson)]*", to ignore tag from Hudson. So we have to add more arg line to Ant's exec task:
<arg value="--match=[^(hudson)]*">

That's all.

Monday, November 1, 2010

[Java] Jars inside Jar

Jar that contains multiple jars inside is not support directly by Java. There are some workarounds on this.
  • Put jars in to jar as ordinary files then load them with your own customized classloader. There is a tool such as One-JAR™ but some people told that it causes performance problem (I have not try this).
  • Extract jars to .class and pack them together to a single jar. You can archive this easily with Ant's Zip Task
For me, I choose the second approach. There are more workarounds in reference links below.

Java: Easiest way to merge a release into one jar-file
Is it possible to package all the jar dependencies in one big jar ?

Collectd PostgreSQL Plugin

I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresq...