maven-plugins/license/plugin.jelly

103 lines
3.6 KiB
XML

<?xml version="1.0"?>
<project
xmlns:j="jelly:core"
xmlns:define="jelly:define"
xmlns:doc="doc"
xmlns:license="license"
xmlns:util="jelly:util">
<define:taglib uri="license">
<define:tag name="fileName">
<j:set var="licenseX" value='${maven.license.licenseFile}X'/>
<j:choose>
<j:when test="${licenseX != 'X'}">
<j:set var="licenseFile" value='${maven.license.licenseFile}'/>
</j:when>
<j:otherwise>
<j:set var="licenseFile" value='${basedir}/LICENSE.txt'/>
</j:otherwise>
</j:choose>
<j:whitespace trim="yes">${licenseFile}</j:whitespace>
</define:tag>
<define:tag name="relativeFileName" trim="yes">
<!-- get the license file and replace backslashes with forwards -->
<util:replace var="forwardSlashFile" oldChar="\" newChar="/" trim="yes">
<license:fileName />
</util:replace>
<!-- change bsaedir to have forward slashes too -->
<util:replace var="forwardSlashBaseDir" value="${basedir}"
oldChar="\" newChar="/" />
<j:if test="${!forwardSlashBaseDir.endsWith('/')}">
<j:set var="base" value="${forwardSlashBaseDir}/" />
</j:if>
<j:set var="relativePath">${forwardSlashFile.substring(base.length())}</j:set>
<j:whitespace trim="yes">${relativePath}</j:whitespace>
</define:tag>
</define:taglib>
<!-- ================================================================== -->
<!-- L I C E N S E -->
<!-- ================================================================== -->
<goal name="maven-license-plugin:register">
<doc:registerReport
name="Project License"
link="license"
description="Displays the primary license for the project."/>
</goal>
<goal name="maven-license-plugin:report"
description="Generate an XML file from the license.txt">
<attainGoal name="license"/>
</goal>
<goal name="license"
description="Generate an XML file from the license file"
prereqs="license:transfer"/>
<goal
name="license:transfer"
prereqs="xdoc:init"
description="Generate a xml file from your license file">
<j:set var="licenseFile"><license:fileName /></j:set>
<j:set var="genDocs"
value="${pom.getPluginContext('maven-xdoc-plugin').getVariable('maven.gen.docs')}"/>
<util:available file="${licenseFile}">
<j:set var="licensePresent" value="true"/>
</util:available>
<j:if test="${licensePresent != 'true'}">
<echo>
======================================================================
= W A R N I N G =
======================================================================
= Your project doesn't contain a header file specified as: =
= ${licenseFile}
= The License Report Plugin needs it to display the license =
= for the project. =
= If it can't find this file, it creates a page mentioning that =
= no license file has been given to Maven. =
======================================================================
</echo>
<j:set var="licenseFile" value='${plugin.resources}/LICENSE.txt'/>
</j:if>
<doc:text-xdoc
title="Project License"
section="Project License"
output="${genDocs}/license.xml"
inputFile="${licenseFile}"/>
</goal>
</project>