maven-plugins/pom/plugin.jelly

180 lines
6.0 KiB
XML

<?xml version="1.0"?>
<!--
/*
* Copyright 2001-2005 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:d="jelly:define"
xmlns:pom="pom"
xmlns:plugin="plugin"
xmlns:util="jelly:util"
xmlns:ant="jelly:ant"
xmlns:x="jelly:xml"
xmlns:log="jelly:log"
xmlns:artifact="artifact"
xmlns:assert="assert">
<!-- set up pom tag library -->
<d:taglib uri="pom">
<d:jellybean
name="contentvalidator"
className="org.apache.maven.ContentValidator"
method="execute"/>
</d:taglib>
<!-- default goal -->
<goal name="pom" description="Validate the Maven XML project descriptor"
prereqs="pom:validate"/>
<!--
========================================================================
Verify validity of <pomVersion> element.
========================================================================
-->
<goal name="pom:verify-version">
<j:if test="${not(pom.pomVersion == '3' or pom.pomVersion == '4')}">
<ant:fail>POM version should be either "3" or "4", found "${pom.pomVersion}".</ant:fail>
</j:if>
</goal>
<!-- ================================================================== -->
<!-- V A L I D A T E P O M -->
<!-- ================================================================== -->
<goal
name="pom:validate"
description="Validate the Maven XML project descriptor">
<assert:assertPluginAvailable
groupId="maven"
artifactId="maven-plugin-plugin"
minRelease="1.7"
neededBy="${plugin.artifactId}"/>
<j:set var="xsd"
value="${plugin.resources}/xsd/pom-strict-${plugin.pomVersion}.xsd"/>
<util:file var="pomAsFile" name="${pom.file.canonicalPath}" />
<j:if test="${pomAsFile != null}">
<!-- x:parse doesn't work if <project> contains namespace? -->
<!--<x:parse var="parsedPom" xml="${pomAsFile}"/>
<x:set var="extends" select="$parsedPom/project/extend"/>-->
<j:new className="org.apache.maven.PomUtils" var="pomUtils"/>
<j:setProperties object="${pomUtils}" file="${pomAsFile}"/>
<j:set var="extends" value="${pomUtils.extend()}"/>
<j:set var="parent" value="${pomUtils.getParent()}"/>
</j:if>
<j:if test="${extends == 'true'}">
<log:warn>
<j:whitespace>
*** WARNING ***
*** The current pom extends ${parent}
*** This parent pom has to be validated separately!
</j:whitespace>
</log:warn>
<j:set var="xsd"
value="${maven.home}/maven-project-${plugin.pomVersion}.xsd"/>
</j:if>
<log:info>Using xsd file: ${xsd}</log:info>
<plugin:validate-xml
schema="${xsd}"
file="${pom.file.canonicalPath}"/>
</goal>
<goal name="pom:contentvalidate"
description="Validate the content of the Maven POM">
<j:new className="org.apache.maven.ContentValidator" var="contentvalidator"/>
<j:setProperties object="${contentvalidator}" project="${pom}"/>
<j:set var="notices" value="${contentvalidator.execute()}"/>
<j:forEach var="notice" items="${notices}">
<log:info>${notice.Level} : ${notice.Section} : ${notice.Message}</log:info>
</j:forEach>
</goal>
<!-- ========================================================================== -->
<!-- I N S T A L L P O M -->
<!-- ========================================================================== -->
<goal name="pom:install"
description="Install POM in the local repository.">
<artifact:install
artifact="project.xml"
type="pom"
project="${pom}"/>
</goal>
<!-- ========================================================================== -->
<!-- D E P L O Y P O M -->
<!-- ========================================================================== -->
<!-- POMs are deployed in the form ${pom.artifactId}-${pom.currentVersion}.pom -->
<!-- to match the same versioning convention as JARs. Having the POMs -->
<!-- deployed during each release will allow someone to build any -->
<!-- version of a project reliably. -->
<!-- ========================================================================== -->
<goal name="pom:deploy"
description="Deploy POM to the central repository.">
<artifact:deploy
artifact="project.xml"
type="pom"
project="${pom}"/>
</goal>
<!--==================================================================-->
<!-- Install the snapshot version of the pom in the local repository -->
<!--==================================================================-->
<goal name="pom:install-snapshot"
description="Install the snapshot version of the POM in the local repository">
<artifact:install-snapshot
artifact="project.xml"
type="pom"
project="${pom}"/>
</goal>
<!--==================================================================-->
<!-- Deploys the snapshot of the pom to the remote repository -->
<!--==================================================================-->
<goal name="pom:deploy-snapshot"
description="Deploys the snapshot version of the POM to remote repository">
<artifact:deploy-snapshot
artifact="project.xml"
type="pom"
project="${pom}"/>
</goal>
</project>