Prevent projects who do not use the head check from failing if they don't provide a license file.

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114315 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
vmassol committed 2003-11-12 19:09:07 +00:00
1 parent d5877e36a7
commit 6422d89a10
2 files changed
+94 -98

No files matched your search

+90 -98
View File
@@ -65,45 +65,6 @@
</goal>
<!--
========================================================================
Check if license file is available, display warning if not and sets
the Ant "checkstyleShouldRun" property if the license file is
available.
========================================================================
-->
<goal name="checkstyle:license"
prereqs="checkstyle:init">
<j:if test="${sourcesPresent == 'true'}">
<util:file var="header" name="${maven.checkstyle.header.file}"/>
<j:choose>
<j:when test="${not(header.exists())}">
<ant:echo>
=================================================================
= W A R N I N G =
=================================================================
= Your project doesn't contain a header file specified as: =
= ${header}
= Checkstyle needs it to check the existence of the License in =
= your source files. If it can't find this file, it throws an =
= error. =
= A temporary solution is to create an empty LICENSE.txt file. =
= Though, we recommend that you edit this License. =
=================================================================
</ant:echo>
</j:when>
<j:otherwise>
<ant:property name="checkstyleShouldRun" value="true"/>
</j:otherwise>
</j:choose>
</j:if>
</goal>
<!--
========================================================================
Generate a checkstyle report by running checkstyle on the project
@@ -112,75 +73,106 @@
-->
<goal name="checkstyle:report"
description="Perform checkstyle checks"
prereqs="checkstyle:init,checkstyle:license">
prereqs="checkstyle:init">
<j:if test="${checkstyleShouldRun}">
<j:if test="${sourcesPresent == 'true'}">
<!-- Create the directory for the checkstyle cache in case it doesn't
exist already -->
<ant:dirname property="maven.checkstyle.cache.dir"
file="${maven.checkstyle.cache.file}"/>
<ant:mkdir dir="${maven.checkstyle.cache.dir}"/>
<ant:echo>Using ${checkstyleProperties} for checkstyle ...</ant:echo>
<ant:checkstyle
config="${checkstyleProperties}"
failOnViolation="${maven.checkstyle.fail.on.violation}">
<property key="checkstyle.header.file"
file="${maven.checkstyle.header.file}"/>
<property key="checkstyle.cache.file"
file="${maven.checkstyle.cache.file}"/>
<ant:fileset dir="${pom.build.sourceDirectory}"
includes="${maven.checkstyle.includes}"
excludes="${maven.checkstyle.excludes}">
<!-- FIXME: This is a bad cut and paste -->
<!-- handle source modifications -->
<j:forEach var="sm" items="${pom.build.sourceModifications}">
<ant:available property="classPresent" classname="${sm.className}"/>
<j:if test="${classPresent != 'true'}">
<j:forEach var="exclude" items="${sm.excludes}">
<ant:exclude name="${exclude}"/>
</j:forEach>
<j:forEach var="include" items="${sm.includes}">
<ant:include name="${include}"/>
</j:forEach>
</j:if>
</j:forEach>
</ant:fileset>
<ant:classpath>
<ant:path refid="maven.dependency.classpath"/>
<ant:pathelement path="${maven.build.dest}"/>
</ant:classpath>
<ant:formatter type="xml"
toFile="${maven.build.dir}/checkstyle-raw-report.xml"/>
<j:catch var="exception">
<attainGoal name="checkstyle:run"/>
</j:catch>
<j:if test="${(exception != null)}">
<j:choose>
<j:when test="${maven.checkstyle.usefile}">
<ant:formatter type="plain"
toFile="${maven.build.dir}/checkstyle-raw-report.txt"/>
<j:when test="${exception.indexOf('unable to load header file') != '-1'}">
<ant:echo>
=================================================================
= W A R N I N G =
=================================================================
= Your project doesn't contain a header file specified as: =
= ${maven.checkstyle.header.file}
= Checkstyle needs it to check the existence of the License in =
= your source files. If it can't find this file, it throws an =
= error. =
= A temporary solution is to create an empty LICENSE.txt file. =
= Though, we recommend that you edit this License. =
=================================================================
</ant:echo>
</j:when>
<j:otherwise>
<ant:formatter type="plain"/>
<ant:fail message="${exception}"/>
</j:otherwise>
</j:choose>
</ant:checkstyle>
<doc:jsl
input="${maven.build.dir}/checkstyle-raw-report.xml"
output="checkstyle-report.xml"
stylesheet="${plugin.resources}/checkstyle.jsl"
encoding="${maven.docs.outputencoding}"
outputMode="xml"
prettyPrint="true"/>
</j:if>
</j:if>
</goal>
<goal name="checkstyle:run">
<!-- Create the directory for the checkstyle cache in case it doesn't
exist already -->
<ant:dirname property="maven.checkstyle.cache.dir"
file="${maven.checkstyle.cache.file}"/>
<ant:mkdir dir="${maven.checkstyle.cache.dir}"/>
<ant:echo>Using ${checkstyleProperties} for checkstyle ...</ant:echo>
<ant:checkstyle
config="${checkstyleProperties}"
failOnViolation="${maven.checkstyle.fail.on.violation}">
<property key="checkstyle.header.file"
file="${maven.checkstyle.header.file}"/>
<property key="checkstyle.cache.file"
file="${maven.checkstyle.cache.file}"/>
<ant:fileset dir="${pom.build.sourceDirectory}"
includes="${maven.checkstyle.includes}"
excludes="${maven.checkstyle.excludes}">
<!-- FIXME: This is a bad cut and paste -->
<!-- handle source modifications -->
<j:forEach var="sm" items="${pom.build.sourceModifications}">
<ant:available property="classPresent" classname="${sm.className}"/>
<j:if test="${classPresent != 'true'}">
<j:forEach var="exclude" items="${sm.excludes}">
<ant:exclude name="${exclude}"/>
</j:forEach>
<j:forEach var="include" items="${sm.includes}">
<ant:include name="${include}"/>
</j:forEach>
</j:if>
</j:forEach>
</ant:fileset>
<ant:classpath>
<ant:path refid="maven.dependency.classpath"/>
<ant:pathelement path="${maven.build.dest}"/>
</ant:classpath>
<ant:formatter type="xml"
toFile="${maven.build.dir}/checkstyle-raw-report.xml"/>
<j:choose>
<j:when test="${maven.checkstyle.usefile}">
<ant:formatter type="plain"
toFile="${maven.build.dir}/checkstyle-raw-report.txt"/>
</j:when>
<j:otherwise>
<ant:formatter type="plain"/>
</j:otherwise>
</j:choose>
</ant:checkstyle>
<doc:jsl
input="${maven.build.dir}/checkstyle-raw-report.xml"
output="checkstyle-report.xml"
stylesheet="${plugin.resources}/checkstyle.jsl"
encoding="${maven.docs.outputencoding}"
outputMode="xml"
prettyPrint="true"/>
</goal>
+4
View File
@@ -9,6 +9,10 @@
<body>
<release version="2.2" date="in CVS">
<action dev="vmassol" type="fix">
Prevent projects who do not use the head check from failing if they
don't provide a license file.
</action>
<action dev="vmassol" type="update">
Upgraded to Checkstyle 3.2.
</action>