maven-plugins/jar/plugin.jelly
2004-10-18 17:19:31 +00:00

263 lines
11 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:ant="jelly:ant"
xmlns:license="license"
xmlns:maven="jelly:maven"
xmlns:artifact="artifact"
xmlns:util="jelly:util"
xmlns:doc="doc">
<j:if test="${bootstrapping == null}">
<!-- Poor mans version check - plugin dependencies still suck for multiple versions -->
<maven:get plugin="maven-artifact-plugin" property="plugin" var="artifactPlugin" />
<j:if test="${artifactPlugin.currentVersion.compareTo('1.3') lt 0}">
<ant:fail>
Must have artifact plugin v1.3 installed to use this version of the jar plugin.
Try: maven plugin:download -DgroupId=maven -DartifactId=maven-artifact-plugin -Dversion=1.3
</ant:fail>
</j:if>
</j:if>
<!-- ================================================================== -->
<!-- J A R -->
<!-- ================================================================== -->
<goal name="jar" prereqs="jar:jar"
description="Create the deliverable jar file."/>
<goal name="jar:jar"
description="Create the deliverable jar file."
prereqs="test:test">
<j:choose>
<j:when test="${pom.currentVersion == null}">
<ant:fail>You must define currentVersion in your POM.</ant:fail>
</j:when>
</j:choose>
<ant:available property="maven.jar.manifest.available"
file="${maven.jar.manifest}"/>
<j:set var="specificationTitle" value="${pom.shortDescription.trim()}"/>
<j:if test="${specificationTitle.length() gt 49}">
<ant:echo>Warning: shortDescription is greater than 49 characters - trimming for specification title.</ant:echo>
<j:set var="specificationTitle" value="${specificationTitle.substring(0,46)}..."/>
</j:if>
<!-- See http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html -->
<!-- See http://java.sun.com/j2se/1.4.1/docs/guide/jar/jar.html -->
<ant:jar
jarfile="${maven.build.dir}/${maven.jar.final.name}"
basedir="${maven.build.dest}"
index="${maven.jar.index}"
compress="${maven.jar.compress}"
excludes="${maven.jar.excludes}">
<j:if test="${maven.jar.manifest.available}">
<ant:setProperty name="manifest" value="${maven.jar.manifest}" />
</j:if>
<j:if test="${context.getVariable('maven.jar.includes') != null}">
<ant:setProperty name="includes" value="${maven.jar.includes}" />
</j:if>
<j:set var="licenseFileName"><license:fileName/></j:set>
<util:file name="${licenseFileName}" var="licenseFile"/>
<ant:metainf dir="${licenseFile.canonicalFile.parent}">
<ant:include name="${licenseFile.canonicalFile.name}"/>
</ant:metainf>
<ant:manifest>
<ant:attribute name="Built-By" value="${user.name}"/>
<ant:attribute name="Created-By" value="Apache Maven"/>
<ant:attribute name="Package" value="${pom.package}"/>
<ant:attribute name="Build-Jdk" value="${java.version}"/>
<j:set var="jarClasspath" value="${maven.jar.manifest.classpath.add}"/>
<j:if test="${jarClasspath}">
<j:forEach var="dep" items="${pom.dependencies}">
<j:if test="${dep.getProperty('jar.manifest.classpath')=='true'}">
<j:set var="maven.jar.classpath" value="${maven.jar.classpath} ${dep.artifact}" />
</j:if>
</j:forEach>
<j:if test="${maven.jar.classpath.length() != 0}">
<ant:attribute name="Class-Path" value="${maven.jar.classpath}"/>
</j:if>
</j:if>
<!-- added supplementary entries -->
<ant:attribute name="Extension-Name" value="${pom.artifactId}"/>
<ant:attribute name="Specification-Title" value="${specificationTitle}" />
<ant:attribute name="Specification-Vendor" value="${pom.organization.name}"/>
<!--
<ant:attribute name="Specification-Version" value="${pom.currentVersion}"/>
-->
<ant:attribute name="Implementation-Title" value="${pom.package}"/>
<ant:attribute name="Implementation-Vendor" value="${pom.organization.name}"/>
<ant:attribute name="Implementation-Version" value="${pom.currentVersion}"/>
<j:set var="mainclass" value="${maven.jar.mainclass}" />
<j:if test="${!empty(mainclass)}">
<ant:attribute name="Main-Class" value="${mainclass}"/>
</j:if>
<j:set var="jarExtensions" value="${maven.jar.manifest.extensions.add}"/>
<j:if test="${jarExtensions == 'true'}">
<j:set var="extensionList" value=""/>
<j:forEach var="artifact" items="${pom.artifacts}">
<j:set var="dep" value="${artifact.dependency}"/>
<j:if test="${dep.type == 'jar' || empty(dep.type)}">
<j:set var="extensionList" value="${extensionList} ${dep.artifactId}"/>
</j:if>
</j:forEach>
<j:if test="${extensionList.length() != 0}">
<j:set var="extensionList" value="${extensionList.substring(1)}"/>
<ant:attribute name="Extension-List" value="${extensionList}"/>
</j:if>
<j:forEach var="artifact" items="${pom.artifacts}">
<j:set var="dep" value="${artifact.dependency}"/>
<j:if test="${dep.type == 'jar' || empty(dep.type)}">
<ant:attribute name="${dep.artifactId}-Extension-Name" value="${dep.artifactId}"/>
<ant:attribute name="${dep.artifactId}-Implementation-Version" value="${dep.version}"/>
<j:choose>
<j:when test="${empty(dep.url) || dep.url.toString().trim().length() == 0}">
<ant:attribute name="${dep.artifactId}-Implementation-URL" value="http://www.ibiblio.org/maven${artifact.urlPath}"/>
</j:when>
<j:otherwise>
<ant:attribute name="${dep.artifactId}-Implementation-URL" value="${dep.url}"/>
</j:otherwise>
</j:choose>
</j:if>
</j:forEach>
</j:if>
<j:if test="${context.getVariable('maven.jar.manifest.attributes.list') != null}">
<util:tokenize var="attributeList" delim="," trim="true">${maven.jar.manifest.attributes.list}</util:tokenize>
<j:forEach var="attribute" items="${attributeList}">
<j:set var="name" value="maven.jar.manifest.attribute.${attribute}"/>
<j:set var="value" value="${context.findVariable(name)}"/>
<ant:attribute name="${attribute}" value="${value}"/>
</j:forEach>
</j:if>
<j:if test="${context.getVariable('maven.jar.manifest.groups.list') != null}">
<util:tokenize var="groupList" delim="," trim="true">${maven.jar.manifest.groups.list}</util:tokenize>
<j:forEach var="group" items="${groupList}">
<j:set var="nameVar" value="maven.jar.manifest.${group}.name"/>
<j:set var="groupName" value="${context.findVariable(nameVar)}"/>
<j:set var="attributeListVar" value="maven.jar.manifest.${group}.attributes.list"/>
<j:set var="groupAttributes" value="${context.findVariable(attributeListVar)}"/>
<util:tokenize var="attributeList" delim="," trim="true">${groupAttributes}</util:tokenize>
<ant:section name="${groupName}">
<j:forEach var="attribute" items="${attributeList}">
<j:set var="name" value="maven.jar.manifest.${group}.attribute.${attribute}"/>
<j:set var="value" value="${context.findVariable(name)}"/>
<ant:attribute name="${attribute}" value="${value}"/>
</j:forEach>
</ant:section>
</j:forEach>
</j:if>
</ant:manifest>
</ant:jar>
</goal>
<!-- ================================================================== -->
<!-- S N A P S H O T J A R -->
<!-- ================================================================== -->
<goal
name="jar:snapshot"
description="Create a snapshot jar, ie 'id-YYYYMMDD.hhmmss.jar'">
<ant:echo>DEPRECATED: jar:snapshot is deprecated</ant:echo>
<maven:snapshot project="${pom}"/>
<j:set var="oldMavenFinalName" value="${maven.final.name}" />
<j:set var="maven.final.name" value="${snapshotSignature}"/>
<ant:echo>Building snapshot JAR: ${maven.final.name}</ant:echo>
<attainGoal name="jar:jar"/>
</goal>
<!-- ================================================================== -->
<!-- D E P L O Y S N A P S H O T -->
<!-- ================================================================== -->
<goal
name="jar:deploy-snapshot"
prereqs="jar:jar"
description="Deploy a snapshot jar to the remote repository">
<artifact:deploy-snapshot
artifact="${maven.build.dir}/${maven.jar.final.name}"
type="jar"
project="${pom}"
/>
</goal>
<!-- ================================================================== -->
<!-- D E P L O Y J A R -->
<!-- ================================================================== -->
<goal
name="jar:deploy"
prereqs="jar:jar"
description="Deploy a jar to the remote repository">
<artifact:deploy
artifact="${maven.build.dir}/${maven.jar.final.name}"
type="jar"
project="${pom}"
/>
</goal>
<!-- ================================================================== -->
<!-- I N S T A L L J A R -->
<!-- ================================================================== -->
<goal name="jar:install" prereqs="jar:jar"
description="Install the jar in the local repository">
<artifact:install
artifact="${maven.build.dir}/${maven.jar.final.name}"
type="jar"
project="${pom}"
/>
</goal>
<!-- ================================================================== -->
<!-- I N S T A L L S N A P S H O T -->
<!-- ================================================================== -->
<goal
name="jar:install-snapshot" prereqs="jar:jar"
description="Install a snapshot jar in the local repository">
<artifact:install-snapshot
artifact="${maven.build.dir}/${maven.jar.final.name}"
type="jar"
project="${pom}"
/>
</goal>
</project>