Author: dennisl
Date: Tue Nov 4 22:02:20 2014
New Revision: 1636753
URL: http://svn.apache.org/r1636753
Log:
[RAT-61] List files with unapproved licenses in Maven output
Added:
creadur/rat/trunk/apache-rat-core/src/main/resources/org/apache/rat/unapproved-licenses.xsl
- copied, changed from r1636670,
creadur/rat/trunk/apache-rat-core/src/main/resources/org/apache/rat/plain-rat.xsl
Modified:
creadur/rat/trunk/RELEASE_NOTES.txt
creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Defaults.java
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatReportMojo.java
Modified: creadur/rat/trunk/RELEASE_NOTES.txt
URL:
http://svn.apache.org/viewvc/creadur/rat/trunk/RELEASE_NOTES.txt?rev=1636753&r1=1636752&r2=1636753&view=diff
==============================================================================
--- creadur/rat/trunk/RELEASE_NOTES.txt (original)
+++ creadur/rat/trunk/RELEASE_NOTES.txt Tue Nov 4 22:02:20 2014
@@ -13,6 +13,7 @@ Rat 0.12 (SNAPSHOT)
* [RAT-175] - SourceCodeManagementSystems.hasIgnoreFile() should return
boolean
* [RAT-177] - final arrays should be private
Improvement
+ * [RAT-61] - List files with unapproved licenses in Maven output
* [RAT-170] - RAT should use itself during build and site generation
* [RAT-181] - BinaryGuesser should treat *.truststore as binary
* [RAT-184] - Add DEPENDENCIES to the list of ignored files in NoteGuesser.
Modified:
creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Defaults.java
URL:
http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Defaults.java?rev=1636753&r1=1636752&r2=1636753&view=diff
==============================================================================
---
creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Defaults.java
(original)
+++
creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Defaults.java
Tue Nov 4 22:02:20 2014
@@ -67,12 +67,18 @@ public class Defaults {
new CDDL1License()));
public static final String PLAIN_STYLESHEET =
"org/apache/rat/plain-rat.xsl";
-
+ public static final String UNAPPROVED_LICENSES_STYLESHEET =
"org/apache/rat/unapproved-licenses.xsl";
+
public static InputStream getPlainStyleSheet() {
InputStream result =
Defaults.class.getClassLoader().getResourceAsStream(Defaults.PLAIN_STYLESHEET);
return result;
}
+ public static InputStream getUnapprovedLicensesStyleSheet() {
+ InputStream result =
Defaults.class.getClassLoader().getResourceAsStream(Defaults.UNAPPROVED_LICENSES_STYLESHEET);
+ return result;
+ }
+
public static InputStream getDefaultStyleSheet() {
InputStream result = getPlainStyleSheet();
return result;
Copied:
creadur/rat/trunk/apache-rat-core/src/main/resources/org/apache/rat/unapproved-licenses.xsl
(from r1636670,
creadur/rat/trunk/apache-rat-core/src/main/resources/org/apache/rat/plain-rat.xsl)
URL:
http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/main/resources/org/apache/rat/unapproved-licenses.xsl?p2=creadur/rat/trunk/apache-rat-core/src/main/resources/org/apache/rat/unapproved-licenses.xsl&p1=creadur/rat/trunk/apache-rat-core/src/main/resources/org/apache/rat/plain-rat.xsl&r1=1636670&r2=1636753&rev=1636753&view=diff
==============================================================================
---
creadur/rat/trunk/apache-rat-core/src/main/resources/org/apache/rat/plain-rat.xsl
(original)
+++
creadur/rat/trunk/apache-rat-core/src/main/resources/org/apache/rat/unapproved-licenses.xsl
Tue Nov 4 22:02:20 2014
@@ -20,72 +20,12 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='text'/>
-<xsl:template match='/'>
-*****************************************************
-Summary
--------
-Generated at: <xsl:value-of select='rat-report/@timestamp'/>
-Notes: <xsl:value-of
select='count(descendant::type[attribute::name="notice"])'/>
-Binaries: <xsl:value-of
select='count(descendant::type[attribute::name="binary"])'/>
-Archives: <xsl:value-of
select='count(descendant::type[attribute::name="archive"])'/>
-Standards: <xsl:value-of
select='count(descendant::type[attribute::name="standard"])'/>
-
-Apache Licensed: <xsl:value-of
select='count(descendant::header-type[attribute::name="AL "])'/>
-Generated Documents: <xsl:value-of
select='count(descendant::header-type[attribute::name="GEN "])'/>
-
-JavaDocs are generated and so license header is optional
-Generated files do not required license headers
-
-<xsl:value-of
select='count(descendant::header-type[attribute::name="?????"])'/> Unknown
Licenses
-
-*******************************
-
-Unapproved licenses:
-
+<xsl:template match='/'>Files with unapproved licenses:
<xsl:for-each select='descendant::resource[license-approval/@name="false"]'>
<xsl:text> </xsl:text>
<xsl:value-of select='@name'/>
<xsl:text>
</xsl:text>
</xsl:for-each>
-*******************************
-
-Archives:
-<xsl:for-each select='descendant::resource[type/@name="archive"]'>
- + <xsl:value-of select='@name'/>
- <xsl:text>
- </xsl:text>
- </xsl:for-each>
-*****************************************************
- Files with Apache License headers will be marked AL
- Binary files (which do not require AL headers) will be marked B
- Compressed archives will be marked A
- Notices, licenses etc will be marked N
- <xsl:for-each select='descendant::resource'>
- <xsl:choose>
- <xsl:when test='license-approval/@name="false"'>!</xsl:when>
- <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test='type/@name="notice"'>N </xsl:when>
- <xsl:when test='type/@name="archive"'>A </xsl:when>
- <xsl:when test='type/@name="binary"'>B </xsl:when>
- <xsl:when test='type/@name="standard"'><xsl:value-of
select='header-type/@name'/></xsl:when>
- <xsl:otherwise>!!!!!</xsl:otherwise>
- </xsl:choose>
- <xsl:text> </xsl:text>
- <xsl:value-of select='@name'/>
- <xsl:text>
- </xsl:text>
- </xsl:for-each>
-*****************************************************
- Printing headers for files without AL header...
-
- <xsl:for-each select='descendant::resource[header-type/@name="?????"]'>
-=======================================================================
-==<xsl:value-of select='@name'/>
-=======================================================================
-<xsl:value-of select='header-sample'/>
-</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Modified:
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
URL:
http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java?rev=1636753&r1=1636752&r2=1636753&view=diff
==============================================================================
---
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
(original)
+++
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
Tue Nov 4 22:02:20 2014
@@ -40,6 +40,8 @@ import javax.xml.transform.TransformerCo
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.io.Writer;
import java.lang.reflect.UndeclaredThrowableException;
import java.util.ArrayList;
@@ -378,6 +380,63 @@ public abstract class AbstractRatMojo ex
}
/**
+ * Creates the report as a string.
+ *
+ * @param styleSheet The style sheet to use when formatting the report
+ * @throws MojoFailureException
+ * An error in the plugin configuration was detected.
+ * @throws MojoExecutionException
+ * An error occurred while creating the report.
+ * @return Report contents
+ */
+ protected String createReport( InputStream styleSheet )
+ throws MojoExecutionException, MojoFailureException
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = null;
+ try
+ {
+ pw = new PrintWriter( sw );
+ createReport( new PrintWriter( sw ), styleSheet );
+ final String result = sw.toString();
+ pw.close();
+ pw = null;
+ sw.close();
+ sw = null;
+ return result;
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
+ finally
+ {
+ if ( pw != null )
+ {
+ try
+ {
+ pw.close();
+ }
+ catch ( Throwable t )
+ {
+ // Ignore me
+ }
+ }
+ if ( sw != null )
+ {
+ try
+ {
+ sw.close();
+ }
+ catch ( Throwable t )
+ {
+ // Ignore me
+ }
+ }
+ }
+ }
+
+ /**
* Writes the report to the given stream.
*
* @param out
Modified:
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
URL:
http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java?rev=1636753&r1=1636752&r2=1636753&view=diff
==============================================================================
---
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
(original)
+++
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
Tue Nov 4 22:02:20 2014
@@ -89,6 +89,15 @@ public class RatCheckMojo extends Abstra
@Parameter(property = "rat.ignoreErrors", defaultValue = "false")
private boolean ignoreErrors;
+ /**
+ * Whether to output the names of files that have unapproved licenses to
the
+ * console.
+ *
+ * @since 0.12
+ */
+ @Parameter(property = "rat.consoleOutput", defaultValue = "false")
+ private boolean consoleOutput;
+
private ClaimStatistic getRawReport()
throws MojoExecutionException, MojoFailureException
{
@@ -181,6 +190,18 @@ public class RatCheckMojo extends Abstra
getLog().info("Rat check: Summary of files. Unapproved: " +
statistics.getNumUnApproved() + " unknown: " + statistics.getNumUnknown() + "
generated: " + statistics.getNumGenerated() + " approved: " +
statistics.getNumApproved() + " licence.");
if ( numUnapprovedLicenses < statistics.getNumUnApproved() )
{
+ if ( consoleOutput )
+ {
+ try
+ {
+ getLog().warn( createReport(
Defaults.getUnapprovedLicensesStyleSheet() ).trim() );
+ }
+ catch( MojoExecutionException e )
+ {
+ getLog().warn( "Unable to print the files with unapproved
licenses to the console." );
+ }
+ }
+
final String seeReport = " See RAT report in: " + reportFile;
if ( !ignoreErrors )
{
Modified:
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatReportMojo.java
URL:
http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatReportMojo.java?rev=1636753&r1=1636752&r2=1636753&view=diff
==============================================================================
---
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatReportMojo.java
(original)
+++
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatReportMojo.java
Tue Nov 4 22:02:20 2014
@@ -22,8 +22,6 @@ package org.apache.rat.mp;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Iterator;
@@ -129,61 +127,6 @@ public class RatReportMojo extends Abstr
}
/**
- * Creates the report as a string. Currently, this string will be embedded
verbatimly into the report document.
- *
- * @throws MojoFailureException
- * An error in the plugin configuration was detected.
- * @throws MojoExecutionException
- * An error occurred while creating the report.
- * @return Report contents
- */
- private String createReport() throws MojoExecutionException,
MojoFailureException
- {
- StringWriter sw = new StringWriter();
- PrintWriter pw = null;
- try
- {
- pw = new PrintWriter( sw );
- createReport( new PrintWriter( sw ),
Defaults.getDefaultStyleSheet() );
- final String result = sw.toString();
- pw.close();
- pw = null;
- sw.close();
- sw = null;
- return result;
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( e.getMessage(), e );
- }
- finally
- {
- if ( pw != null )
- {
- try
- {
- pw.close();
- }
- catch ( Throwable t )
- {
- // Ignore me
- }
- }
- if ( sw != null )
- {
- try
- {
- sw.close();
- }
- catch ( Throwable t )
- {
- // Ignore me
- }
- }
- }
- }
-
- /**
* Called from Maven to invoke the plugin.
*
* @throws MojoFailureException
@@ -313,7 +256,7 @@ public class RatReportMojo extends Abstr
sink.verbatim( true );
try
{
- sink.text( createReport() );
+ sink.text( createReport( Defaults.getDefaultStyleSheet() ) );
}
catch ( MojoExecutionException e )
{