Thursday, February 2, 2012

Maven build on winows and unix


Windows paths differ from that of unix, linux, solaris, aix and sometimes it becomes challange to use one pom.xml for building on two different os.
Here is how one maven script can be used for building applications on windows and unix environments:



<profiles>
    <profile>
        <id>windows</id>
        <activation>
        <os>
            <family>windows</family>
        </os>
        </activation>
        <properties>
            <!-- windows based properties here -->
        </properties>
    </profile>
    <profile>
        <id>non-windows</id>
        <activation>
        <os>
            <family>!windows</family>
        </os>
        </activation>
        <properties>
            <!-- unix based properties here -->
        </properties>
    </profile>
</profiles>

Date Time for Maven Builds

Print/View Datetime stamp in Maven
Since Maven 2.1 M1 version, here is how you can get the datetime stamp while using maven build scripts:
Define a property named "maven.build.timestamp.format" with some legitimate value i.e. "yyyyMMdd.HHmm" and property named "maven.build.timestamp" will be available to use.

Example here:



<properties>
<maven.build.timestamp.format>yyyyMMdd.HHmm</maven.build.timestamp.format>
<CurrentDateTime>${maven.build.timestamp}</CurrentDateTime>
</properties>