git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@531612 13f79535-47bb-0310-9956-ffa450edef68
291 lines
13 KiB
XML
291 lines
13 KiB
XML
<?xml version="1.0"?>
|
|
<!--
|
|
/*
|
|
* 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.
|
|
*/
|
|
-->
|
|
|
|
|
|
<project
|
|
xmlns:j="jelly:core"
|
|
xmlns:ant="jelly:ant"
|
|
xmlns:license="license"
|
|
xmlns:maven="jelly:maven"
|
|
xmlns:artifact="artifact"
|
|
xmlns:assert="assert"
|
|
xmlns:util="jelly:util"
|
|
xmlns:doc="doc">
|
|
|
|
<j:if test="${bootstrapping == null}">
|
|
<!-- fake test because the assert:assertPluginAvailable tag is avalaible in the maven-plugin-plugin 1.7 and newer. Thus maven will break if it's not present. -->
|
|
<assert:assertPluginAvailable groupId="maven" artifactId="maven-plugin-plugin" minRelease="1.7" neededBy="${plugin.artifactId}"/>
|
|
<assert:assertPluginAvailable groupId="maven" artifactId="maven-artifact-plugin" minRelease="1.3" neededBy="${plugin.artifactId}"/>
|
|
</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="java:compile,java:jar-resources,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}"/>
|
|
|
|
<j:set var="mavenVersion" value="${maven.application.version}"/>
|
|
<j:if test="${mavenVersion != null}">
|
|
<ant:attribute name="Maven-Version" value="${mavenVersion}"/>
|
|
</j:if>
|
|
|
|
<j:set var="jarClasspath" value="${maven.jar.manifest.classpath.add}"/>
|
|
<j:if test="${jarClasspath}">
|
|
<j:remove var="maven.jar.classpath"/>
|
|
<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="${!empty(maven.jar.classpath)}">
|
|
<ant:attribute name="Class-Path" value="${maven.jar.classpath}"/>
|
|
</j:if>
|
|
</j:if>
|
|
|
|
<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://repo1.maven.org/maven${artifact.urlPath}"/>
|
|
</j:when>
|
|
<j:otherwise>
|
|
<ant:attribute name="${dep.artifactId}-Implementation-URL" value="${dep.url}"/>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
<j:set var="depVendorId" value="${dep.properties.vendorId}"/>
|
|
<j:if test="${!empty(depVendorId) and depVendorId.toString().trim().length() != 0}">
|
|
<ant:attribute name="${dep.artifactId}-Implementation-Vendor-Id" value="${depVendorId}"/>
|
|
</j:if>
|
|
</j:if>
|
|
</j:forEach>
|
|
</j:if>
|
|
|
|
<!-- Remove SNAPSHOT -->
|
|
<j:choose>
|
|
<j:when test="${pom.currentVersion.endsWith('-SNAPSHOT')}">
|
|
<j:invokeStatic className="org.apache.commons.lang.StringUtils" method="substringBeforeLast" var="pomCurrentVersion">
|
|
<j:arg value="${pom.currentVersion}" type="java.lang.String"/>
|
|
<j:arg value="-SNAPSHOT" type="java.lang.String"/>
|
|
</j:invokeStatic>
|
|
</j:when>
|
|
<j:otherwise>
|
|
<j:set var="pomCurrentVersion" value="${pom.currentVersion}"/>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
|
|
<util:tokenize var="versionItems" delim="." trim="true">${pomCurrentVersion}</util:tokenize>
|
|
<j:if test="${size(versionItems) > 0}">
|
|
<j:set var="specificationVersion" value="${versionItems[0]}" />
|
|
</j:if>
|
|
<j:if test="${size(versionItems) > 1}">
|
|
<j:set var="specificationVersion" value="${specificationVersion}.${versionItems[1]}" />
|
|
</j:if>
|
|
<j:if test="${size(versionItems) > 2}">
|
|
<j:set var="specificationVersion" value="${specificationVersion}.${versionItems[2]}" />
|
|
</j:if>
|
|
|
|
<util:replace var="packagePath" oldChar="." newChar="/" value="${pom.package}"/>
|
|
<ant:section name="${packagePath}">
|
|
<ant:attribute name="Extension-name" value="${pom.package}"/>
|
|
<ant:attribute name="Specification-Title" value="${specificationTitle}"/>
|
|
<ant:attribute name="Specification-Vendor" value="${pom.organization.name}"/>
|
|
<ant:attribute name="Specification-Version" value="${specificationVersion}"/>
|
|
<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: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>
|
|
</ant:section>
|
|
|
|
<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>
|