You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2013/10/19 19:20:21 UTC
svn commit: r1533791 - in /lucene/dev/trunk/lucene/tools: custom-tasks.xml
src/java/org/apache/lucene/validation/LicenseCheckTask.java
Author: markrmiller
Date: Sat Oct 19 17:20:20 2013
New Revision: 1533791
URL: http://svn.apache.org/r1533791
Log:
LUCENE-5295: Allow the license checker to optionally avoid check sum comparisons.
Modified:
lucene/dev/trunk/lucene/tools/custom-tasks.xml
lucene/dev/trunk/lucene/tools/src/java/org/apache/lucene/validation/LicenseCheckTask.java
Modified: lucene/dev/trunk/lucene/tools/custom-tasks.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/tools/custom-tasks.xml?rev=1533791&r1=1533790&r2=1533791&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/tools/custom-tasks.xml (original)
+++ lucene/dev/trunk/lucene/tools/custom-tasks.xml Sat Oct 19 17:20:20 2013
@@ -59,7 +59,7 @@
<sequential>
<!-- LICENSE and NOTICE verification macro. -->
<echo>License check under: @{dir}</echo>
- <licenses licenseDirectory="@{licensedir}" skipSnapshotsChecksum="${skipSnapshotsChecksum}">
+ <licenses licenseDirectory="@{licensedir}" skipChecksum="${skipChecksum}" skipSnapshotsChecksum="${skipSnapshotsChecksum}">
<fileset dir="@{dir}">
<include name="**/*.jar" />
<!-- Speed up scanning a bit. -->
Modified: lucene/dev/trunk/lucene/tools/src/java/org/apache/lucene/validation/LicenseCheckTask.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/tools/src/java/org/apache/lucene/validation/LicenseCheckTask.java?rev=1533791&r1=1533790&r2=1533791&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/tools/src/java/org/apache/lucene/validation/LicenseCheckTask.java (original)
+++ lucene/dev/trunk/lucene/tools/src/java/org/apache/lucene/validation/LicenseCheckTask.java Sat Oct 19 17:20:20 2013
@@ -55,6 +55,7 @@ public class LicenseCheckTask extends Ta
private static final int CHECKSUM_BYTE_MASK = 0xFF;
private boolean skipSnapshotsChecksum;
+ private boolean skipChecksum;
/**
* All JAR files to check.
@@ -109,6 +110,10 @@ public class LicenseCheckTask extends Ta
public void setSkipSnapshotsChecksum(boolean skipSnapshotsChecksum) {
this.skipSnapshotsChecksum = skipSnapshotsChecksum;
}
+
+ public void setSkipChecksum(boolean skipChecksum) {
+ this.skipChecksum = skipChecksum;
+ }
/**
* Execute the task.
@@ -119,7 +124,12 @@ public class LicenseCheckTask extends Ta
throw new BuildException("Expected an embedded <licenseMapper>.");
}
- if (skipSnapshotsChecksum) log("Skipping checksum for SNAPSHOT dependencies", Project.MSG_INFO);
+ if (skipChecksum) {
+ log("Skipping checksum verification for dependencies", Project.MSG_INFO);
+ } else if (skipSnapshotsChecksum) {
+ log("Skipping checksum for SNAPSHOT dependencies", Project.MSG_INFO);
+ }
+
jarResources.setProject(getProject());
processJars();
@@ -168,53 +178,60 @@ public class LicenseCheckTask extends Ta
private boolean checkJarFile(File jarFile) {
log("Scanning: " + jarFile.getPath(), verboseLevel);
- if (!skipSnapshotsChecksum || !jarFile.getName().contains("-SNAPSHOT")) {
- // validate the jar matches against our expected hash
- final File checksumFile = new File(licenseDirectory,
- jarFile.getName() + "." + CHECKSUM_TYPE);
- if (! (checksumFile.exists() && checksumFile.canRead()) ) {
- log("MISSING " +CHECKSUM_TYPE+ " checksum file for: " + jarFile.getPath(), Project.MSG_ERR);
- log("EXPECTED " +CHECKSUM_TYPE+ " checksum file : " + checksumFile.getPath(), Project.MSG_ERR);
- this.failures = true;
- return false;
- } else {
- final String expectedChecksum = readChecksumFile(checksumFile);
- try {
- final MessageDigest md = MessageDigest.getInstance(CHECKSUM_TYPE);
- byte[] buf = new byte[CHECKSUM_BUFFER_SIZE];
+ if (!skipChecksum) {
+ if (!skipSnapshotsChecksum || !jarFile.getName().contains("-SNAPSHOT")) {
+ // validate the jar matches against our expected hash
+ final File checksumFile = new File(licenseDirectory, jarFile.getName()
+ + "." + CHECKSUM_TYPE);
+ if (!(checksumFile.exists() && checksumFile.canRead())) {
+ log("MISSING " + CHECKSUM_TYPE + " checksum file for: "
+ + jarFile.getPath(), Project.MSG_ERR);
+ log("EXPECTED " + CHECKSUM_TYPE + " checksum file : "
+ + checksumFile.getPath(), Project.MSG_ERR);
+ this.failures = true;
+ return false;
+ } else {
+ final String expectedChecksum = readChecksumFile(checksumFile);
try {
- FileInputStream fis = new FileInputStream(jarFile);
+ final MessageDigest md = MessageDigest.getInstance(CHECKSUM_TYPE);
+ byte[] buf = new byte[CHECKSUM_BUFFER_SIZE];
try {
- DigestInputStream dis = new DigestInputStream(fis, md);
+ FileInputStream fis = new FileInputStream(jarFile);
try {
- while (dis.read(buf, 0, CHECKSUM_BUFFER_SIZE) != -1) {
- // NOOP
+ DigestInputStream dis = new DigestInputStream(fis, md);
+ try {
+ while (dis.read(buf, 0, CHECKSUM_BUFFER_SIZE) != -1) {
+ // NOOP
+ }
+ } finally {
+ dis.close();
}
} finally {
- dis.close();
+ fis.close();
}
- } finally {
- fis.close();
+ } catch (IOException ioe) {
+ throw new BuildException("IO error computing checksum of file: "
+ + jarFile, ioe);
}
- } catch (IOException ioe) {
- throw new BuildException("IO error computing checksum of file: " + jarFile, ioe);
- }
- final byte[] checksumBytes = md.digest();
- final String checksum = createChecksumString(checksumBytes);
- if ( ! checksum.equals(expectedChecksum) ) {
- log("CHECKSUM FAILED for " + jarFile.getPath() +
- " (expected: \"" + expectedChecksum + "\" was: \"" + checksum + "\")",
- Project.MSG_ERR);
- this.failures = true;
- return false;
+ final byte[] checksumBytes = md.digest();
+ final String checksum = createChecksumString(checksumBytes);
+ if (!checksum.equals(expectedChecksum)) {
+ log("CHECKSUM FAILED for " + jarFile.getPath() + " (expected: \""
+ + expectedChecksum + "\" was: \"" + checksum + "\")",
+ Project.MSG_ERR);
+ this.failures = true;
+ return false;
+ }
+
+ } catch (NoSuchAlgorithmException ae) {
+ throw new BuildException("Digest type " + CHECKSUM_TYPE
+ + " not supported by your JVM", ae);
}
-
- } catch (NoSuchAlgorithmException ae) {
- throw new BuildException("Digest type " + CHECKSUM_TYPE + " not supported by your JVM", ae);
}
+ } else if (skipSnapshotsChecksum) {
+ log("Skipping jar because it is a SNAPSHOT : "
+ + jarFile.getAbsolutePath(), Project.MSG_INFO);
}
- } else if (skipSnapshotsChecksum) {
- log("Skipping jar because it is a SNAPSHOT : " + jarFile.getAbsolutePath(), Project.MSG_INFO);
}
// Get the expected license path base from the mapper and search for license files.