Date Created: Fri 21-Jan-2011


    After successfully installing Hudson here is our first discovery of how to use Maven, so we can start using Maven with Hudson to produce an automated build/package/deploy pipeline.

    Steps to test maven in Windows 7...

    Download JDK6 Update 20, ANT and Maven and install in c:\

    Set the windows system path to include both Maven and ANT for future use via command line



    Set system Path




    Add:

    C:\apache-ant-1.8.0\bin;C:\apache-maven-2.2.1\bin

    i then launched a CMD prompt and go thtis error

    C:\Program Files\VMware\VMware vSphere CLI>ant -version
    Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li
    b\tools.jar
    Apache Ant version 1.8.0 compiled on February 1 2010




    The reason is that I have JAVA_HOME set to JRE, it needs to be set to JDK



    Open a new CMD prompt and type set to verify JAVA_HOME is set to jdk



    Now ANT works

    ant -version



    Lets's try Maven



    mvn --version

    OK Now lets got to c:\temp\mavenexample and try our

    The mvn command invokes the Maven 2 system, in this case a request to run the archetype plugin with the create command. The -D commands are simply setting Java system properties, thereby passing configuration information to Maven 2. Per the Maven 2 FAQ, the groupID should follow the package name (reversed DNS of your website), and can contain subgroups as appropriate. For example, I have used com.veinteractive.test

    Create a shortcut like this to create command prompt icon to go straight to our example






    Open command window:

    C:\temp\mavenexample\mvn archetype:create -DgroupId=com.veinteractive.com -DartifactId=my_webapp -DarchetypeArtifactId=maven-archetype-webapp


    Note: Running mvn commands the first time will take time as Maven downloads all the requires artifacts from a remote repository: On my machine these were downloaded to...

    C:\Users\SteveR\.m2\repository



    Result ...



    Resulting folder set is created. This is where Maven forces the appropriate business models on specific project hierarchy which in it self is very powerful.




    A default pom is created which can be modified as required.





    Example of the pom.xml file as generated above.


    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.veinteractive.com</groupId>
    <artifactId>my_webapp</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>my_webapp Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
    </dependency>
    </dependencies>
    <build>
    <finalName>my_webapp</finalName>
    </build>
    </project>

    Go to the project directory containing the pom.xml



    If we then run

    mvn package



    We will get a WAR file created




    The trick is now to figure out how to organise our projects in SVN correctly for use with Eclipse local builds and remote Hudson builds.

    Steps:

    Install Hudson on Linux
    Install ANT on Linux
    Install Maven on Linux

    Re-design SVN projects to work with both local (Developer use from Eclipse IDE) and for Hudson to use locally from the Linux server and for the project in SVN to be organised in a standard fashion to work with Maven. Going forward we will use Maven as it will enforce business logic and process for all builds internally.

Middleware Mentor - Steven Charles Robinson

About Me

Steve Robinson has been working in IT for over 15 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware consulting. Steve comes from both an administration and development background.

Before moving to JEE, Steve was an accomplished developer and consultant for both IBM Lotus Notes and Microsoft .NET Technologies.

Follow Steve as @stevencrobinson on twitter.

Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Categories

Oracle WebLogic Categories

JBoss Categories

Other Categories