vmassol     2003/11/12 11:09:07

  Modified:    checkstyle/xdocs changes.xml
               checkstyle plugin.jelly
  Log:
  Prevent projects who do not use the head check from failing if they don't provide a 
license file.
  
  Revision  Changes    Path
  1.14      +4 -0      maven-plugins/checkstyle/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/checkstyle/xdocs/changes.xml,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- changes.xml       10 Nov 2003 11:58:14 -0000      1.13
  +++ changes.xml       12 Nov 2003 19:09:07 -0000      1.14
  @@ -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>
  
  
  
  1.19      +89 -97    maven-plugins/checkstyle/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/maven-plugins/checkstyle/plugin.jelly,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- plugin.jelly      10 Nov 2003 12:14:42 -0000      1.18
  +++ plugin.jelly      12 Nov 2003 19:09:07 -0000      1.19
  @@ -67,120 +67,112 @@
   
     <!--
        ========================================================================
  -       Check if license file is available, display warning if not and sets
  -       the Ant "checkstyleShouldRun" property if the license file is 
  -       available.
  +       Generate a checkstyle report by running checkstyle on the project
  +       source code.
        ========================================================================
     -->
  -  <goal name="checkstyle:license"
  +  <goal name="checkstyle:report"
  +    description="Perform checkstyle checks"
       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:catch var="exception">
  +        <attainGoal name="checkstyle:run"/>
  +      </j:catch>
   
  -    </j:if>
  +      <j:if test="${(exception != null)}">
  +        <j:choose>
  +          <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:fail message="${exception}"/>
  +          </j:otherwise>
  +        </j:choose>
  +      </j:if>
   
  +    </j:if>
  +    
     </goal>
   
  -  <!--
  -     ========================================================================
  -       Generate a checkstyle report by running checkstyle on the project
  -       source code.
  -     ========================================================================
  -  -->
  -  <goal name="checkstyle:report"
  -    description="Perform checkstyle checks"
  -    prereqs="checkstyle:init,checkstyle:license">
  -
  -    <j:if test="${checkstyleShouldRun}">
  +  <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" 
  +    <!-- 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: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: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"/>
  +      <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>
  +      <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>
  +    </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>
  +    <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>
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to