Apache Lucene open-source search software
LUCENE-2952: drop dev-tools dependency, move to test framework, split out checking to each area: lucene, modules, solr
Grant Ingersoll8bee95305783
diff --git a/build.xml b/build.xmlindex 35ab6a719c2..344c0d3b9da 100644--- a/build.xml+++ b/build.xml@@ -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" />diff --git a/common-build.xml b/common-build.xmlindex cf4f8893064..a622cf37712 100644--- a/common-build.xml+++ b/common-build.xml@@ -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>diff --git a/dev-tools/validation/build.xml b/dev-tools/validation/build.xmldeleted file mode 100644index ed777d59062..00000000000--- a/dev-tools/validation/build.xml+++ /dev/null@@ -1,172 +0,0 @@-<!--- Licensed to the Apache Software Foundation (ASF) under one or more- contributor license agreements. See the NOTICE file distributed with- this work for additional information regarding copyright ownership.- The ASF licenses this file to You under the Apache License, Version 2.0- (the "License"); you may not use this file except in compliance with- the License. You may obtain a copy of the License at-- http://www.apache.org/licenses/LICENSE-2.0-- Unless required by applicable law or agreed to in writing, software- distributed under the License is distributed on an "AS IS" BASIS,- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- See the License for the specific language governing permissions and- limitations under the License.- -->--<project name="validation" default="check-legal" basedir="."- xmlns:artifact="antlib:org.apache.maven.artifact.ant">-- <property name="build.dir" value="build"/>- <property name="dest.dir" value="${build.dir}/classes"/>- <property name="src.dir" value="src/main/java"/>- <property name="java.compat.version" value="1.5"/>- <property name="toplevel.dir" value="../.."/>- <property name="lib" location="lib" />-- <path id="compile.classpath">- <fileset dir="${lib}">- <include name="*.jar" />- </fileset>- </path>- <path id="runtime.classpath">- <path refid="compile.classpath"/>- <pathelement location="${build.dir}/classes"/>- </path>-- <target name="compile">- <mkdir dir="${dest.dir}" />- <javac destdir="${dest.dir}"- target="${java.compat.version}"- source="${java.compat.version}"- debug="on"- encoding="utf8"- includeAntRuntime="${javac.includeAntRuntime}"- srcdir="${src.dir}"- classpathref="compile.classpath">- <compilerarg line="-Xlint -Xlint:-deprecation -Xlint:-serial"/>- </javac>- </target>- <target name="clean">- <delete dir="${build.dir}"/>- </target>- <!--- >find . -name lib-./dev-tools/validation/lib-./lucene/contrib/ant/lib-./lucene/contrib/db/bdb/lib-./lucene/contrib/db/bdb-je/lib-./lucene/contrib/lucli/lib-./lucene/contrib/queries/lib-./lucene/lib-./modules/analysis/icu/lib-./modules/analysis/phonetic/lib-./modules/benchmark/lib-./solr/build/tests/solr/lib-./solr/build/web/WEB-INF/lib-./solr/client/ruby/flare/lib-./solr/client/ruby/flare/vendor/plugins/engines/lib-./solr/client/ruby/flare/vendor/plugins/flare/lib-./solr/client/ruby/solr-ruby/lib-./solr/client/ruby/solr-ruby/solr/lib-./solr/contrib/analysis-extras/lib-./solr/contrib/clustering/lib-./solr/contrib/dataimporthandler/lib-./solr/contrib/extraction/lib-./solr/contrib/uima/lib-./solr/example/example-DIH/solr/db/lib-./solr/example/example-DIH/solr/mail/lib-./solr/example/lib-./solr/example/work/Jetty_0_0_0_0_8983_solr.war__solr__k1kf17/webapp/WEB-INF/lib-./solr/lib-./solr/src/test-files/solr/lib--- -->- <target name="check-legal-lucene" depends="compile">- <java classname="org.apache.lucene.validation.DependencyChecker" failonerror="true" fork="true">- <classpath>- <path refid="compile.classpath" />- <path refid="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="${toplevel.dir}/lucene/lib" />- <arg value="-c" />- <arg value="${toplevel.dir}/lucene/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="${toplevel.dir}/lucene/contrib/lucli/lib" />- <arg value="-c" />- <arg value="${toplevel.dir}/lucene/contrib/queries/lib" />- </java>- </target>-- <target name="check-legal-solr" depends="compile">- <java classname="org.apache.lucene.validation.DependencyChecker" failonerror="true" fork="true">- <classpath>- <path refid="compile.classpath" />- <path refid="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="${toplevel.dir}/solr/lib" />- <arg value="-c" />- <arg value="${toplevel.dir}/solr/contrib/analysis-extras/lib" />- <arg value="-c" />- <arg value="${toplevel.dir}/solr/contrib/clustering/lib" />- <arg value="-c" />- <arg value="${toplevel.dir}/solr/contrib/dataimporthandler/lib" />- <arg value="-c" />- <arg value="${toplevel.dir}/solr/contrib/extraction/lib" />- <arg value="-c" />- <arg value="${toplevel.dir}/solr/contrib/uima/lib" />- <arg value="-c" />- <arg value="${toplevel.dir}/solr/example/example-DIH/solr/db/lib" />- <arg value="-c" />- <arg value="${toplevel.dir}/solr/example/example-DIH/solr/mail/lib" />- <arg value="-c" />- <arg value="${toplevel.dir}/solr/example/example/lib" />- <arg value="-c" />- <arg value="${toplevel.dir}/solr/src/test-files/solr/lib" />- </java>- </target>-- <target name="check-legal-modules" depends="compile">- <java classname="org.apache.lucene.validation.DependencyChecker" failonerror="true" fork="true">- <classpath>- <path refid="compile.classpath" />- <path refid="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="${toplevel.dir}/modules/analysis/icu/lib" />- <arg value="-c" />- <arg value="${toplevel.dir}/modules/analysis/phonetic/lib" />- <arg value="-c" />- <arg value="${toplevel.dir}/modules/benchmark/lib" />- </java>- </target>- <target name="check-legal" depends="check-legal-lucene, check-legal-solr, check-legal-modules"/>-- <target name="validate-lucene" depends="check-legal-lucene" unless="validated-lucene"/>- <target name="validate-modules" depends="check-legal-modules" unless="validated-modules"/>- <target name="validate-solr" depends="check-legal-solr" unless="validated-solr"/>- <!-- Generic placeholder target for if we add other validation tasks -->- <target name="validate" depends="validate-lucene, validate-modules, validate-solr"/>--</project>diff --git a/dev-tools/validation/lib/commons-cli-1.1.jar b/dev-tools/validation/lib/commons-cli-1.1.jardeleted file mode 100644index 4c5dd578c21..00000000000--- a/dev-tools/validation/lib/commons-cli-1.1.jar+++ /dev/null@@ -1,2 +0,0 @@-AnyObjectId[e633afbe6842aa92b1a8f0ff3f5b8c0e3283961b] was removed in git history.-Apache SVN contains full history.\ No newline at end of filediff --git a/dev-tools/validation/lib/commons-cli-LICENSE-ASL.txt b/dev-tools/validation/lib/commons-cli-LICENSE-ASL.txtdeleted file mode 100644index cdf6ff8b222..00000000000--- a/dev-tools/validation/lib/commons-cli-LICENSE-ASL.txt+++ /dev/null@@ -1,272 +0,0 @@-/*- * Apache License- * Version 2.0, January 2004- * http://www.apache.org/licenses/- *- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION- *- * 1. Definitions.- *- * "License" shall mean the terms and conditions for use, reproduction,- * and distribution as defined by Sections 1 through 9 of this document.- *- * "Licensor" shall mean the copyright owner or entity authorized by- * the copyright owner that is granting the License.- *- * "Legal Entity" shall mean the union of the acting entity and all- * other entities that control, are controlled by, or are under common- * control with that entity. For the purposes of this definition,- * "control" means (i) the power, direct or indirect, to cause the- * direction or management of such entity, whether by contract or- * otherwise, or (ii) ownership of fifty percent (50%) or more of the- * outstanding shares, or (iii) beneficial ownership of such entity.- *- * "You" (or "Your") shall mean an individual or Legal Entity- * exercising permissions granted by this License.- *- * "Source" form shall mean the preferred form for making modifications,- * including but not limited to software source code, documentation- * source, and configuration files.- *- * "Object" form shall mean any form resulting from mechanical- * transformation or translation of a Source form, including but- * not limited to compiled object code, generated documentation,- * and conversions to other media types.- *- * "Work" shall mean the work of authorship, whether in Source or- * Object form, made available under the License, as indicated by a- * copyright notice that is included in or attached to the work- * (an example is provided in the Appendix below).- *- * "Derivative Works" shall mean any work, whether in Source or Object- * form, that is based on (or derived from) the Work and for which the- * editorial revisions, annotations, elaborations, or other modifications- * represent, as a whole, an original work of authorship. For the purposes- * of this License, Derivative Works shall not include works that remain- * separable from, or merely link (or bind by name) to the interfaces of,- * the Work and Derivative Works thereof.- *- * "Contribution" shall mean any work of authorship, including- * the original version of the Work and any modifications or additions- * to that Work or Derivative Works thereof, that is intentionally- * submitted to Licensor for inclusion in the Work by the copyright owner- * or by an individual or Legal Entity authorized to submit on behalf of- * the copyright owner. For the purposes of this definition, "submitted"- * means any form of electronic, verbal, or written communication sent- * to the Licensor or its representatives, including but not limited to- * communication on electronic mailing lists, source code control systems,- * and issue tracking systems that are managed by, or on behalf of, the- * Licensor for the purpose of discussing and improving the Work, but- * excluding communication that is conspicuously marked or otherwise- * designated in writing by the copyright owner as "Not a Contribution."- *- * "Contributor" shall mean Licensor and any individual or Legal Entity- * on behalf of whom a Contribution has been received by Licensor and- * subsequently incorporated within the Work.- *- * 2. Grant of Copyright License. Subject to the terms and conditions of- * this License, each Contributor hereby grants to You a perpetual,- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable- * copyright license to reproduce, prepare Derivative Works of,- * publicly display, publicly perform, sublicense, and distribute the- * Work and such Derivative Works in Source or Object form.- *- * 3. Grant of Patent License. Subject to the terms and conditions of- * this License, each Contributor hereby grants to You a perpetual,- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable- * (except as stated in this section) patent license to make, have made,- * use, offer to sell, sell, import, and otherwise transfer the Work,- * where such license applies only to those patent claims licensable- * by such Contributor that are necessarily infringed by their- * Contribution(s) alone or by combination of their Contribution(s)- * with the Work to which such Contribution(s) was submitted. If You- * institute patent litigation against any entity (including a- * cross-claim or counterclaim in a lawsuit) alleging that the Work- * or a Contribution incorporated within the Work constitutes direct- * or contributory patent infringement, then any patent licenses- * granted to You under this License for that Work shall terminate- * as of the date such litigation is filed.- *- * 4. Redistribution. You may reproduce and distribute copies of the- * Work or Derivative Works thereof in any medium, with or without- * modifications, and in Source or Object form, provided that You- * meet the following conditions:- *- * (a) You must give any other recipients of the Work or- * Derivative Works a copy of this License; and- *- * (b) You must cause any modified files to carry prominent notices- * stating that You changed the files; and- *- * (c) You must retain, in the Source form of any Derivative Works- * that You distribute, all copyright, patent, trademark, and- * attribution notices from the Source form of the Work,- * excluding those notices that do not pertain to any part of- * the Derivative Works; and- *- * (d) If the Work includes a "NOTICE" text file as part of its- * distribution, then any Derivative Works that You distribute must- * include a readable copy of the attribution notices contained- * within such NOTICE file, excluding those notices that do not- * pertain to any part of the Derivative Works, in at least one- * of the following places: within a NOTICE text file distributed- * as part of the Derivative Works; within the Source form or- * documentation, if provided along with the Derivative Works; or,- * within a display generated by the Derivative Works, if and- * wherever such third-party notices normally appear. The contents- * of the NOTICE file are for informational purposes only and- * do not modify the License. You may add Your own attribution- * notices within Derivative Works that You distribute, alongside- * or as an addendum to the NOTICE text from the Work, provided- * that such additional attribution notices cannot be construed- * as modifying the License.- *- * You may add Your own copyright statement to Your modifications and- * may provide additional or different license terms and conditions- * for use, reproduction, or distribution of Your modifications, or- * for any such Derivative Works as a whole, provided Your use,- * reproduction, and distribution of the Work otherwise complies with- * the conditions stated in this License.- *- * 5. Submission of Contributions. Unless You explicitly state otherwise,- * any Contribution intentionally submitted for inclusion in the Work- * by You to the Licensor shall be under the terms and conditions of- * this License, without any additional terms or conditions.- * Notwithstanding the above, nothing herein shall supersede or modify- * the terms of any separate license agreement you may have executed- * with Licensor regarding such Contributions.- *- * 6. Trademarks. This License does not grant permission to use the trade- * names, trademarks, service marks, or product names of the Licensor,- * except as required for reasonable and customary use in describing the- * origin of the Work and reproducing the content of the NOTICE file.- *- * 7. Disclaimer of Warranty. Unless required by applicable law or- * agreed to in writing, Licensor provides the Work (and each- * Contributor provides its Contributions) on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or- * implied, including, without limitation, any warranties or conditions- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A- * PARTICULAR PURPOSE. You are solely responsible for determining the- * appropriateness of using or redistributing the Work and assume any- * risks associated with Your exercise of permissions under this License.- *- * 8. Limitation of Liability. In no event and under no legal theory,- * whether in tort (including negligence), contract, or otherwise,- * unless required by applicable law (such as deliberate and grossly- * negligent acts) or agreed to in writing, shall any Contributor be- * liable to You for damages, including any direct, indirect, special,- * incidental, or consequential damages of any character arising as a- * result of this License or out of the use or inability to use the- * Work (including but not limited to damages for loss of goodwill,- * work stoppage, computer failure or malfunction, or any and all- * other commercial damages or losses), even if such Contributor- * has been advised of the possibility of such damages.- *- * 9. Accepting Warranty or Additional Liability. While redistributing- * the Work or Derivative Works thereof, You may choose to offer,- * and charge a fee for, acceptance of support, warranty, indemnity,- * or other liability obligations and/or rights consistent with this- * License. However, in accepting such obligations, You may act only- * on Your own behalf and on Your sole responsibility, not on behalf- * of any other Contributor, and only if You agree to indemnify,- * defend, and hold each Contributor harmless for any liability- * incurred by, or claims asserted against, such Contributor by reason- * of your accepting any such warranty or additional liability.- *- * END OF TERMS AND CONDITIONS- *- * APPENDIX: How to apply the Apache License to your work.- *- * To apply the Apache License to your work, attach the following- * boilerplate notice, with the fields enclosed by brackets "[]"- * replaced with your own identifying information. (Don't include- * the brackets!) The text should be enclosed in the appropriate- * comment syntax for the file format. We also recommend that a- * file or class name and description of purpose be included on the- * same "printed page" as the copyright notice for easier- * identification within third-party archives.- *- * Copyright [yyyy] [name of copyright owner]- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--W3C� SOFTWARE NOTICE AND LICENSE-http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231--This work (and included software, documentation such as READMEs, or other-related items) is being provided by the copyright holders under the following-license. By obtaining, using and/or copying this work, you (the licensee) agree-that you have read, understood, and will comply with the following terms and-conditions.--Permission to copy, modify, and distribute this software and its documentation,-with or without modification, for any purpose and without fee or royalty is-hereby granted, provided that you include the following on ALL copies of the-software and documentation or portions thereof, including modifications:-- 1. The full text of this NOTICE in a location viewable to users of the- redistributed or derivative work.- 2. Any pre-existing intellectual property disclaimers, notices, or terms- and conditions. If none exist, the W3C Software Short Notice should be- included (hypertext is preferred, text is permitted) within the body- of any redistributed or derivative code.- 3. Notice of any changes or modifications to the files, including the date- changes were made. (We recommend you provide URIs to the location from- which the code is derived.)--THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE-NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED-TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT-THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY-PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.--COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR-CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.--The name and trademarks of copyright holders may NOT be used in advertising or-publicity pertaining to the software without specific, written prior permission.-Title to copyright in this software and any associated documentation will at-all times remain with copyright holders.--____________________________________--This formulation of W3C's notice and license became active on December 31 2002.-This version removes the copyright ownership notice such that this license can-be used with materials other than those owned by the W3C, reflects that ERCIM-is now a host of the W3C, includes references to this specific dated version of-the license, and removes the ambiguous grant of "use". Otherwise, this version-is the same as the previous version and is written so as to preserve the Free-Software Foundation's assessment of GPL compatibility and OSI's certification-under the Open Source Definition. Please see our Copyright FAQ for common-questions about using materials from our site, including specific terms and-conditions for packages like libwww, Amaya, and Jigsaw. Other questions about-this notice can be directed to [email protected].--Joseph Reagle <[email protected]>--This license came from: http://www.megginson.com/SAX/copying.html- However please note future versions of SAX may be covered- under http://saxproject.org/?selected=pd--SAX2 is Free!--I hereby abandon any property rights to SAX 2.0 (the Simple API for-XML), and release all of the SAX 2.0 source code, compiled code, and-documentation contained in this distribution into the Public Domain.-SAX comes with NO WARRANTY or guarantee of fitness for any-purpose.--David Megginson, [email protected]-2000-05-05diff --git a/dev-tools/validation/src/main/java/org/apache/lucene/validation/DependencyChecker.java b/dev-tools/validation/src/main/java/org/apache/lucene/validation/DependencyChecker.javadeleted file mode 100644index 8d8f2f2bc2e..00000000000--- a/dev-tools/validation/src/main/java/org/apache/lucene/validation/DependencyChecker.java+++ /dev/null@@ -1,291 +0,0 @@-package org.apache.lucene.validation;-/**- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * 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.Arrays;-import java.util.HashMap;-import java.util.HashSet;-import java.util.Map;-import java.util.Set;--/**- *- *- **/-public class DependencyChecker {- private static Set<String> excludes = new HashSet<String>();- private static final String LINE_SEPARATOR = System.getProperty("line.separator");-- static {- //Collections.addAll(excludes, );- }-- 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);- }- 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++;- }- }- }- } 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) {- 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);- }- }-- }- } 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);- System.out.println("Left\t\t\tRight");- System.out.println("----------------");- StringBuilder bldr = new StringBuilder();- int i = 0;- for (; i < left.length; i++) {- bldr.append(left[i]).append("\t\t\t");- if (i < right.length) {- bldr.append(right[i]);- }- bldr.append(LINE_SEPARATOR);- }- if (i < right.length){- for (; i < right.length; i++){- bldr.append("--- N/A ---\t\t\t").append(right[i]).append(LINE_SEPARATOR);- }- }- System.out.println(bldr.toString());- System.out.println("----------------");- }-- private static LicenseType[] getLicenseTypes(String licName) {- LicenseType[] result = new LicenseType[0];- int idx = licName.lastIndexOf("-");- if (idx != -1) {- String licAbbrev = licName.substring(idx + 1, licName.length() - ".txt".length());- String[] lics = licAbbrev.split("__");- result = new LicenseType[lics.length];- for (int j = 0; j < lics.length; j++) {- try {- result[j] = LicenseType.valueOf(lics[j].toUpperCase());- } catch (IllegalArgumentException e) {- System.out.println("Invalid license: " + lics[j].toUpperCase() + " for " + licName);- }- }- }- return result;- }-- private static File getLicenseFile(File file, Map<String, UpdateableInt> licenseNames) {- File result = null;- String filename = file.getName();- int length = 0;- for (String licName : licenseNames.keySet()) {- String prefix = licName.substring(0, licName.indexOf("-LICENSE"));- String name = null;- //System.out.println("prefix: " + prefix + " lic name: " + licName);- if (filename.toLowerCase().startsWith(prefix.toLowerCase())) {- result = new File(file.getParentFile(), licName);- UpdateableInt ui = licenseNames.get(licName);- ui.theInt++;- } else {- }-- }- //System.out.println("License File: " + result + " for file: " + file);-- return result;- }-- private static File getNoticeFile(File file, Map<String, UpdateableInt> noticeNames) {- File result = null;- String filename = file.getName();- int length = 0;- for (String noticeName : noticeNames.keySet()) {- String prefix = noticeName.substring(0, noticeName.indexOf("-NOTICE"));- String name = null;- //System.out.println("prefix: " + prefix + " lic name: " + licName);- if (filename.toLowerCase().startsWith(prefix.toLowerCase())) {- result = new File(file.getParentFile(), noticeName);- UpdateableInt ui = noticeNames.get(noticeName);- ui.theInt++;- } else {- }-- }- //System.out.println("License File: " + result + " for file: " + file);-- return result;- }--}--class UpdateableInt {- public int theInt;-}diff --git a/lucene/common-build.xml b/lucene/common-build.xmlindex 79f8d25d346..be49f380e40 100644--- a/lucene/common-build.xml+++ b/lucene/common-build.xml@@ -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>diff --git a/lucene/src/test-framework/org/apache/lucene/validation/DependencyChecker.java b/lucene/src/test-framework/org/apache/lucene/validation/DependencyChecker.javanew file mode 100644index 00000000000..a15de1109b8--- /dev/null+++ b/lucene/src/test-framework/org/apache/lucene/validation/DependencyChecker.java@@ -0,0 +1,282 @@+package org.apache.lucene.validation;+/**+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++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;++/**+ *+ *+ **/+public class DependencyChecker {+ private static Set<String> excludes = new HashSet<String>();+ private static final String LINE_SEPARATOR = System.getProperty("line.separator");++ static {+ //Collections.addAll(excludes, );+ }++ public static void main(String[] args) throws IOException {+ 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]);+ }+ }+++ 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++;+ }+ }+ }+ 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 (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);+ }+ }+ }+++ /**+ * 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);+ System.out.println("Left\t\t\tRight");+ System.out.println("----------------");+ StringBuilder bldr = new StringBuilder();+ int i = 0;+ for (; i < left.length; i++) {+ bldr.append(left[i]).append("\t\t\t");+ if (i < right.length) {+ bldr.append(right[i]);+ }+ bldr.append(LINE_SEPARATOR);+ }+ if (i < right.length) {+ for (; i < right.length; i++) {+ bldr.append("--- N/A ---\t\t\t").append(right[i]).append(LINE_SEPARATOR);+ }+ }+ System.out.println(bldr.toString());+ System.out.println("----------------");+ }++ private static LicenseType[] getLicenseTypes(String licName) {+ LicenseType[] result = new LicenseType[0];+ int idx = licName.lastIndexOf("-");+ if (idx != -1) {+ String licAbbrev = licName.substring(idx + 1, licName.length() - ".txt".length());+ String[] lics = licAbbrev.split("__");+ result = new LicenseType[lics.length];+ for (int j = 0; j < lics.length; j++) {+ try {+ result[j] = LicenseType.valueOf(lics[j].toUpperCase());+ } catch (IllegalArgumentException e) {+ System.out.println("Invalid license: " + lics[j].toUpperCase() + " for " + licName);+ }+ }+ }+ return result;+ }++ private static File getLicenseFile(File file, Map<String, UpdateableInt> licenseNames) {+ File result = null;+ String filename = file.getName();+ int length = 0;+ for (String licName : licenseNames.keySet()) {+ String prefix = licName.substring(0, licName.indexOf("-LICENSE"));+ String name = null;+ //System.out.println("prefix: " + prefix + " lic name: " + licName);+ if (filename.toLowerCase().startsWith(prefix.toLowerCase())) {+ result = new File(file.getParentFile(), licName);+ UpdateableInt ui = licenseNames.get(licName);+ ui.theInt++;+ } else {+ }++ }+ //System.out.println("License File: " + result + " for file: " + file);++ return result;+ }++ private static File getNoticeFile(File file, Map<String, UpdateableInt> noticeNames) {+ File result = null;+ String filename = file.getName();+ int length = 0;+ for (String noticeName : noticeNames.keySet()) {+ String prefix = noticeName.substring(0, noticeName.indexOf("-NOTICE"));+ String name = null;+ //System.out.println("prefix: " + prefix + " lic name: " + licName);+ if (filename.toLowerCase().startsWith(prefix.toLowerCase())) {+ result = new File(file.getParentFile(), noticeName);+ UpdateableInt ui = noticeNames.get(noticeName);+ ui.theInt++;+ } else {+ }++ }+ //System.out.println("License File: " + result + " for file: " + file);++ return result;+ }++}++class UpdateableInt {+ public int theInt;+}diff --git a/dev-tools/validation/src/main/java/org/apache/lucene/validation/LicenseType.java b/lucene/src/test-framework/org/apache/lucene/validation/LicenseType.javasimilarity index 100%rename from dev-tools/validation/src/main/java/org/apache/lucene/validation/LicenseType.javarename to lucene/src/test-framework/org/apache/lucene/validation/LicenseType.javadiff --git a/modules/build.xml b/modules/build.xmlindex 9702d72cca8..fe9a1931715 100644--- a/modules/build.xml+++ b/modules/build.xml@@ -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>diff --git a/solr/common-build.xml b/solr/common-build.xmlindex c43fdc63ccd..77e83bfd7c5 100644--- a/solr/common-build.xml+++ b/solr/common-build.xml@@ -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>