home | career | drupal | java | mac | mysql | perl | scala | uml | unix

Groovy example source code file (build-maven.xml)

This example Groovy source code file (build-maven.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

author, conditions, date, is, kind, lastchangedby, license, license, of, see, see, warranties, you, you

The Groovy build-maven.xml source code

<?xml version="1.0"?>

<!--
Licensed 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.

This work is copyright by the author(s) and is part of a greater work collectively copyright by the
Groovy community. See the NOTICE.txt file distributed with this work for additional information.

Author : Paul King
$Revision: 20154 $ ($LastChangedBy: paulk $)
$Date: 2010-05-29 06:47:51 +0200 (Sa, 29. Mai 2010) $
-->

<project name="build-maven" default="" basedir="../.." xmlns:artifact="urn:maven-artifact-ant">

    <import file="build-setup.xml"/>

    <macrodef name="fetch.maven">
        <attribute name="scope"/>
        <attribute name="module"/>
        <sequential>
            <artifact:dependencies useScope="@{scope}" filesetId="fs.@{scope}.@{module}" pomRefId="@{module}.pom"/>
        </sequential>
    </macrodef>

    <macrodef name="maven.pom">
        <attribute name="file"/>
        <attribute name="id"/>
        <sequential>
            <artifact:pom file="@{file}" id="@{id}"/>
        </sequential>
    </macrodef>

    <macrodef name="fetch.maven.all.scopes">
        <attribute name="module"/>
        <sequential>
            <fetch.maven scope="compile" module="@{module}"/>
            <fetch.maven scope="runtime" module="@{module}"/>
            <fetch.maven scope="test" module="@{module}"/>
        </sequential>
    </macrodef>

    <macrodef name="fetch.maven.all.modules">
        <sequential>
            <fetch.maven.all.scopes module="groovy"/>
            <fetch.maven scope="runtime" module="groovy-tools"/>
            <fetch.maven scope="runtime" module="groovy-examples"/>
        </sequential>
    </macrodef>

    <target name="-mavenInit" depends="-mavenTaskdef,-mavenPomDefinitions"/>

    <target name="-mavenTaskdef" unless="_skipFetch_">
        <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant">
            <classpath>
                <fileset dir="${bootstrapDirectory}" includes="maven-ant-tasks-*.jar"/>
            </classpath>
        </typedef>
    </target>

    <target name="-mavenPomDefinitions" unless="_skipFetch_">
        <maven.pom file="pom.xml" id="groovy.pom"/>
        <xslt in="pom.xml" out="${targetDirectory}/groovy-all.pom" style="config/maven/groovy-all.xsl"/>
        <maven.pom file="${targetDirectory}/groovy-all.pom" id="groovy-all.pom"/>
        <maven.pom file="config/maven/groovy-tools.pom" id="groovy-tools.pom"/>
        <maven.pom file="config/maven/groovy-examples.pom" id="groovy-examples.pom"/>
    </target>

    <target name="-fetchDependencies" depends="-mavenFetchAllModules,-copyLibraries,-definePathsWithoutCopyingLibraries"/>

    <target name="-mavenFetchAllModules" depends="-mavenInit" unless="_skipFetch_">
        <fetch.maven.all.modules/>
    </target>

    <target name="-copyLibraries" unless="_skipFetch_">
        <definePath pathId="compilePath" filesetId="fs.compile.groovy" libdir="${compileLibDirectory}"/>
        <definePath pathId="runtimePath" filesetId="fs.runtime.groovy" libdir="${runtimeLibDirectory}"/>
        <definePath pathId="testLibPath" filesetId="fs.test.groovy" libdir="${testLibDirectory}"/>
        <definePath pathId="toolsPath" filesetId="fs.runtime.groovy-tools" libdir="${toolsLibDirectory}"/>
        <definePath pathId="examplesPath" filesetId="fs.runtime.groovy-examples" libdir="${examplesLibDirectory}"/>
    </target>

    <target name="-definePathsWithoutCopyingLibraries" if="_skipFetch_">
        <path id="compilePath">
            <fileset dir="${compileLibDirectory}" includes="**/*.jar"/>
        </path>
        <path id="runtimePath">
            <fileset dir="${runtimeLibDirectory}" includes="**/*.jar"/>
        </path>
        <path id="testLibPath">
            <fileset dir="${testLibDirectory}" includes="**/*.jar"/>
        </path>
        <path id="toolsPath">
            <fileset dir="${toolsLibDirectory}" includes="**/*.jar"/>
        </path>
        <path id="examplesPath">
            <fileset dir="${examplesLibDirectory}" includes="**/*.jar"/>
        </path>
    </target>

    <target name="-mavenDeployInit" depends="-mavenInit">
        <artifact:install-provider artifactId="wagon-webdav" version="1.0-beta-2"/>
    </target>

    <macrodef name="definePath">
        <attribute name="filesetId"/>
        <attribute name="libdir"/>
        <attribute name="pathId"/>
        <sequential>
            <mkdir dir="@{libdir}"/>
            <copy todir="@{libdir}">
                <mapper type="flatten"/>
                <fileset refid="@{filesetId}"/>
            </copy>
            <path id="@{pathId}">
                <fileset dir="@{libdir}" includes="**/*.jar"/>
            </path>
        </sequential>
    </macrodef>

    <macrodef name="mavenDeploy">
        <attribute name="version"/>
        <attribute name="prefix"/>
        <sequential>
            <artifact:deploy file="${targetDistDirectory}/@{prefix}-@{version}.jar">
                <pom refid="@{prefix}.pom"/>
                <attach file="${targetDistDirectory}/@{prefix}-@{version}-sources.jar" classifier="sources"/>
                <attach file="${targetDistDirectory}/@{prefix}-@{version}-javadoc.jar" classifier="javadoc"/>
            </artifact:deploy>
        </sequential>
    </macrodef>

    <macrodef name="mavenDeploySettings">
        <attribute name="version"/>
        <attribute name="prefix"/>
        <attribute name="settings"/>
        <sequential>
            <artifact:deploy file="${targetDistDirectory}/@{prefix}-@{version}.jar" settingsFile="@{settings}">
                <pom refid="@{prefix}.pom"/>
                <attach file="${targetDistDirectory}/@{prefix}-@{version}-sources.jar" classifier="sources"/>
                <attach file="${targetDistDirectory}/@{prefix}-@{version}-javadoc.jar" classifier="javadoc"/>
            </artifact:deploy>
        </sequential>
    </macrodef>

    <macrodef name="mavenInstallRepo">
        <attribute name="version"/>
        <attribute name="prefix"/>
        <sequential>
            <artifact:install file="${targetDistDirectory}/@{prefix}-@{version}.jar">
                <pom refid="@{prefix}.pom"/>
                <attach file="${targetDistDirectory}/@{prefix}-@{version}-sources.jar" classifier="sources"/>
                <attach file="${targetDistDirectory}/@{prefix}-@{version}-javadoc.jar" classifier="javadoc"/>
            </artifact:install>
        </sequential>
    </macrodef>

</project>

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy build-maven.xml source code file:

new blog posts

 

Copyright 1998-2013 Alvin Alexander, alvinalexander.com
All Rights Reserved.