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

Saturday, 31 August 2013

Transitioning from ANT to MAVEN

Well I have been putting together ANT scripts for some time now and I have created some funky scripts.
My main issue with ANT was that I had to do all the hard work over and over again. I did work to include IVY into my projects but it was just hard work and the scripts grew in complexity.
I had heard good things about MAVEN so I thought I might as well get stuck into it.

After some successes I smacked straight into an issue regarding the precompilation of JSPs which seems to be a dead topic as the plugins do not seem to work correctly or only work if you are building a WAR.
I want to precompile some JSPs and put them into a JAR ... but no joy.
So right now I am looking back at the ANT scripts and looking how best to include them in to MAVEN.

The first clue was a post on Slashdot titled "Multiple antrun tasks in maven".

The key is to have a series of ANTRuns stuck into your MAVEN script as follows:
<plugin>

    <artifactId>maven-antrun-plugin</artifactId>
    <executions>

        <execution>
            <id>clean</id>
            <phase>clean</phase>
            <configuration>
                <tasks>
                    <echo message = ">>>>>>>>>>>>>>>>>>>>>>>>>>clean"/>
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>

        <execution>
            <id>compile</id>
            <phase>compile</phase>
            <configuration>
                <tasks>
                    <echo message = ">>>>>>>>>>>>>>>>>>>>>>>>>>>>compile"/>
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>

        <execution>
            <id>package</id>
            <phase>package</phase>
            <configuration>
                <tasks>
                    <echo message = ">>>>>>>>>>>>>>>>>>>>>>>>>>>>package"/>
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>

    </executions>

</plugin>
asas

Tuesday, 19 June 2012

Using Apache-IVY : Missing dependency

This is just in case I loose this reference.
I had an error with my Ivy dependencies which reported "org.eclipse.persistence#org.eclipse.persistence.jpa;2.2.0: not found". It took me a while to find it but this post on Stack-Overflow helped.
It means that the standard Maven repositories do not hold this JAR so I have connected to the Eclipse Maven repository @ http://download.eclipse.org/rt/eclipselink/maven.repo/.

How?

Well my ivysettings.xml has this setting in it <ibiblio name="Eclipse-libraries"   m2compatible="true" root="http://download.eclipse.org/rt/eclipselink/maven.repo/" /> and looks like this:

<!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.   
-->
<ivysettings>
    <properties file="${ivy.settings.dir}/ivysettings.properties"/>
   
    <settings defaultResolver="embedplaysafe" />
   
    <!-- Where the Cache is placed -->
    <!-- <caches defaultCacheDir="${ivy.settings.dir}/ivy-cache" /> -->
    <caches defaultCacheDir="${defaultCache.dir}" />
   
    <resolvers>
        <!-- Path is important as this is the final repository -->
        <chain name="embedplaysafe"
               returnFirst="true"> <!-- if a revision is found in the filesystem then ivyrep will not be queried -->
            <!--
            It is a filesystem resolver, so looks at a directory structure to retrieve the artifacts.
            This one is configured to look in the repository sub directory of the directory that contains the ivysettings.xml file
             -->
            <filesystem name="local">
                <artifact pattern="${repository.dir}/[type]/[artifact]-[revision].[ext]" />
                <ivy pattern="${repository.dir}/[type]/[module]-[revision].xml" />
            </filesystem>
            <!--  See http://www.buildmeister.com/articles/escape_from_jar_hell_with_apache_ivy_the_agile_dependency_manager -->
            <!-- 
            <url name="buildmeister"> 
               <ivy pattern="http://m2.buildmeister.com/[module]/[revision]/ 
                ivy-[revision].xml" /> 
               <artifact pattern="http://m2.buildmeister.com/[module]/[revision]/ 
                [artifact]-[revision].[ext]" /> 
            </url>
            -->
            <!--  See http://stackoverflow.com/questions/1033859/ivy-via-nexus-proxy  -->
            <!-- It looks in the ibiblio maven repository to retrieve the artifacts.  -->
            <!--   -->
            <ibiblio name="uk-libraries"         m2compatible="true" root="http://uk.maven.org/maven2" />
            <ibiblio name="global-libraries"     m2compatible="true" usepoms="true" />
            <ibiblio name="Eclipse-libraries"   m2compatible="true" root="http://download.eclipse.org/rt/eclipselink/maven.repo/" />
          
        </chain>
    </resolvers>

</ivysettings>


I hope this helps you.