new plugin:available tag to check if a minimal release of a plugin is present.

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@280355 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
aheritier 2005-09-12 15:34:35 +00:00
parent 421aff51d2
commit 1e69156909
3 changed files with 86 additions and 0 deletions

View File

@ -369,6 +369,67 @@
</ant:fileset> </ant:fileset>
</ant:delete> </ant:delete>
</define:tag> </define:tag>
<define:tag name="available">
<!-- Check parameters -->
<maven:param-check value="${groupId}" fail="true" message="'groupId' must be specified"/>
<maven:param-check value="${artifactId}" fail="true" message="'artifactId' must be specified"/>
<maven:param-check value="${minRelease}" fail="true" message="'minRelease' must be specified"/>
<j:set var="pluginToTest" value="${artifactId}"/>
<j:set var="minReleaseToHave" value="${minRelease}"/>
<maven:get plugin="${pluginToTest}" property="plugin" var="installedPlugin" />
<!-- Check if the plugin is installed -->
<j:choose>
<j:when test="${!empty(installedPlugin)}">
<j:set var="installedRelease" value="${installedPlugin.currentVersion}"/>
<!-- Remove SNAPSHOT -->
<u:replace var="installedRelease" escapeText="true" old="-SNAPSHOT" new="">${installedRelease}</u:replace>
<u:replace var="minReleaseToHave" escapeText="true" old="-SNAPSHOT" new="">${minReleaseToHave}</u:replace>
<!-- Tokenify -->
<u:tokenize var="installedReleaseTokens" delim="." escapeText="true">${installedRelease}</u:tokenize>
<u:tokenize var="minReleaseToHaveTokens" delim="." escapeText="true">${minReleaseToHave}</u:tokenize>
<j:set var="minReleaseToHaveTokensIter" value="${minReleaseToHaveTokens.iterator()}"/>
<j:forEach var="numberInstalled" items="${installedReleaseTokens}">
<j:if test="${!minReleaseToHaveTokens.iterator().hasNext()}">
<j:set var="testFailed" value="true"/>
<j:break/>
</j:if>
<j:set var="numberToHave" value="${minReleaseToHaveTokensIter.next()}"/>
<j:choose>
<j:when test="${numberInstalled.compareTo(numberToHave) lt 0}">
<!-- ${numberInstalled} is less than ${numberToHave} => fail -->
<j:set var="testFailed" value="true"/>
<j:break/>
</j:when>
<j:when test="${numberInstalled.compareTo(numberToHave) eq 0}">
<!-- ${numberInstalled} is equal than ${numberToHave} => continue to test -->
</j:when>
<j:when test="${numberInstalled.compareTo(numberToHave) gt 0}">
<!-- ${numberInstalled} is greater than ${numberToHave} => good -->
<j:break/>
</j:when>
</j:choose>
</j:forEach>
</j:when>
<j:otherwise>
<j:set var="testFailed" value="true"/>
</j:otherwise>
</j:choose>
<j:if test="${testFailed}">
<ant:fail>
- BE CAREFUL
=======================================================================================
Must have ${pluginToTest} plugin v${minReleaseToHave} installed to use this version of the plugin.
Try: maven plugin:download -DgroupId=maven -DartifactId=${pluginToTest} -Dversion=${minReleaseToHave}
=======================================================================================
</ant:fail>
</j:if>
</define:tag>
</define:taglib> </define:taglib>
<define:taglib uri="assert"> <define:taglib uri="assert">

View File

@ -23,6 +23,9 @@
<author email="evenisse@ifrance.com">Emmanuel Venisse</author> <author email="evenisse@ifrance.com">Emmanuel Venisse</author>
</properties> </properties>
<body> <body>
<release version="1.7-SNAPSHOT" date="In SVN">
<action dev="aheritier" type="add">new plugin:available tag to check if a minimal release of a plugin is present.</action>
</release>
<release version="1.6" date="2005-06-03"> <release version="1.6" date="2005-06-03">
<action dev="vmassol" type="add">Added new <action dev="vmassol" type="add">Added new
<code>assert:assertFileContains</code>tag that verifies if a file contains a specific string. <code>assert:assertFileContains</code>tag that verifies if a file contains a specific string.

View File

@ -31,6 +31,7 @@
<ol> <ol>
<li><a href='#uninstall_Tag'>uninstall</a></li> <li><a href='#uninstall_Tag'>uninstall</a></li>
<li><a href='#clearCache_Tag'>clearCache</a></li> <li><a href='#clearCache_Tag'>clearCache</a></li>
<li><a href='#available_Tag'>available</a></li>
</ol> </ol>
</li> </li>
<li><a href='#assert_Tag_Library'>assert</a> <li><a href='#assert_Tag_Library'>assert</a>
@ -70,6 +71,27 @@
</p> </p>
<p>There are no attributes for this tag</p> <p>There are no attributes for this tag</p>
</subsection> </subsection>
<subsection name='assertFileExists Tag'>
<p>Fails the build if the given plugin does not exist or hasn't the minimal release number. Otherwise no effect.</p>
<table>
<tr><th>Attribute</th><th>Optional?</th><th>Description</th></tr>
<tr>
<td>groupId</td>
<td>No</td>
<td>The plugin's groupId</td>
</tr>
<tr>
<td>artifactId</td>
<td>No</td>
<td>The plugin's artifactId</td>
</tr>
<tr>
<td>minRelease</td>
<td>No</td>
<td>The minimum plugin's release</td>
</tr>
</table>
</subsection>
</section> </section>
<section name='assert Tag Library'> <section name='assert Tag Library'>
<p> <p>