maven-plugins/uberjar/plugin.jelly
brett 07024cc0e6 PR: MPUBERJAR-4
add uberjar.bundle property for dependencies


git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114998 13f79535-47bb-0310-9956-ffa450edef68
2004-04-10 03:17:22 +00:00

204 lines
7.0 KiB
XML

<?xml version="1.0"?>
<!--
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* 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.
*/
-->
<project
xmlns:j="jelly:core"
xmlns:velocity="jelly:velocity"
xmlns:ant="jelly:ant"
xmlns:artifact="artifact">
<!--==================================================================-->
<!-- Default goal : Builds a uberjar file -->
<!--==================================================================-->
<goal
name="uberjar"
prereqs="uberjar:uberjar"
description="Build a uberjar file"/>
<!--==================================================================-->
<!-- Initializations -->
<!--==================================================================-->
<goal name="uberjar:init">
<property name="maven.uberjar.final.name" value="${maven.build.dir}/${maven.final.name}-uber.jar"/>
<property name="dest" value="${maven.build.dir}/uberjar"/>
<property name="inf" value="${dest}/WORLDS-INF"/>
<property name="libdir" value="${inf}/lib"/>
<property name="confdir" value="${inf}/conf"/>
<mkdir dir="${libdir}"/>
<mkdir dir="${confdir}"/>
</goal>
<!--==================================================================-->
<!-- Build the uberjar -->
<!--==================================================================-->
<goal
name="uberjar:uberjar"
prereqs="jar:jar, uberjar:init"
description="Build an uberjar">
<j:set var="uberconf" value="${maven.uberjar.classworlds.conf}"/>
<!-- Create the classworlds conf if user hasn't specified one -->
<j:choose>
<j:when test="${empty(uberconf)}">
<attainGoal name="uberjar:classworlds-conf"/>
</j:when>
<j:otherwise>
<copy file="${uberconf}" tofile="${confdir}/classworlds.conf"/>
</j:otherwise>
</j:choose>
<!-- Copy the project's complete jar -->
<copy
file="${maven.build.dir}/${maven.final.name}.jar"
todir="${libdir}"/>
<!-- Copy each dep to our working dir -->
<j:forEach var="lib" items="${pom.artifacts}">
<j:set var="dep" value="${lib.dependency}"/>
<j:if test="${dep.getProperty('uberjar.bundle')!='false'}">
<j:if test="${dep.type =='jar'}">
<ant:copy todir="${libdir}" file="${lib.path}"/>
</j:if>
</j:if>
</j:forEach>
<!-- Copy the classworlds.jar -->
<copy
tofile="${inf}/classworlds.jar"
file="${plugin.getDependencyPath('classworlds')}"/>
<!-- Unjar the bootstrap code -->
<unjar
dest="${dest}"
src="${plugin.getDependencyPath('classworlds')}">
<patternset>
<include name="org/codehaus/classworlds/boot/*.class"/>
<include name="org/codehaus/classworlds/protocol/jar/*.class"/>
</patternset>
</unjar>
<!-- Jar it all up -->
<jar
jarfile="${maven.uberjar.final.name}"
basedir="${dest}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Created-By" value="Classworlds"/>
<attribute name="Package" value="${pom.package}"/>
<attribute name="Main-Class" value="org.codehaus.classworlds.boot.Bootstrapper"/>
</manifest>
</jar>
</goal>
<!--==================================================================-->
<!-- Generate a classworlds conf file -->
<!--==================================================================-->
<goal
name="uberjar:classworlds-conf"
prereqs="uberjar:init"
description="Generates a classworlds conf">
<j:set var="ubermain" value="${maven.uberjar.main}"/>
<j:if test="${empty(ubermain)}">
<fail message="">
The maven.uberjar.main property has not been set. This value should
be set to the value of the class that contains the main method
to be invoked.
</fail>
</j:if>
<!-- Need to add the ant property 'maven.final.name' to the context
those are preloaded into the jelly context which is supposed to
happen soon. -->
<j:set var="self" value="${maven.final.name}"/>
<velocity:merge
name="${confdir}/classworlds.conf"
basedir="${plugin.resources}/conf"
template="classworlds.conf"/>
</goal>
<!--==================================================================-->
<!-- Install the uberjar in the local repository -->
<!--==================================================================-->
<goal name="uberjar:install"
prereqs="uberjar:uberjar"
description="Install the uberjar in the local repository">
<artifact:install
artifact="${maven.uberjar.final.name}"
type="uberjar"
project="${pom}"/>
</goal>
<!--=====================================================================-->
<!-- Install the snapshot version of the uberjar in the local repository -->
<!--=====================================================================-->
<goal name="uberjar:install-snapshot"
prereqs="uberjar:uberjar"
description="Install the snapshot version of the uberjar in the local repository">
<artifact:install-snapshot
artifact="${maven.uberjar.final.name}"
type="uberjar"
project="${pom}"/>
</goal>
<!--==================================================================-->
<!-- Deploys the uberjar to the remote repository -->
<!--==================================================================-->
<goal name="uberjar:deploy"
prereqs="uberjar:uberjar"
description="Deploys the uberjar to the remote repository">
<artifact:deploy
artifact="${maven.uberjar.final.name}"
type="uberjar"
project="${pom}"/>
</goal>
<!--==================================================================-->
<!-- Deploys the snapshot of the uberjar to the remote repository -->
<!--==================================================================-->
<goal name="uberjar:deploy-snapshot"
prereqs="uberjar:uberjar"
description="Deploys the snapshot version of the uberjar to remote repository">
<artifact:deploy-snapshot
artifact="${maven.uberjar.final.name}"
type="uberjar"
project="${pom}"/>
</goal>
</project>