add validate-maven task to check maven dependencies, fix redundant dependencies in generate-maven-artifacts

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1381602 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2012-09-06 13:53:35 +00:00
parent fa731ef7e3
commit a4cf4bd859
7 changed files with 159 additions and 30 deletions

View File

@ -91,6 +91,13 @@
</subant></sequential>
</target>
<target name="validate-maven-dependencies" description="Validates maven dependencies, licenses, etc">
<subant target="validate-maven-dependencies" inheritall="false" failonerror="true">
<fileset dir="lucene" includes="build.xml"/>
<fileset dir="solr" includes="build.xml"/>
</subant>
</target>
<target name="resolve" depends="clean-jars" description="Resolves all dependencies">
<sequential><subant target="resolve" inheritall="false" failonerror="true">
<fileset dir="lucene" includes="build.xml" />

View File

@ -45,6 +45,7 @@
<propertyset id="uptodate.and.compiled.properties" dynamic="true">
<propertyref regex=".*\.uptodate$$"/>
<propertyref regex=".*\.compiled$$"/>
<propertyref regex=".*\.loaded$$"/>
</propertyset>
<target name="common">
@ -106,10 +107,14 @@
<target name="build-artifacts-and-tests" depends="default,compile-test" />
<target name="dist-maven" depends="default,javadocs">
<target name="dist-maven">
<forall-analyzers target="dist-maven"/>
</target>
<target name="-validate-maven-dependencies">
<forall-analyzers target="-validate-maven-dependencies"/>
</target>
<target name="javadocs">
<forall-analyzers target="javadocs"/>
</target>

View File

@ -442,12 +442,8 @@
</target>
<!-- TODO: these dependencies are bogus: we only
call this from prepare-release so it shouldn't require
'package' and 'javadocs' again -->
<target name="generate-maven-artifacts"
depends="install-maven-tasks, filter-pom-templates, package, javadocs">
<!-- install-maven-tasks is *not* a useless dependency. do not remove -->
<target name="generate-maven-artifacts" depends="install-maven-tasks">
<sequential>
<subant target="dist-maven" failonerror="true" inheritall="false">
<propertyset refid="uptodate.and.compiled.properties"/>
@ -459,6 +455,18 @@
</sequential>
</target>
<target name="validate-maven-dependencies" depends="compile-tools, generate-maven-artifacts, load-custom-tasks">
<sequential>
<subant target="-validate-maven-dependencies" failonerror="true" inheritall="false">
<propertyset refid="uptodate.and.compiled.properties"/>
<fileset dir="${common.dir}/core" includes="build.xml"/>
<fileset dir="${common.dir}/test-framework" includes="build.xml"/>
</subant>
<modules-crawl target="-validate-maven-dependencies"/>
</sequential>
</target>
<!-- ================================================================== -->
<!-- support for signing the artifacts using gpg -->
<!-- ================================================================== -->

View File

@ -19,7 +19,8 @@
<project name="common" xmlns:artifact="antlib:org.apache.maven.artifact.ant"
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:junit4="antlib:com.carrotsearch.junit4">
xmlns:junit4="antlib:com.carrotsearch.junit4"
xmlns:rsel="antlib:org.apache.tools.ant.types.resources.selectors">
<description>
This file is designed for importing into a main build file, and not intended
for standalone use.
@ -29,6 +30,7 @@
<property name="dev-tools.dir" value="${common.dir}/../dev-tools"/>
<property name="prettify.dir" value="${common.dir}/tools/prettify"/>
<property name="maven.build.dir" value="${build.dir}/maven"/>
<property name="license.dir" value="${common.dir}/licenses"/>
<!-- Give user a chance to override without editing this file
(and without typing -D each time it compiles it -->
@ -172,6 +174,7 @@
<property name="maven.dist.dir" location="${dist.dir}/maven"/>
<makeurl file="${maven.dist.dir}" property="m2.repository.url" validate="false"/>
<property name="m2.repository.private.key" value="${user.home}/.ssh/id_dsa"/>
<property name="m2.repository.id" value="local"/>
<property name="jflex.home" location="${common.dir}"/>
@ -233,6 +236,7 @@
<propertyset id="uptodate.and.compiled.properties" dynamic="true">
<propertyref regex=".*\.uptodate$$"/>
<propertyref regex=".*\.compiled$$"/>
<propertyref regex=".*\.loaded$$"/>
</propertyset>
<patternset id="lucene.local.src.package.patterns"
@ -457,6 +461,39 @@
</sequential>
</macrodef>
<!-- validate maven dependencies -->
<macrodef name="m2-validate-dependencies">
<attribute name="pom.xml"/>
<attribute name="licenseDirectory"/>
<element name="excludes" optional="true"/>
<element name="additional-filters" optional="true"/>
<sequential>
<artifact:dependencies filesetId="maven.fileset" useScope="test" type="jar">
<artifact:pom file="@{pom.xml}"/>
<remoteRepository id="apache.snapshots" url="${m2.repository.url}">
<snapshots enabled="true" updatePolicy="always"/>
<releases enabled="false"/>
</remoteRepository>
</artifact:dependencies>
<licenses licenseDirectory="@{licenseDirectory}">
<restrict>
<fileset refid="maven.fileset"/>
<rsel:not>
<excludes/>
</rsel:not>
</restrict>
<licenseMapper>
<chainedmapper>
<filtermapper refid="license-mapper-defaults"/>
<filtermapper>
<additional-filters/>
</filtermapper>
</chainedmapper>
</licenseMapper>
</licenses>
</sequential>
</macrodef>
<macrodef name="build-manifest" description="Builds a manifest file">
<attribute name="title"/>
<attribute name="implementation.title"/>
@ -1232,6 +1269,24 @@ ${tests-output}/junit4-*.suites - per-JVM executed suites
</sequential>
</target>
<target name="-validate-maven-dependencies">
<property name="top.level.dir" location="${common.dir}/.."/>
<pathconvert property="pom.xml">
<mapper>
<chainedmapper>
<globmapper from="${top.level.dir}*" to="${filtered.pom.templates.dir}*"/>
<globmapper from="*build.xml" to="*pom.xml"/>
</chainedmapper>
</mapper>
<path location="${ant.file}"/>
</pathconvert>
<m2-validate-dependencies pom.xml="${pom.xml}" licenseDirectory="${license.dir}">
<excludes>
<rsel:name name="**/lucene-*.jar" handledirsep="true"/>
</excludes>
</m2-validate-dependencies>
</target>
<target name="filter-pom-templates" unless="filtered.pom.templates.uptodate">
<mkdir dir="${filtered.pom.templates.dir}"/>
<copy todir="${common.dir}/build/poms" overwrite="true">

View File

@ -16,6 +16,23 @@
<property name="custom-tasks.loaded" value="true"/>
</target>
<filtermapper id="license-mapper-defaults">
<!-- Normalize input paths. -->
<replacestring from="\" to="/" />
<replaceregex pattern="\.jar$" replace="" flags="gi" />
<!-- Some typical snapshot/minimalized JAR suffixes. -->
<replaceregex pattern="-min$" replace="" flags="gi" />
<replaceregex pattern="SNAPSHOT$" replace="" flags="gi" />
<!-- Typical version patterns. -->
<replaceregex pattern="\.rc[0-9]+" replace="" flags="gi" />
<replaceregex pattern="\-(r)?([0-9\-\_\.])+(b(eta)?([0-9\-\.])*)?$" replace="" flags="gi" />
<!-- git hashcode pattern: its always 40 chars right? -->
<replaceregex pattern="\-[a-z0-9]{40,40}$" replace="" flags="gi" />
</filtermapper>
<macrodef name="license-check-macro">
<attribute name="dir" />
<attribute name="licensedir" />
@ -38,25 +55,13 @@
</fileset>
<licenseMapper>
<filtermapper id="license-mapper-defaults">
<!-- Normalize input paths. -->
<replacestring from="\" to="/" />
<replaceregex pattern="\.jar$" replace="" flags="gi" />
<!-- Some typical snapshot/minimalized JAR suffixes. -->
<replaceregex pattern="-min$" replace="" flags="gi" />
<replaceregex pattern="SNAPSHOT$" replace="" flags="gi" />
<!-- Non-typical version patterns. -->
<additional-filters />
<!-- Typical version patterns. -->
<replaceregex pattern="\.rc[0-9]+" replace="" flags="gi" />
<replaceregex pattern="\-(r)?([0-9\-\_\.])+(b(eta)?([0-9\-\.])*)?$" replace="" flags="gi" />
<!-- git hashcode pattern: its always 40 chars right? -->
<replaceregex pattern="\-[a-z0-9]{40,40}$" replace="" flags="gi" />
</filtermapper>
<chainedmapper>
<filtermapper refid="license-mapper-defaults"/>
<filtermapper>
<!-- Non-typical version patterns. -->
<additional-filters />
</filtermapper>
</chainedmapper>
</licenseMapper>
</licenses>
</sequential>

View File

@ -202,7 +202,6 @@
</additional-excludes>
<additional-filters>
<replaceregex pattern="jetty([^/]+)$" replace="jetty" flags="gi" />
<replaceregex pattern="apache-solr-commons-csv-([^/]+)$" replace="apache-solr-commons-csv" flags="gi" />
<replaceregex pattern="slf4j-([^/]+)$" replace="slf4j" flags="gi" />
<replaceregex pattern="(bcmail|bcprov)-([^/]+)$" replace="\1" flags="gi" />
</additional-filters>
@ -554,6 +553,7 @@
<check-broken-links dir="build/docs"/>
</target>
<!-- install-maven-tasks is *not* a useless dependency. do not remove -->
<target name="generate-maven-artifacts" depends="install-maven-tasks">
<sequential>
<subant target="dist-maven" inheritall="false" >
@ -566,8 +566,28 @@
<contrib-crawl target="dist-maven"/>
</sequential>
</target>
<!-- only used by validate below, it needs the lucene artifacts installed: can we do this better?! -->
<target name="-generate-lucene-maven-artifacts">
<subant target="generate-maven-artifacts" inheritall="false">
<propertyset refid="uptodate.and.compiled.properties"/>
<fileset dir="${common.dir}" includes="build.xml"/>
</subant>
</target>
<target name="validate-maven-dependencies" depends="compile-tools, generate-maven-artifacts, -generate-lucene-maven-artifacts, load-custom-tasks">
<sequential>
<subant target="-validate-maven-dependencies" failonerror="true" inheritall="false">
<propertyset refid="uptodate.and.compiled.properties"/>
<fileset dir="core" includes="build.xml"/>
<fileset dir="solrj" includes="build.xml"/>
<fileset dir="test-framework" includes="build.xml"/>
<fileset dir="webapp" includes="build.xml"/>
</subant>
<contrib-crawl target="-validate-maven-dependencies"/>
</sequential>
</target>
<!-- ========================================================================= -->
<!-- ========================= COMMITTERS' HELPERS =========================== -->
<!-- ========================================================================= -->

View File

@ -15,7 +15,7 @@
limitations under the License.
-->
<project name="common-solr" default="default">
<project name="common-solr" default="default" xmlns:rsel="antlib:org.apache.tools.ant.types.resources.selectors">
<description>
This file is designed for importing into a main build file, and not intended
for standalone use.
@ -50,6 +50,7 @@
<property name="tests.cleanthreads.sysprop" value="perClass"/>
<property name="changes.target.dir" value="${dest}/docs/changes"/>
<property name="license.dir" value="${common-solr.dir}/licenses"/>
<import file="${common-solr.dir}/../lucene/module-build.xml"/>
@ -276,6 +277,34 @@
<target name="dist-maven"
depends="filter-pom-templates, install-maven-tasks, m2-deploy-solr-parent-pom, dist-maven-common"/>
<target name="-validate-maven-dependencies">
<property name="top.level.dir" location="${common.dir}/.."/>
<pathconvert property="pom.xml">
<mapper>
<chainedmapper>
<globmapper from="${top.level.dir}*" to="${filtered.pom.templates.dir}*"/>
<globmapper from="*build.xml" to="*pom.xml"/>
</chainedmapper>
</mapper>
<path location="${ant.file}"/>
</pathconvert>
<m2-validate-dependencies pom.xml="${pom.xml}" licenseDirectory="${license.dir}">
<additional-filters>
<replaceregex pattern="jetty([^/]+)$" replace="jetty" flags="gi" />
<replaceregex pattern="slf4j-([^/]+)$" replace="slf4j" flags="gi" />
<replaceregex pattern="(bcmail|bcprov)-([^/]+)$" replace="\1" flags="gi" />
</additional-filters>
<excludes>
<rsel:or>
<rsel:name name="**/lucene-*.jar" handledirsep="true"/>
<rsel:name name="**/solr-*.jar" handledirsep="true"/>
<!-- TODO: figure out what is going on here with servlet-apis -->
<rsel:name name="**/*servlet*.jar" handledirsep="true"/>
</rsel:or>
</excludes>
</m2-validate-dependencies>
</target>
<!-- Solr core targets -->
<target name="compile-solr-core" description="Compile Solr core." unless="solr.core.compiled">
<ant dir="${common-solr.dir}/core" target="compile-core" inheritAll="false">