LUCENE-4753: Run forbidden-apis Ant task per module. This allows more improvements and prevents OOMs after the number of class files raised recently

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1540573 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2013-11-10 22:50:51 +00:00
parent 2e8469408a
commit 7315a90a7b
18 changed files with 162 additions and 102 deletions

View File

@ -286,6 +286,10 @@ Build
* LUCENE-5322: Clean up / simplify Maven-related Ant targets. * LUCENE-5322: Clean up / simplify Maven-related Ant targets.
(Steve Rowe) (Steve Rowe)
* LUCENE-4753: Run forbidden-apis Ant task per module. This allows more
improvements and prevents OOMs after the number of class files
raised recently. (Uwe Schindler)
Tests Tests
* LUCENE-5278: Fix MockTokenizer to work better with more regular expression * LUCENE-5278: Fix MockTokenizer to work better with more regular expression

View File

@ -147,4 +147,8 @@
<forall-analyzers target="-append-module-dependencies-properties"/> <forall-analyzers target="-append-module-dependencies-properties"/>
</target> </target>
<target name="check-forbidden-apis">
<forall-analyzers target="check-forbidden-apis"/>
</target>
</project> </project>

View File

@ -23,6 +23,11 @@
Analyzer for indexing Polish Analyzer for indexing Polish
</description> </description>
<property name="forbidden-sysout-excludes" value="
org/egothor/stemmer/Compile.class
org/egothor/stemmer/DiffIt.class
"/>
<import file="../analysis-module-build.xml"/> <import file="../analysis-module-build.xml"/>
<path id="classpath"> <path id="classpath">

View File

@ -26,6 +26,9 @@
<import file="../module-build.xml"/> <import file="../module-build.xml"/>
<property name="working.dir" location="work"/> <property name="working.dir" location="work"/>
<!-- benchmark creates lots of sysout stuff, so dont run forbidden! -->
<target name="-check-forbidden-sysout"/>
<target name="check-files"> <target name="check-files">
<available file="temp/news20.tar.gz" property="news20.exists"/> <available file="temp/news20.tar.gz" property="news20.exists"/>

View File

@ -174,64 +174,15 @@
<lib-versions-check-macro dir="${common.dir}/.." centralized.versions.file="${common.dir}/ivy-versions.properties"/> <lib-versions-check-macro dir="${common.dir}/.." centralized.versions.file="${common.dir}/ivy-versions.properties"/>
</target> </target>
<target name="check-forbidden-apis" depends="compile-tools,compile-test,install-forbidden-apis,-forbidden-apis-classpath,-check-forbidden-jdk-apis,-check-forbidden-test-apis,-check-system-out" description="Check forbidden API calls in compiled class files"/> <!-- -install-forbidden-apis is *not* a useless dependency. do not remove -->
<target name="check-forbidden-apis" depends="-install-forbidden-apis" description="Check forbidden API calls in compiled class files">
<!-- TODO: Make the forbidden API checks per module! --> <subant target="check-forbidden-apis" failonerror="true" inheritall="false">
<target name="-forbidden-apis-classpath"> <propertyset refid="uptodate.and.compiled.properties"/>
<path id="forbidden-apis.classpath"> <fileset dir="core" includes="build.xml"/>
<fileset dir="${basedir}" includes="**/lib/*.jar"/> <fileset dir="test-framework" includes="build.xml"/>
<dirset dir="${basedir}/build" includes="**/classes/*"/> <fileset dir="tools" includes="build.xml"/>
</path> </subant>
</target> <modules-crawl target="check-forbidden-apis"/>
<target name="-check-forbidden-jdk-apis">
<forbidden-apis internalRuntimeForbidden="true" classpathref="forbidden-apis.classpath">
<bundledSignatures name="jdk-unsafe-${javac.target}"/>
<bundledSignatures name="jdk-deprecated-${javac.target}"/>
<signaturesFileSet dir="${common.dir}/tools/forbiddenApis">
<include name="base.txt" />
</signaturesFileSet>
<fileset dir="${basedir}/build" includes="**/*.class" />
</forbidden-apis>
</target>
<target name="-check-forbidden-test-apis">
<forbidden-apis signaturesFile="${common.dir}/tools/forbiddenApis/tests.txt" classpathref="forbidden-apis.classpath">
<classpath refid="junit-path"/>
<fileset dir="${basedir}/build" includes="**/classes/test/**/*.class,test-framework/**/*.class" />
</forbidden-apis>
</target>
<target name="-check-system-out">
<forbidden-apis bundledSignatures="jdk-system-out" classpathref="forbidden-apis.classpath">
<fileset dir="${basedir}/build">
<include name="**/classes/java/**/*.class"/>
<!-- this is basically tests -->
<exclude name="test-framework/**"/>
<!-- exclude command line tools -->
<exclude name="core/classes/java/org/apache/lucene/index/CheckIndex.class"/>
<exclude name="core/classes/java/org/apache/lucene/index/IndexUpgrader.class"/>
<exclude name="core/classes/java/org/apache/lucene/store/LockVerifyServer.class"/>
<exclude name="core/classes/java/org/apache/lucene/store/LockStressTest.class"/>
<exclude name="analysis/stempel/classes/java/org/egothor/stemmer/Compile.class"/>
<exclude name="analysis/stempel/classes/java/org/egothor/stemmer/DiffIt.class"/>
<exclude name="benchmark/**"/>
<exclude name="demo/classes/java/org/apache/lucene/**"/>
<exclude name="misc/classes/java/org/apache/lucene/index/CompoundFileExtractor.class"/>
<exclude name="misc/classes/java/org/apache/lucene/index/IndexSplitter.class"/>
<exclude name="misc/classes/java/org/apache/lucene/index/MultiPassIndexSplitter.class"/>
<exclude name="misc/classes/java/org/apache/lucene/misc/GetTermInfo.class"/>
<exclude name="misc/classes/java/org/apache/lucene/misc/HighFreqTerms.class"/>
<exclude name="misc/classes/java/org/apache/lucene/misc/IndexMergeTool.class"/>
<!-- not printing, just checking if its a system stream -->
<exclude name="core/classes/java/org/apache/lucene/util/PrintStreamInfoStream.class"/>
<!-- not printing, just generated code from javacc -->
<exclude name="queryparser/classes/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.class"/>
<exclude name="queryparser/classes/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.class"/>
<exclude name="queryparser/classes/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.class"/>
<exclude name="facet/classes/java/org/apache/lucene/facet/util/PrintTaxonomyStats.class"/>
</fileset>
</forbidden-apis>
</target> </target>
<target name="resolve"> <target name="resolve">

View File

@ -2176,13 +2176,52 @@ ${ant.project.name}.test.dependencies=${test.classpath.list}
</target> </target>
<!-- Forbidden API Task --> <!-- Forbidden API Task -->
<target name="install-forbidden-apis" unless="forbidden-apis.loaded" depends="ivy-availability-check,ivy-configure"> <property name="forbidden-base-excludes" value=""/>
<property name="forbidden-tests-excludes" value=""/>
<property name="forbidden-sysout-excludes" value=""/>
<target name="-install-forbidden-apis" unless="forbidden-apis.loaded" depends="ivy-availability-check,ivy-configure">
<ivy:cachepath organisation="de.thetaphi" module="forbiddenapis" revision="1.3" <ivy:cachepath organisation="de.thetaphi" module="forbiddenapis" revision="1.3"
inline="true" conf="default" transitive="true" pathid="forbidden-apis.classpath"/> inline="true" conf="default" transitive="true" pathid="forbidden-apis.classpath"/>
<taskdef name="forbidden-apis" classname="de.thetaphi.forbiddenapis.AntTask" classpathref="forbidden-apis.classpath"/> <taskdef name="forbidden-apis" classname="de.thetaphi.forbiddenapis.AntTask" classpathref="forbidden-apis.classpath"/>
<property name="forbidden-apis.loaded" value="true"/> <property name="forbidden-apis.loaded" value="true"/>
</target> </target>
<target name="-init-forbidden-apis" depends="-install-forbidden-apis">
<path id="forbidden-apis.allclasses.classpath">
<path refid="classpath"/>
<path refid="test.classpath"/>
<path refid="junit-path"/>
<!-- include the output directories, too (so we can still resolve excluded classes: -->
<pathelement path="${build.dir}/classes/java"/>
<pathelement path="${build.dir}/classes/test"/>
</path>
</target>
<target name="check-forbidden-apis" depends="-check-forbidden-base,-check-forbidden-tests,-check-forbidden-sysout" description="Check forbidden API calls in compiled class files"/>
<target name="-check-forbidden-base" depends="-init-forbidden-apis,compile-core,compile-test">
<forbidden-apis internalRuntimeForbidden="true" classpathref="forbidden-apis.allclasses.classpath">
<bundledSignatures name="jdk-unsafe-${javac.target}"/>
<bundledSignatures name="jdk-deprecated-${javac.target}"/>
<signaturesFileSet file="${common.dir}/tools/forbiddenApis/base.txt"/>
<fileset dir="${build.dir}/classes/java" excludes="${forbidden-base-excludes}"/>
<fileset dir="${build.dir}/classes/test" excludes="${forbidden-tests-excludes}" erroronmissingdir="false"/>
</forbidden-apis>
</target>
<target name="-check-forbidden-tests" depends="-init-forbidden-apis,compile-test">
<forbidden-apis signaturesFile="${common.dir}/tools/forbiddenApis/tests.txt" classpathref="forbidden-apis.allclasses.classpath">
<fileset dir="${build.dir}/classes/test" excludes="${forbidden-tests-excludes}"/>
</forbidden-apis>
</target>
<target name="-check-forbidden-sysout" depends="-init-forbidden-apis,compile-core">
<forbidden-apis bundledSignatures="jdk-system-out" classpathref="forbidden-apis.allclasses.classpath">
<fileset dir="${build.dir}/classes/java" excludes="${forbidden-sysout-excludes}"/>
</forbidden-apis>
</target>
<!-- PEGDOWN macro: Before using depend on the target "resolve-pegdown,resolve-groovy" --> <!-- PEGDOWN macro: Before using depend on the target "resolve-pegdown,resolve-groovy" -->
<target name="resolve-pegdown" unless="pegdown.loaded" depends="ivy-availability-check,ivy-configure"> <target name="resolve-pegdown" unless="pegdown.loaded" depends="ivy-availability-check,ivy-configure">

View File

@ -22,6 +22,14 @@
<property name="build.dir" location="../build/core"/> <property name="build.dir" location="../build/core"/>
<property name="forbidden-sysout-excludes" value="
org/apache/lucene/index/CheckIndex.class
org/apache/lucene/index/IndexUpgrader.class
org/apache/lucene/store/LockVerifyServer.class
org/apache/lucene/store/LockStressTest.class
org/apache/lucene/util/PrintStreamInfoStream.class
"/>
<import file="../common-build.xml"/> <import file="../common-build.xml"/>
<property name="moman.commit-hash" value="5c5c2a1e4dea" /> <property name="moman.commit-hash" value="5c5c2a1e4dea" />

View File

@ -53,6 +53,9 @@
</invoke-module-javadoc> </invoke-module-javadoc>
</target> </target>
<!-- we don't check for sysout in demo, because the demo is there to use sysout :-) -->
<target name="-check-forbidden-sysout"/>
<target name="compile-core" depends="jar-analyzers-common,jar-queryparser,jar-queries,jar-facet,jar-expressions,common.compile-core" /> <target name="compile-core" depends="jar-analyzers-common,jar-queryparser,jar-queries,jar-facet,jar-expressions,common.compile-core" />
<target name="default" depends="jar-core,build-web-demo"/> <target name="default" depends="jar-core,build-web-demo"/>

View File

@ -23,6 +23,10 @@
Faceted indexing and search capabilities Faceted indexing and search capabilities
</description> </description>
<property name="forbidden-sysout-excludes" value="
org/apache/lucene/facet/util/PrintTaxonomyStats.class
"/>
<import file="../module-build.xml"/> <import file="../module-build.xml"/>
<path id="classpath"> <path id="classpath">

View File

@ -23,6 +23,15 @@
Index tools and other miscellaneous code Index tools and other miscellaneous code
</description> </description>
<property name="forbidden-sysout-excludes" value="
org/apache/lucene/index/CompoundFileExtractor.class
org/apache/lucene/index/IndexSplitter.class
org/apache/lucene/index/MultiPassIndexSplitter.class
org/apache/lucene/misc/GetTermInfo.class
org/apache/lucene/misc/HighFreqTerms.class
org/apache/lucene/misc/IndexMergeTool.class
"/>
<import file="../module-build.xml"/> <import file="../module-build.xml"/>
<target name="install-cpptasks" unless="cpptasks.uptodate" depends="ivy-availability-check,ivy-fail,ivy-configure"> <target name="install-cpptasks" unless="cpptasks.uptodate" depends="ivy-availability-check,ivy-fail,ivy-configure">

View File

@ -20,6 +20,11 @@
Query parsers and parsing framework Query parsers and parsing framework
</description> </description>
<!-- TODO: remove the stupid debugStream in the JavaCC TokenManager classes with an additional regex below! -->
<property name="forbidden-sysout-excludes" value="
org/apache/lucene/queryparser/**/*TokenManager.class
"/>
<import file="../module-build.xml"/> <import file="../module-build.xml"/>
<path id="classpath"> <path id="classpath">

View File

@ -42,6 +42,17 @@
<!-- redefine the clover setup, because we dont want to run clover for the test-framework --> <!-- redefine the clover setup, because we dont want to run clover for the test-framework -->
<target name="-clover.setup" if="run.clover"/> <target name="-clover.setup" if="run.clover"/>
<!-- redefine the test compilation, so its just a no-op -->
<target name="compile-test"/>
<!-- redefine the forbidden apis for tests, as we check ourselves - no sysout testing -->
<target name="-check-forbidden-tests" depends="-init-forbidden-apis,compile-core">
<forbidden-apis signaturesFile="${common.dir}/tools/forbiddenApis/tests.txt" classpathref="forbidden-apis.allclasses.classpath">
<fileset dir="${build.dir}/classes/java"/>
</forbidden-apis>
</target>
<target name="-check-forbidden-sysout"/>
<target name="javadocs-core" depends="javadocs"/> <target name="javadocs-core" depends="javadocs"/>
<target name="javadocs" depends="init,javadocs-lucene-core,javadocs-lucene-codecs"> <target name="javadocs" depends="init,javadocs-lucene-core,javadocs-lucene-codecs">
<sequential> <sequential>

View File

@ -27,8 +27,19 @@
<import file="../common-build.xml"/> <import file="../common-build.xml"/>
<path id="classpath"> <path id="classpath">
<!-- TODO: we need this for forbidden-apis to be happy, because it does not support "includeantruntime": -->
<path refid="ant-path"/>
</path> </path>
<path id="test.classpath"/>
<!-- redefine the test compilation, so its just a no-op -->
<target name="compile-test"/>
<!-- redefine the forbidden apis to be no-ops -->
<target name="-check-forbidden-tests"/>
<target name="-check-forbidden-sysout"/>
<!-- <!--
Specialize compile-core to not depend on clover, to exclude a Specialize compile-core to not depend on clover, to exclude a
classpath reference when compiling, and to not attempt to copy classpath reference when compiling, and to not attempt to copy

View File

@ -267,49 +267,14 @@
</license-check-macro> </license-check-macro>
</target> </target>
<target name="check-forbidden-apis" depends="compile-tools,compile-test,install-forbidden-apis,-forbidden-apis-classpath,-check-forbidden-java-apis,-check-forbidden-test-apis" <target name="check-forbidden-apis" depends="-install-forbidden-apis" description="Check forbidden API calls in compiled class files.">
description="Check forbidden API calls in compiled class files."/> <subant target="check-forbidden-apis" inheritall="false" >
<propertyset refid="uptodate.and.compiled.properties"/>
<!-- TODO: Make the forbidden API checks per module! Also remove failOnMissingClasses="false" below!!! --> <fileset dir="core" includes="build.xml"/>
<target name="-forbidden-apis-classpath"> <fileset dir="solrj" includes="build.xml"/>
<path id="forbidden-apis.classpath"> <fileset dir="test-framework" includes="build.xml"/>
<fileset dir="${basedir}" includes="**/lib/*.jar,**/test-lib/*.jar"/> </subant>
<dirset dir="${basedir}/build" includes="**/classes/*"/> <contrib-crawl target="check-forbidden-apis" failonerror="true"/>
<path refid="solr.lucene.libs"/>
<path refid="classpath"/>
<path refid="test.classpath"/>
</path>
</target>
<target name="-check-forbidden-java-apis">
<property file="${common.dir}/ivy-versions.properties"/> <!-- for commons-io version -->
<forbidden-apis internalRuntimeForbidden="true" classpathref="forbidden-apis.classpath" failOnMissingClasses="false">
<bundledSignatures name="jdk-unsafe-${javac.target}"/>
<bundledSignatures name="jdk-deprecated-${javac.target}"/>
<bundledSignatures name="commons-io-unsafe-${/commons-io/commons-io}"/>
<signaturesFileSet dir="${common.dir}/tools/forbiddenApis">
<include name="base.txt" />
<include name="servlet-api.txt" />
</signaturesFileSet>
<fileset dir="${basedir}/build">
<include name="**/*.class" />
<!-- violates the servlet-api restrictions, but it is safe to do so in this test: -->
<exclude name="solr-solrj/classes/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest$DebugServlet.class"/>
</fileset>
</forbidden-apis>
</target>
<target name="-check-forbidden-test-apis">
<forbidden-apis signaturesFile="${common.dir}/tools/forbiddenApis/tests.txt" classpathref="forbidden-apis.classpath" failOnMissingClasses="false">
<fileset dir="${basedir}/build">
<include name="**/classes/test/**/*.class"/>
<include name="solr-test-framework/**/*.class"/>
<!-- not actually a test -->
<exclude name="solr-core/classes/test/org/apache/solr/search/DocSetPerf.class"/>
<!-- imported code -->
<exclude name="solr-core/classes/test/org/apache/solr/internal/**/*.class"/>
</fileset>
</forbidden-apis>
</target> </target>
<!-- rat sources --> <!-- rat sources -->

View File

@ -466,6 +466,24 @@
<contrib-crawl target="add-to-war"/> <contrib-crawl target="add-to-war"/>
</target> </target>
<!-- Forbidden API Task, customizations for Solr -->
<target name="-check-forbidden-base" depends="-init-forbidden-apis,compile-core,compile-test">
<property file="${common.dir}/ivy-versions.properties"/> <!-- for commons-io version -->
<forbidden-apis internalRuntimeForbidden="true" classpathref="forbidden-apis.allclasses.classpath">
<bundledSignatures name="jdk-unsafe-${javac.target}"/>
<bundledSignatures name="jdk-deprecated-${javac.target}"/>
<bundledSignatures name="commons-io-unsafe-${/commons-io/commons-io}"/>
<signaturesFileSet dir="${common.dir}/tools/forbiddenApis">
<include name="base.txt" />
<include name="servlet-api.txt" />
</signaturesFileSet>
<fileset dir="${build.dir}/classes/java" excludes="${forbidden-base-excludes}"/>
<fileset dir="${build.dir}/classes/test" excludes="${forbidden-tests-excludes}" erroronmissingdir="false"/>
</forbidden-apis>
</target>
<target name="-check-forbidden-sysout"/>
<!-- hack for now to disable *all* Solr tests on Jenkins when "tests.disable-solr" property is set --> <!-- hack for now to disable *all* Solr tests on Jenkins when "tests.disable-solr" property is set -->
<target name="test" unless="tests.disable-solr"> <target name="test" unless="tests.disable-solr">
<antcall target="common.test" inheritrefs="true" inheritall="true"/> <antcall target="common.test" inheritrefs="true" inheritall="true"/>

View File

@ -23,6 +23,11 @@
<property name="test.lib.dir" location="test-lib"/> <property name="test.lib.dir" location="test-lib"/>
<property name="forbidden-tests-excludes" value="
org/apache/solr/internal/**
org/apache/solr/search/DocSetPerf.class
"/>
<import file="../common-build.xml"/> <import file="../common-build.xml"/>
<target name="compile-core" depends="compile-solrj,common-solr.compile-core"/> <target name="compile-core" depends="compile-solrj,common-solr.compile-core"/>

View File

@ -18,6 +18,11 @@
<project name="solr-solrj" default="default"> <project name="solr-solrj" default="default">
<description>Solrj - Solr Java Client</description> <description>Solrj - Solr Java Client</description>
<!-- violates the servlet-api restrictions, but it is safe to do so in this test: -->
<property name="forbidden-tests-excludes" value="
org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest$DebugServlet.class
"/>
<import file="../common-build.xml"/> <import file="../common-build.xml"/>
<!-- Specialized compile classpath: to only depend on what solrj should depend on (e.g. not lucene) --> <!-- Specialized compile classpath: to only depend on what solrj should depend on (e.g. not lucene) -->

View File

@ -46,6 +46,16 @@
<!-- redefine the clover setup, because we dont want to run clover for the test-framework --> <!-- redefine the clover setup, because we dont want to run clover for the test-framework -->
<target name="-clover.setup" if="run.clover"/> <target name="-clover.setup" if="run.clover"/>
<!-- redefine the test compilation, so its just a no-op -->
<target name="compile-test"/>
<!-- redefine the forbidden apis for tests, as we check ourselves -->
<target name="-check-forbidden-tests" depends="-init-forbidden-apis,compile-core">
<forbidden-apis signaturesFile="${common.dir}/tools/forbiddenApis/tests.txt" classpathref="forbidden-apis.allclasses.classpath">
<fileset dir="${build.dir}/classes/java"/>
</forbidden-apis>
</target>
<!-- Override common-solr.javadocs to include JUnit links --> <!-- Override common-solr.javadocs to include JUnit links -->
<!-- and to copy the built javadocs to ${dest}/docs/api/test-framework --> <!-- and to copy the built javadocs to ${dest}/docs/api/test-framework -->
<target name="javadocs" <target name="javadocs"