Showing posts with label Apache. Show all posts
Showing posts with label Apache. Show all posts

Tuesday 9 February 2016

How to setup Apache Ant on Mac OS X

Folks, presenting a quick tutorial on how to setup the build tool Apache Ant on a Mac OS X machine.

Download the relevant ant archive version from Apache Ant homepage. For this example we download the latest v1.9.6.
Store it locally at any location you like; maybe like /Users/Username/apache-ant-1.9.6

Now lets edit the .bash_profile to define the ANT_HOME environment variable.

sudo vim ~/.bash_profile

Add the following lines to it (make sure to replace with your own username in the path):

export ANT_HOME=/Users/IroncladZone/apache-ant-1.9.6/
export PATH=$PATH:$ANT_HOME/bin

Now source ~/.bash_profile and restart terminal.

Check the above settings by looking up the ant version in terminal :

ant -v
Apache Ant(TM) version 1.9.6 compiled on June 29 2015
Trying the default build file: build.xml
Buildfile: build.xml does not exist!
Build failed

This means your ant is ready to use for builds. Going forward all you have to do is pass the build.xml to trigger the build.

Folks, watch out for this space for more basic to intermediate to advanced tutorials coming up soon.

Friday 5 February 2016

Maven - Install vs Deploy

In Maven, the difference between mvn install and mvn deploy is the following :

  • mvn install is used to install the artifact/dependency on your local repository.


  • mvn deploy is used to upload/install the artifact/dependency on the remote repository like nexus or artifactory.

Check this link for detailed reference.

Also let me refresh your memory about repositories. As you may be aware, your local repository is usually a local cache of the remote repository and may also contain unreleased artifacts.

Tuesday 2 February 2016

Maven - Offline Build

In order to execute a Maven build in offline mode, run the following command :

mvn -o install  OR  mvn --offline install.

In offline mode, Maven will not connect to the remote repository to check for the artifacts/dependencies. It will just check for the artifacts currently present in your local repository.

Saturday 26 April 2014

Invoke Ant build from Maven

The jar created by the Ant build can be then attached to the project using the Build Helper Maven plugin.

Consider the following example snippet of the pom.xml

<plugins>
   <plugin>
        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-antrun-plugin</artifactId>
         <version>1.7</version>
            <executions>
              <execution>
                <tasks>
                      Place any Ant task here
                </tasks>
             </execution>
           <executions>
   </plugin>
 </plugins>

If required, you can then attach the jar created by the Ant build to this Maven project using another plugin named "build-helper-maven-plugin".

This plugin has various goals like build-helper:add-resource and build-helper:attach-artifact

Friday 10 January 2014

Taskdef in Apache Ant

The 'taskdef' attribute can be used to add a task definition which would then be used in the existing project.

The taskdef tag is an important step you need to know, before I compose a post about automating deployments to tomcat.

It's syntax is similar to the typedef attribute.

Eg:

<taskdef name="start-tomcat" classname="org.apache.catalina.ant.StartTask" />

Observe how we set the classname attribute above.

Official information about Taskdef can be read here.

Tuesday 7 January 2014

Accept user input in Apache Ant

In Apache Ant, you can use the Input task in build.xml to accept user input. Check out the following illustration.

Eg:


As you see in the Input task, we specify the message that should get displayed asking for user input. 
The user input is then stored in a property named "my-name" in this case.
The valid arguments i.e the valid options are mentioned in the validargs parameter.

A detailed technote can be read here.

Friday 3 January 2014

Tstamp task in Ant

The Tstamp task in Apache Ant is used to set the DSTAMP, TSTAMP and TODAY properties. These properties can then be used in the build file, to generate filenames having the timestamps as strings.

Eg:

<tstamp>
        <format property = "current-date" pattern = "d-MMMM-yyyy" locale="en" />
        <format property = "current-time" pattern = "hh:mm:ss" locale="en />
</tstamp>

Note the nested element format which is used to set properties to a current time or date.

You could also add a prefix to these properties as follows:

Eg:

<tstamp prefix = "info">
</tstamp>

This will prefix the properties with the world info info. i.e. info.DSTAMP, info.TSTAMP, info.TODAY

Official detailed technote can be found here.

Thursday 26 December 2013

Increase memory used by JVM for Ant builds

Sometimes for builds using Apache Ant, we come across the Out of Memory error. In order to increase the memory used by JVM for the build, do the following:

Set ANT_OPTS=-Xms256m -Xmx1024m -XX:MaxPermSize=120m

Monday 23 December 2013

Pass arguments to build file - Apache Ant

In Apache Ant, we can pass arguments to the build file using the switch -D. We can define a value for a property from the command line using -Dname=value

Eg:

ant build.xml -Dx=5

Sunday 22 December 2013

Ant - read from build.properties

While performing builds using Ant, you must be aware about the build.xml file. The build.xml can read the parameter values from the build.properties file, which usually is one level up.

You have to define a property which mentions the properties file from which the script would read the values.

<property file = "build.properties" />
Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker