You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by gs...@apache.org on 2011/03/18 19:40:03 UTC
svn commit: r1083010 - in /lucene/dev/trunk: ./ dev-tools/validation/
lucene/ lucene/src/test-framework/org/apache/lucene/validation/ modules/
solr/
Author: gsingers
Date: Fri Mar 18 18:40:02 2011
New Revision: 1083010
URL: http://svn.apache.org/viewvc?rev=1083010&view=rev
Log:
LUCENE-2952: drop dev-tools dependency, move to test framework, split out checking to each area: lucene, modules, solr
Added:
lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/validation/
- copied from r1082535, lucene/dev/trunk/dev-tools/validation/src/main/java/org/apache/lucene/validation/
Removed:
lucene/dev/trunk/dev-tools/validation/
Modified:
lucene/dev/trunk/build.xml
lucene/dev/trunk/common-build.xml
lucene/dev/trunk/lucene/common-build.xml
lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/validation/DependencyChecker.java
lucene/dev/trunk/modules/build.xml
lucene/dev/trunk/solr/common-build.xml
Modified: lucene/dev/trunk/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/build.xml?rev=1083010&r1=1083009&r2=1083010&view=diff
==============================================================================
--- lucene/dev/trunk/build.xml (original)
+++ lucene/dev/trunk/build.xml Fri Mar 18 18:40:02 2011
@@ -28,9 +28,16 @@
</subant>
</sequential>
</target>
-
- <target name="compile" description="Compile Lucene and Solr">
+ <target name="validate" description="Validate dependencies, licenses, etc.">
+ <sequential><subant target="validate" inheritall="false" failonerror="true">
+ <fileset dir="lucene" includes="build.xml" />
+ <fileset dir="modules" includes="build.xml" />
+ <fileset dir="solr" includes="build.xml" />
+ </subant></sequential>
+ </target>
+ <target name="compile" depends="validate" description="Compile Lucene and Solr">
<sequential>
+
<subant target="compile" inheritall="false" failonerror="true">
<fileset dir="lucene" includes="build.xml" />
<fileset dir="modules" includes="build.xml" />
Modified: lucene/dev/trunk/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/common-build.xml?rev=1083010&r1=1083009&r2=1083010&view=diff
==============================================================================
--- lucene/dev/trunk/common-build.xml (original)
+++ lucene/dev/trunk/common-build.xml Fri Mar 18 18:40:02 2011
@@ -17,36 +17,15 @@
<project name="all-common" default="validate" basedir="."
xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
<dirname file="${ant.file.all-common}" property="all.common.dir"/>
- <target name="validate" description="Compile Validation tools" unless="validated">
- <sequential>
- <subant target="validate" inheritall="false" failonerror="true">
- <property name="validated" value="true"/>
- <fileset dir="${all.common.dir}/dev-tools/validation" includes="build.xml" />
- </subant>
- </sequential>
- </target>
- <target name="validate-lucene" description="Compile Validation tools" unless="validated">
- <sequential>
- <subant target="validate-lucene" inheritall="false" failonerror="true">
- <property name="validated" value="true"/>
- <fileset dir="${all.common.dir}/dev-tools/validation" includes="build.xml" />
- </subant>
- </sequential>
- </target>
- <target name="validate-solr" description="Compile Validation tools" unless="validated">
- <sequential>
- <subant target="validate-solr" inheritall="false" failonerror="true">
- <property name="validated" value="true"/>
- <fileset dir="${all.common.dir}/dev-tools/validation" includes="build.xml" />
- </subant>
- </sequential>
- </target>
- <target name="validate-modules" description="Compile Validation tools" unless="validated">
+ <path id="validation.runtime.classpath">
+ <pathelement location="${all.common.dir}/lucene/build/classes/test-framework"/>
+ </path>
+ <target name="compile-test-framework" description="Compile the Test Framework and Validation tools">
<sequential>
- <subant target="validate-modules" inheritall="false" failonerror="true">
- <property name="validated" value="true"/>
- <fileset dir="${all.common.dir}/dev-tools/validation" includes="build.xml" />
+ <subant target="compile-test-framework" inheritall="false" failonerror="true">
+ <fileset dir="${all.common.dir}/lucene" includes="build.xml" />
</subant>
</sequential>
</target>
Modified: lucene/dev/trunk/lucene/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/common-build.xml?rev=1083010&r1=1083009&r2=1083010&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/common-build.xml (original)
+++ lucene/dev/trunk/lucene/common-build.xml Fri Mar 18 18:40:02 2011
@@ -304,7 +304,7 @@
</copy>
</target>
- <target name="compile" depends="validate-lucene, compile-core">
+ <target name="compile" depends="compile-core, validate-lucene">
<!-- convenience target to compile core -->
</target>
@@ -792,4 +792,41 @@
</macrodef>
+ <!-- VALIDATION work -->
+
+ <target name="check-legal-lucene" depends="compile-test-framework">
+ <java classname="org.apache.lucene.validation.DependencyChecker" failonerror="true" fork="true">
+ <classpath>
+ <path refid="validation.runtime.classpath" />
+ </classpath>
+ <!-- TODO: it might be better to just automatically find all directories that contain jar files, but that could take a
+ long time. This should be faster, but we could miss a directory
+ -->
+ <!-- Lucene -->
+ <arg value="-c" />
+ <arg value="${basedir}/lib" />
+ <arg value="-c" />
+ <arg value="${basedir}/contrib/ant/lib" />
+ <!-- BDB libs are downloaded, don't check them -->
+ <!--<arg value="-c" />
+ <arg value="${toplevel.dir}/lucene/contrib/db/bdb/lib" />
+ <arg value="-c" />
+ <arg value="${toplevel.dir}/lucene/contrib/db/bdb-je/lib" />-->
+ <arg value="-c" />
+ <arg value="${basedir}/contrib/lucli/lib" />
+ <arg value="-c" />
+ <arg value="${basedir}/contrib/queries/lib" />
+ </java>
+ </target>
+
+ <target name="check-legal" depends="check-legal-lucene"/>
+
+ <target name="validate-lucene" depends="check-legal-lucene" unless="validated-lucene"/>
+
+
+ <!-- Generic placeholder target for if we add other validation tasks -->
+ <target name="validate" depends="validate-lucene"/>
+
+
+
</project>
Modified: lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/validation/DependencyChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/validation/DependencyChecker.java?rev=1083010&r1=1082535&r2=1083010&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/validation/DependencyChecker.java (original)
+++ lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/validation/DependencyChecker.java Fri Mar 18 18:40:02 2011
@@ -16,20 +16,15 @@ package org.apache.lucene.validation;
* limitations under the License.
*/
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.cli.PosixParser;
-
import java.io.File;
import java.io.FileFilter;
import java.io.FileWriter;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -46,161 +41,157 @@ public class DependencyChecker {
}
public static void main(String[] args) throws IOException {
- Options options = new Options();
- Option dumpOpt = OptionBuilder.withLongOpt("dump").hasArg().withDescription("Print the JAR and it's license to a file. Arg is the name of the file").create("d");
- options.addOption(dumpOpt);
- Option checkOpt = OptionBuilder.withLongOpt("check").isRequired().hasArgs().withDescription("Check that every jar in the specified dir has an associated license file").create("c");
- options.addOption(checkOpt);
- CommandLine cmdLine = null;
- try {
- PosixParser parser = new PosixParser();
- cmdLine = parser.parse(options, args);
-
- boolean dump = cmdLine.hasOption(dumpOpt.getOpt());
- FileWriter writer = null;
- if (dump == true) {
- File out = new File(cmdLine.getOptionValue(dumpOpt.getOpt()));
- System.out.println("Dumping to " + out);
- writer = new FileWriter(out);
+ String dumpFile = null;
+ List<String> dirs = new ArrayList<String>();
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].equalsIgnoreCase("--dump") || args[i].equalsIgnoreCase("-d")) {
+ dumpFile = args[++i];
+
+ } else if (args[i].equalsIgnoreCase("--check") || args[i].equalsIgnoreCase("-c")) {
+ dirs.add(args[++i]);
}
- boolean check = cmdLine.hasOption(checkOpt.getOpt());
- //TODO: put in NOTICE checks
- if (check) {
- String[] checkDirs = cmdLine.getOptionValues(checkOpt.getOpt());
- for (int k = 0; k < checkDirs.length; k++) {
- String checkDir = checkDirs[k];
- File dir = new File(checkDir);
- if (dir.exists()) {
- System.out.println("----------------------");
- System.out.println("Starting on dir: " + dir);
- int numFailed = 0;
- File[] list = dir.listFiles();
- File[] licFiles = dir.listFiles(new FileFilter() {
- public boolean accept(File file) {
- return file.getName().indexOf("-LICENSE") != -1 && file.getName().endsWith(".txt");//check for a consistent end, so that we aren't fooled by emacs ~ files or other temp files
- }
- });
- File[] noticeFiles = dir.listFiles(new FileFilter() {
- public boolean accept(File file) {
- return file.getName().indexOf("-NOTICE") != -1 && file.getName().endsWith(".txt");
- }
- });
- File[] jarFiles = dir.listFiles(new FileFilter() {
- public boolean accept(File file) {
- return file.getName().endsWith(".jar");
- }
- });
- if (licFiles.length == 0 && jarFiles.length != 0) {
- System.out.println("No license files found: " + dir);
- numFailed++;
- }
- if (jarFiles.length != licFiles.length) {
- System.out.println("WARNING: There are missing LICENSE files in: " + dir + " Jar file count: " + jarFiles.length + " License Count: " + licFiles.length);
- printDiffs(jarFiles, licFiles);
- numFailed++;
- }
- if (jarFiles.length != noticeFiles.length) {
- System.out.println("WARNING: There may be missing NOTICE files in: " + dir + ". Note, not all files require a NOTICE. Jar file count: " + jarFiles.length + " Notice Count: " + noticeFiles.length);
- //printDiffs(jarFiles, noticeFiles);
- }
- Map<String, UpdateableInt> licenseNames = new HashMap<String, UpdateableInt>();
- for (int i = 0; i < licFiles.length; i++) {
- licenseNames.put(licFiles[i].getName(), new UpdateableInt());
- }
- Map<String, UpdateableInt> noticeNames = new HashMap<String, UpdateableInt>();
- for (int i = 0; i < noticeFiles.length; i++) {
- noticeNames.put(noticeFiles[i].getName(), new UpdateableInt());
- }
+ }
- for (int i = 0; i < list.length; i++) {
- File file = list[i];
- String fileName = file.getName();
- if (fileName.endsWith(".jar") && excludes.contains(fileName) == false) {
- File licFile = getLicenseFile(file, licenseNames);
- if (licFile != null && licFile.exists()) {
- String licName = licFile.getName();
- LicenseType[] types = getLicenseTypes(licName);
- if (types != null && types.length > 0) {
- for (int j = 0; j < types.length; j++) {
- LicenseType type = types[j];
- if (dump == true) {
- writer.write(file.getName() + "," + type.getDisplay() + LINE_SEPARATOR);
- }
- if (type.isNoticeRequired()) {
- File noticeFile = getNoticeFile(file, noticeNames);
- if (noticeFile != null && noticeFile.exists()) {
-
- } else {
- System.out.println("!!!!!! Missing NOTICE file for " + file + " and license type: " + type.getDisplay());
- if (dump){
- writer.write("Missing NOTICE file for " + file + LINE_SEPARATOR);
- }
- numFailed++;
- }
+ FileWriter writer = null;
+ boolean dump = false;
+ if (dumpFile != null) {
+ File out = new File(dumpFile);
+ System.out.println("Dumping to " + out);
+ writer = new FileWriter(out);
+ dump = true;
+ }
+ //TODO: put in NOTICE checks
+ for (String checkDir : dirs) {
+ File dir = new File(checkDir);
+ if (dir.exists()) {
+ System.out.println("----------------------");
+ System.out.println("Starting on dir: " + dir);
+ int numFailed = 0;
+ File[] list = dir.listFiles();
+ File[] licFiles = dir.listFiles(new FileFilter() {
+ public boolean accept(File file) {
+ return file.getName().indexOf("-LICENSE") != -1 && file.getName().endsWith(".txt");//check for a consistent end, so that we aren't fooled by emacs ~ files or other temp files
+ }
+ });
+ File[] noticeFiles = dir.listFiles(new FileFilter() {
+ public boolean accept(File file) {
+ return file.getName().indexOf("-NOTICE") != -1 && file.getName().endsWith(".txt");
+ }
+ });
+ File[] jarFiles = dir.listFiles(new FileFilter() {
+ public boolean accept(File file) {
+ return file.getName().endsWith(".jar");
+ }
+ });
+ if (licFiles.length == 0 && jarFiles.length != 0) {
+ System.out.println("No license files found: " + dir);
+ numFailed++;
+ }
+ if (jarFiles.length != licFiles.length) {
+ System.out.println("WARNING: There are missing LICENSE files in: " + dir + " Jar file count: " + jarFiles.length + " License Count: " + licFiles.length);
+ printDiffs(jarFiles, licFiles);
+ numFailed++;
+ }
+ if (jarFiles.length != noticeFiles.length) {
+ System.out.println("WARNING: There may be missing NOTICE files in: " + dir + ". Note, not all files require a NOTICE. Jar file count: " + jarFiles.length + " Notice Count: " + noticeFiles.length);
+ //printDiffs(jarFiles, noticeFiles);
+ }
+ Map<String, UpdateableInt> licenseNames = new HashMap<String, UpdateableInt>();
+ for (int i = 0; i < licFiles.length; i++) {
+ licenseNames.put(licFiles[i].getName(), new UpdateableInt());
+ }
+ Map<String, UpdateableInt> noticeNames = new HashMap<String, UpdateableInt>();
+ for (int i = 0; i < noticeFiles.length; i++) {
+ noticeNames.put(noticeFiles[i].getName(), new UpdateableInt());
+ }
+
+
+ for (int i = 0; i < list.length; i++) {
+ File file = list[i];
+ String fileName = file.getName();
+ if (fileName.endsWith(".jar") && excludes.contains(fileName) == false) {
+ File licFile = getLicenseFile(file, licenseNames);
+ if (licFile != null && licFile.exists()) {
+ String licName = licFile.getName();
+ LicenseType[] types = getLicenseTypes(licName);
+ if (types != null && types.length > 0) {
+ for (int j = 0; j < types.length; j++) {
+ LicenseType type = types[j];
+ if (dump == true) {
+ writer.write(file.getName() + "," + type.getDisplay() + LINE_SEPARATOR);
+ }
+ if (type.isNoticeRequired()) {
+ File noticeFile = getNoticeFile(file, noticeNames);
+ if (noticeFile != null && noticeFile.exists()) {
+
+ } else {
+ System.out.println("!!!!!! Missing NOTICE file for " + file + " and license type: " + type.getDisplay());
+ if (dump) {
+ writer.write("Missing NOTICE file for " + file + LINE_SEPARATOR);
}
+ numFailed++;
}
- } else {
- System.out.println("!!!!!! Couldn't determine license type for file: " + file);
- if (dump == true) {
- writer.write("Invalid license for file: " + file + LINE_SEPARATOR);
- }
- numFailed++;
}
- } else {
- System.out.println("!!!!!!! Couldn't get license file for " + file);
- if (dump == true) {
- writer.write("Couldn't get license file for " + file + LINE_SEPARATOR);
- }
- numFailed++;
}
+ } else {
+ System.out.println("!!!!!! Couldn't determine license type for file: " + file);
+ if (dump == true) {
+ writer.write("Invalid license for file: " + file + LINE_SEPARATOR);
+ }
+ numFailed++;
}
+ } else {
+ System.out.println("!!!!!!! Couldn't get license file for " + file);
+ if (dump == true) {
+ writer.write("Couldn't get license file for " + file + LINE_SEPARATOR);
+ }
+ numFailed++;
}
- if (dump == true) {
- writer.write(LINE_SEPARATOR + LINE_SEPARATOR);
- writer.write("Other Licenses (installer, javascript, etc." + LINE_SEPARATOR);
- }
+ }
+ }
+ if (dump == true) {
+ writer.write(LINE_SEPARATOR + LINE_SEPARATOR);
+ writer.write("Other Licenses (installer, javascript, etc." + LINE_SEPARATOR);
+ }
- if (dump == true) {
- for (Map.Entry<String, UpdateableInt> entry : licenseNames.entrySet()) {
- if (entry.getValue().theInt == 0) {
- LicenseType[] types = getLicenseTypes(entry.getKey());
- if (types != null && types.length > 0) {
- for (int i = 0; i < types.length; i++) {
- writer.write(entry.getKey() + "," + types[i].getDisplay() + LINE_SEPARATOR);
- }
- } else {
- System.out.println("Couldn't determine license for: " + entry.getKey());
- }
+ if (dump == true) {
+ for (Map.Entry<String, UpdateableInt> entry : licenseNames.entrySet()) {
+ if (entry.getValue().theInt == 0) {
+ LicenseType[] types = getLicenseTypes(entry.getKey());
+ if (types != null && types.length > 0) {
+ for (int i = 0; i < types.length; i++) {
+ writer.write(entry.getKey() + "," + types[i].getDisplay() + LINE_SEPARATOR);
}
+ } else {
+ System.out.println("Couldn't determine license for: " + entry.getKey());
}
}
- if (writer != null) {
- writer.close();
- }
- if (numFailed > 0) {
- System.out.println("At least one file does not have a license, or it's license name is not in the proper format. See the logs.");
- System.exit(-1);
- } else {
- System.out.println("Found a license for every file in " + dir);
- }
- } else {
- System.out.println("Could not find directory:" + dir);
}
}
-
+ if (writer != null) {
+ writer.close();
+ }
+ if (numFailed > 0) {
+ System.out.println("At least one file does not have a license, or it's license name is not in the proper format. See the logs.");
+ System.exit(-1);
+ } else {
+ System.out.println("Found a license for every file in " + dir);
+ }
+ } else {
+ System.out.println("Could not find directory:" + dir);
}
- } catch (ParseException exp) {
- exp.printStackTrace(System.err);
}
}
+
/**
* Sort the two lists and then print them out for visual comparison
*
* @param left
* @param right
*/
+
private static void printDiffs(File[] left, File[] right) {
Arrays.sort(left);
Arrays.sort(right);
@@ -215,8 +206,8 @@ public class DependencyChecker {
}
bldr.append(LINE_SEPARATOR);
}
- if (i < right.length){
- for (; i < right.length; i++){
+ if (i < right.length) {
+ for (; i < right.length; i++) {
bldr.append("--- N/A ---\t\t\t").append(right[i]).append(LINE_SEPARATOR);
}
}
Modified: lucene/dev/trunk/modules/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/build.xml?rev=1083010&r1=1083009&r2=1083010&view=diff
==============================================================================
--- lucene/dev/trunk/modules/build.xml (original)
+++ lucene/dev/trunk/modules/build.xml Fri Mar 18 18:40:02 2011
@@ -64,6 +64,25 @@
</subant>
</sequential>
</target>
+ <target name="validate" depends="validate-modules"/>
+ <target name="validate-modules" depends="check-legal-modules" unless="validated-modules"/>
+ <target name="check-legal-modules" depends="compile-test-framework">
+ <java classname="org.apache.lucene.validation.DependencyChecker" failonerror="true" fork="true">
+ <classpath>
+ <path refid="validation.runtime.classpath" />
+ </classpath>
+ <!-- TODO: it might be better to just automatically find all directories that contain jar files, but that could take a
+ long time. This should be faster, but we could miss a directory
+ -->
+ <!-- Modules -->
+ <arg value="-c" />
+ <arg value="${basedir}/analysis/icu/lib" />
+ <arg value="-c" />
+ <arg value="${basedir}/analysis/phonetic/lib" />
+ <arg value="-c" />
+ <arg value="${basedir}/benchmark/lib" />
+ </java>
+ </target>
<target name="clean" description="Clean all modules">
<sequential>
Modified: lucene/dev/trunk/solr/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/common-build.xml?rev=1083010&r1=1083009&r2=1083010&view=diff
==============================================================================
--- lucene/dev/trunk/solr/common-build.xml (original)
+++ lucene/dev/trunk/solr/common-build.xml Fri Mar 18 18:40:02 2011
@@ -573,5 +573,40 @@
##########################################################################
</fail>
</target>
+ <!-- Validation -->
+ <target name="validate" depends="validate-solr"/>
+ <target name="validate-solr" depends="check-legal-solr" unless="validated-solr"/>
+
+ <target name="check-legal-solr" depends="compile-test-framework">
+ <java classname="org.apache.lucene.validation.DependencyChecker" failonerror="true" fork="true">
+ <classpath>
+ <path refid="validation.runtime.classpath" />
+ </classpath>
+ <!-- TODO: it might be better to just automatically find all directories that contain jar files, but that could take a
+ long time. This should be faster, but we could miss a directory
+ -->
+ <!-- Solr -->
+ <arg value="-c" />
+ <arg value="${basedir}/lib" />
+ <arg value="-c" />
+ <arg value="${basedir}/contrib/analysis-extras/lib" />
+ <arg value="-c" />
+ <arg value="${basedir}/contrib/clustering/lib" />
+ <arg value="-c" />
+ <arg value="${basedir}/contrib/dataimporthandler/lib" />
+ <arg value="-c" />
+ <arg value="${basedir}/contrib/extraction/lib" />
+ <arg value="-c" />
+ <arg value="${basedir}/contrib/uima/lib" />
+ <arg value="-c" />
+ <arg value="${basedir}/example/example-DIH/solr/db/lib" />
+ <arg value="-c" />
+ <arg value="${basedir}/example/example-DIH/solr/mail/lib" />
+ <arg value="-c" />
+ <arg value="${basedir}/example/example/lib" />
+ <arg value="-c" />
+ <arg value="${basedir}/src/test-files/solr/lib" />
+ </java>
+ </target>
</project>