MPANNOUNCEMENT-19: added property maven.announcement.lenient

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@331807 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
felipeal 2005-11-08 12:57:44 +00:00
parent aecfd29e24
commit a44f732cf8
15 changed files with 513 additions and 38 deletions

View File

@ -59,11 +59,15 @@
<util:file var="inputFile" name="${maven.docs.src}/changes.xml"/>
<j:useBean var="stringUtils" class="org.apache.commons.lang.StringUtils"/>
<j:set var="isLenient" value="${maven.announcement.lenient}"/>
</goal>
<goal name="announcement:check-version" prereqs="announcement:init">
<j:choose>
<j:when test="${! isLenient}">
<x:parse var="doc" xml="${inputFile}"/>
<jsl:stylesheet select="$doc">
@ -94,6 +98,29 @@
<ant:fail>Missing "version" element in the POM for release ${versionVariable}.</ant:fail>
</j:if>
</j:if>
</j:when>
<j:otherwise>
<!-- creates an empty changes.xml file -->
<j:set var="emptyChangesXml" value="${maven.build.dir}/empty-changes.xml"/>
<j:file
name="${emptyChangesXml}"
encoding="${maven.announcement.encoding}"
outputMode="xml"
omitXmlDeclaration="true"
prettyPrint="false">
<document>
<properties>
<title>Release Notes</title>
</properties>
<body>
<release version="${pom.currentVersion}" description="No description"/>
</body>
</document>
</j:file>
<util:file var="emptyChangesXmlFile" name="${emptyChangesXml}"/>
<x:parse var="doc" xml="${emptyChangesXmlFile}"/>
</j:otherwise>
</j:choose>
</goal>
@ -107,6 +134,13 @@
<goal name="announcement:generate-all" prereqs="announcement:init"
description="Generate release announcement for all releases">
<j:set var="changesXmlAvailable" value="false"/>
<util:available file="${inputFile}">
<j:set var="changesXmlAvailable" value="true"/>
</util:available>
<j:choose>
<j:when test="${changesXmlAvailable}">
<x:parse var="doc" xml="${inputFile}"/>
<jsl:stylesheet select="$doc">
@ -119,6 +153,15 @@
<jsl:template match="@*"/>
<jsl:template match="text()"/>
</jsl:stylesheet>
</j:when>
<j:when test="${!changesXmlAvailable and isLenient}">
<ant:echo>File ${inputFile} not found, but maven.announcement.lenient set to true: calling announcement!</ant:echo>
<attainGoal name="announcement"/>
</j:when>
<j:when test="${!changesXmlAvailable and !isLenient}">
<ant:fail>File ${inputFile} not available</ant:fail>
</j:when>
</j:choose>
</goal>

View File

@ -53,3 +53,11 @@ maven.announcement.mail.client = localhost
# Mail subject to use when sending an announcement email.
maven.announcement.mail.subject = [ANN] ${pom.name} %VERSION% released
# Flag indicating if the announcement should be generated when restrictions
# doesn't apply:
# - changes.xml is missing
# - release version is missing on changes.xml
# - release version is missing on project.xml <versions> tag
# If set to true, these restrictions are ignored
maven.announcement.lenient = false

View File

@ -0,0 +1,22 @@
<!--
/*
* Copyright 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:util="jelly:util" xmlns:maven="jelly:maven" xmlns:j="jelly:core" xmlns:assert="assert" xmlns:ant="jelly:ant">
<goal name="testPlugin">
<maven:reactor basedir="${basedir}" includes="*Test/project.xml" goals="testPlugin" banner="Test" ignoreFailures="false"/>
</goal>
</project>

View File

@ -0,0 +1,59 @@
<!--
/*
* Copyright 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:ant="jelly:ant" xmlns:maven="jelly:maven" xmlns:assert="assert" xmlns:util="jelly:util" default="testPlugin">
<goal name="testPlugin" prereqs="testAnnouncement">
<attainGoal name="clean"/>
</goal>
<goal name="testAnnouncement" prereqs="test-default,test-lenient,test-non-lenient"/>
<goal name="test-lenient" prereqs="clean">
<j:set var="maven.announcement.lenient" value="true"/>
<attainGoal name="announcement"/>
<attainGoal name="assert-generated-file"/>
</goal>
<goal name="test-non-lenient" prereqs="clean">
<j:set var="maven.announcement.lenient" value="false"/>
<attainGoal name="catch-it"/>
</goal>
<goal name="test-default" prereqs="clean">
<attainGoal name="catch-it"/>
</goal>
<goal name="assert-generated-file">
<maven:property var="announcementFile" name="maven.announcement.file"
defaultValue="${maven.gen.docs}/announcements/announcement-${pom.currentVersion}.txt"/>
<assert:assertFileExists file="${announcementFile}"/>
<util:file var="generatedFile" name="${announcementFile}"/>
<j:set var="fileSize" value="${generatedFile.length()}"/>
<j:if test="${fileSize==0}">
<ant:fail>File ${announcementFile} was generated empty!</ant:fail>
</j:if>
</goal>
<goal name="catch-it" prereqs="clean">
<j:catch var="e">
<attainGoal name="announcement"/>
</j:catch>
<j:if test="${empty(e)}">
<ant:fail>Goal announcement should have failed</ant:fail>
</j:if>
</goal>
</project>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* Copyright 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="http://maven.apache.org/POM/3.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/3.0.0
http://maven.apache.org/maven-v3_0_0.xsd">
<pomVersion>3</pomVersion>
<name>Announcment Plugin - Ignore Missing Release Test</name>
<artifactId>test-maven-announcement-ignore-missing-release-test</artifactId>
<inceptionYear>2005</inceptionYear>
<shortDescription>Tests missing release element on changes.xml</shortDescription>
<description>Tests missing release element on changes.xml when property maven.announcement.lenient is set</description>
<currentVersion>1.0</currentVersion>
<url/>
<developers>
<developer>
<name>Felipe Leme</name>
<id>felipeal</id>
<email>maven@felipeal.net</email>
<organization>Falcon Informatica</organization>
</developer>
</developers>
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<document>
<body>
<release version="6.6.6" >
<action dev="felipeal" type="add">Bogus version.</action>
</release>
</body>
</document>

View File

@ -0,0 +1,59 @@
<!--
/*
* Copyright 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:ant="jelly:ant" xmlns:maven="jelly:maven" xmlns:assert="assert" xmlns:util="jelly:util" default="testPlugin">
<goal name="testPlugin" prereqs="testAnnouncement">
<attainGoal name="clean"/>
</goal>
<goal name="testAnnouncement" prereqs="test-default,test-lenient,test-non-lenient"/>
<goal name="test-lenient" prereqs="clean">
<j:set var="maven.announcement.lenient" value="true"/>
<attainGoal name="announcement"/>
<attainGoal name="assert-generated-file"/>
</goal>
<goal name="test-non-lenient" prereqs="clean">
<j:set var="maven.announcement.lenient" value="false"/>
<attainGoal name="catch-it"/>
</goal>
<goal name="test-default" prereqs="clean">
<attainGoal name="catch-it"/>
</goal>
<goal name="assert-generated-file">
<maven:property var="announcementFile" name="maven.announcement.file"
defaultValue="${maven.gen.docs}/announcements/announcement-${pom.currentVersion}.txt"/>
<assert:assertFileExists file="${announcementFile}"/>
<util:file var="generatedFile" name="${announcementFile}"/>
<j:set var="fileSize" value="${generatedFile.length()}"/>
<j:if test="${fileSize==0}">
<ant:fail>File ${announcementFile} was generated empty!</ant:fail>
</j:if>
</goal>
<goal name="catch-it" prereqs="clean">
<j:catch var="e">
<attainGoal name="announcement"/>
</j:catch>
<j:if test="${empty(e)}">
<ant:fail>Goal announcement should have failed</ant:fail>
</j:if>
</goal>
</project>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* Copyright 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="http://maven.apache.org/POM/3.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/3.0.0
http://maven.apache.org/maven-v3_0_0.xsd">
<pomVersion>3</pomVersion>
<name>Announcment Plugin - Ignore Missing Version Test</name>
<artifactId>test-maven-announcement-ignore-missing-version-test</artifactId>
<inceptionYear>2005</inceptionYear>
<shortDescription>Tests missing version element on project.xml</shortDescription>
<description>Tests missing element on project.xml when property maven.announcement.lenient is set</description>
<currentVersion>1.0</currentVersion>
<versions>
<version>
<id>6.6.6</id>
<name>6.6.6</name>
<tag>BOGUS-6.6.6</tag>
</version>
</versions>
<url/>
<developers>
<developer>
<name>Felipe Leme</name>
<id>felipeal</id>
<email>maven@felipeal.net</email>
<organization>Falcon Informatica</organization>
</developer>
</developers>
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<document>
<body>
<release version="1.0" >
<action dev="felipeal" type="add">Bogus version.</action>
</release>
</body>
</document>

View File

@ -0,0 +1,74 @@
<!--
/*
* Copyright 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:ant="jelly:ant" xmlns:maven="jelly:maven" xmlns:assert="assert" xmlns:util="jelly:util" default="testPlugin">
<goal name="testPlugin" prereqs="testAnnouncement,testAnnouncementAll">
<attainGoal name="clean"/>
</goal>
<goal name="testAnnouncement" prereqs="test-default,test-lenient,test-non-lenient"/>
<goal name="testAnnouncementAll" prereqs="test-all-default,test-all-lenient,test-all-non-lenient"/>
<goal name="test-lenient" prereqs="clean">
<j:set var="maven.announcement.lenient" value="true"/>
<attainGoal name="announcement"/>
<attainGoal name="assert-generated-file"/>
</goal>
<goal name="test-non-lenient" prereqs="clean">
<j:set var="maven.announcement.lenient" value="false"/>
<j:set var="catchItGoal" value="announcement"/>
<attainGoal name="catch-it"/>
</goal>
<goal name="test-default" prereqs="clean">
<j:set var="catchItGoal" value="announcement"/>
<attainGoal name="catch-it"/>
</goal>
<goal name="test-all-lenient" prereqs="clean">
<j:set var="maven.announcement.lenient" value="true"/>
<attainGoal name="announcement:generate-all"/>
<attainGoal name="assert-generated-file"/>
</goal>
<goal name="test-all-non-lenient" prereqs="clean">
<j:set var="maven.announcement.lenient" value="false"/>
<j:set var="catchItGoal" value="announcement:generate-all"/>
<attainGoal name="catch-it"/>
</goal>
<goal name="test-all-default" prereqs="clean">
<j:set var="catchItGoal" value="announcement:generate-all"/>
<attainGoal name="catch-it"/>
</goal>
<goal name="assert-generated-file">
<maven:property var="announcementFile" name="maven.announcement.file"
defaultValue="${maven.gen.docs}/announcements/announcement-${pom.currentVersion}.txt"/>
<assert:assertFileExists file="${announcementFile}"/>
<util:file var="generatedFile" name="${announcementFile}"/>
<j:set var="fileSize" value="${generatedFile.length()}"/>
<j:if test="${fileSize==0}">
<ant:fail>File ${announcementFile} was generated empty!</ant:fail>
</j:if>
</goal>
<goal name="catch-it" prereqs="clean">
<j:catch var="e">
<attainGoal name="${catchItGoal}"/>
</j:catch>
<j:if test="${empty(e)}">
<ant:fail>Goal ${catchItGoal} should have failed</ant:fail>
</j:if>
</goal>
</project>

View File

@ -0,0 +1,17 @@
# -------------------------------------------------------------------
# Copyright 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.
# -------------------------------------------------------------------
maven.announcement.versions.ignore=true

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* Copyright 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="http://maven.apache.org/POM/3.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/3.0.0
http://maven.apache.org/maven-v3_0_0.xsd">
<pomVersion>3</pomVersion>
<name>Announcment Plugin - No changes.xml Test</name>
<artifactId>test-maven-announcement-no-changes-xml-test</artifactId>
<inceptionYear>2005</inceptionYear>
<currentVersion>1.0</currentVersion>
<shortDescription>Tests missing changes.xml file</shortDescription>
<description>Tests missing changes.xml file when maven.announcement.lenient property is set</description>
<url/>
<developers>
<developer>
<name>Felipe Leme</name>
<id>felipeal</id>
<email>maven@felipeal.net</email>
<organization>Falcon Informatica</organization>
</developer>
</developers>
</project>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* Copyright 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>
<pomVersion>3</pomVersion>
<name>Test project for Maven Announcement Plugin</name>
<groupId>maven</groupId>
<currentVersion>1.0</currentVersion>
<organization>
<name>Apache Software Foundation</name>
<url>http://www.apache.org/</url>
<logo>http://maven.apache.org/images/apache-maven-project.png</logo>
</organization>
<inceptionYear>2005</inceptionYear>
<package>org.apache.maven</package>
<logo>http://maven.apache.org/images/maven.gif</logo>
<description>Test for Maven Announcement plugin</description>
<shortDescription>Test for Maven Announcement plugin</shortDescription>
<url>http://maven.apache.org/reference/plugins/announcement/</url>
<siteDirectory>/www/maven.apache.org/reference/plugins/announcement/</siteDirectory>
<repository>
<connection>scm:svn:http://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk/announcement/</connection>
<url>http://svn.apache.org/viewcvs.cgi/maven/maven-1/plugins/trunk/announcement/</url>
</repository>
</project>

View File

@ -25,6 +25,8 @@
</properties>
<body>
<release version="1.4-SNAPSHOT" date="in SVN">
<action dev="felipeal" type="add" issue="MPANNOUNCEMENT-19">Added property <code>maven.announcement.lenient</code>.
</action>
<action dev="aheritier" type="update" issue="MAVEN-1712">Update dependencies to match ones in maven 1.1 core and to unify them between plugins. The following dependencies are updated :
<ul>
<li>commons-net v1.2.1 -> v1.4.0</li>

View File

@ -140,6 +140,21 @@
<code>UTF-8</code>
</td>
</tr>
<tr>
<td>maven.announcement.lenient</td>
<td>Yes</td>
<td>
When set to <code>false</code>, the plugin will fail in the occurrence of any of the following conditions:<br/>
<ul>
<li><code>xdocs/changes.xml</code> file is not available</li>
<li><code>xdocs/changes.xml</code> has not a <code>release</code> entry for the current version</li>
<li><code>project.xml</code> has not a <code>version</code> entry for the current version</li>
</ul>
</td>
<td>
<code>false</code>
</td>
</tr>
</table>
</section>
</body>