NUTCH-2818 Fix Apache Rat task to check sources for license headers
- automatize download of Apache Rat jar file
- write report to build/apache-rat-report.txt
diff --git a/build.xml b/build.xml
index bbe4aaf..67a3aa2 100644
--- a/build.xml
+++ b/build.xml
@@ -15,7 +15,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project name="${name}" default="runtime" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+<project name="${name}" default="runtime"
+ xmlns:ivy="antlib:org.apache.ivy.ant"
+ xmlns:artifact="antlib:org.apache.maven.artifact.ant"
+ xmlns:rat="antlib:org.apache.rat.anttasks"
+ xmlns="antlib:org.apache.tools.ant">
<!-- Load all the default properties, and any the user wants -->
<!-- to contribute (without having to type -D or edit this file -->
@@ -33,10 +37,16 @@
<property name="maven-javadoc-jar" value="${release.dir}/${artifactId}-${version}-javadoc.jar" />
<property name="maven-sources-jar" value="${release.dir}/${artifactId}-${version}-sources.jar" />
+ <property name="dependency-check.home" value="${ivy.dir}/dependency-check-ant/"/>
+
<property name="spotbugs.version" value="4.1.1" />
<property name="spotbugs.home" value="${basedir}/lib/spotbugs-${spotbugs.version}" />
<property name="spotbugs.jar" value="${spotbugs.home}/lib/spotbugs-ant.jar" />
+ <property name="apache-rat.version" value="0.13" />
+ <property name="apache-rat.home" value="${ivy.dir}/apache-rat-${apache-rat.version}" />
+ <property name="apache-rat.jar" value="${apache-rat.home}/apache-rat-${apache-rat.version}.jar" />
+
<!-- the normal classpath -->
<path id="classpath">
<pathelement location="${build.classes}"/>
@@ -633,7 +643,6 @@
<!-- https://jeremylong.github.io/DependencyCheck/dependency-check-ant/index.html -->
<!-- get http://dl.bintray.com/jeremy-long/owasp/dependency-check-ant-3.3.2-release.zip -->
<!-- and unzip in directory ./ivy/ -->
- <property name="dependency-check.home" value="${ivy.dir}/dependency-check-ant/"/>
<path id="dependency-check.path">
<pathelement location="${dependency-check.home}/dependency-check-ant.jar"/>
<fileset dir="${dependency-check.home}/lib" erroronmissingdir="false">
@@ -1003,17 +1012,35 @@
<!-- ================================================================== -->
<!-- RAT targets -->
<!-- ================================================================== -->
- <target name="rat-sources-typedef" description="--> run RAT antlib task">
- <typedef resource="org/apache/rat/anttasks/antlib.xml" >
- <classpath>
- <fileset dir="." includes="rat*.jar"/>
- </classpath>
- </typedef>
+ <target name="apache-rat-download" description="--> download Apache Rat jar">
+ <available file="${apache-rat.jar}" property="apache-rat.jar.found"/>
+ <antcall target="apache-rat-download-unchecked"/>
</target>
- <target name="rat-sources" depends="rat-sources-typedef"
+ <target name="apache-rat-download-unchecked" unless="apache-rat.jar.found"
+ description="--> downloads the Apache Rat jar">
+ <get src="https://www.apache.org/dist/creadur/apache-rat-${apache-rat.version}/apache-rat-${apache-rat.version}-bin.tar.gz"
+ dest="${ivy.dir}/apache-rat-${apache-rat.version}-bin.tar.gz" usetimestamp="false" />
+
+ <untar src="${ivy.dir}/apache-rat-${apache-rat.version}-bin.tar.gz"
+ dest="${ivy.dir}/" compression="gzip">
+ </untar>
+
+ <delete file="${ivy.dir}/apache-rat-${apache-rat.version}-bin.tar.gz" />
+ </target>
+
+ <taskdef
+ uri="antlib:org.apache.rat.anttasks"
+ resource="org/apache/rat/anttasks/antlib.xml">
+ <classpath>
+ <pathelement location="${apache-rat.jar}" />
+ </classpath>
+ </taskdef>
+
+ <target name="rat-sources" depends="init, apache-rat-download"
description="--> runs RAT tasks over src/java">
- <rat:report xmlns:rat="antlib:org.apache.rat.anttasks">
+ <rat:report
+ reportFile="${build.dir}/apache-rat-report.txt">
<fileset dir="src">
<include name="java/**/*"/>
<include name="plugin/**/src/**/*"/>