LUCENE-7292: Use '-release' instead of '-source/-target' during compilation on Java 9+ to ensure real cross-compilation

This commit is contained in:
Uwe Schindler 2016-05-20 22:20:39 +02:00
parent 76d4dea086
commit 7bd6d94952
8 changed files with 47 additions and 69 deletions

View File

@ -43,8 +43,10 @@
<vc-browse-base-url>https://git1-us-west.apache.org/repos/asf?p=lucene-solr.git;a=tree</vc-browse-base-url> <vc-browse-base-url>https://git1-us-west.apache.org/repos/asf?p=lucene-solr.git;a=tree</vc-browse-base-url>
<specification.version>@spec.version@</specification.version> <specification.version>@spec.version@</specification.version>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format> <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
<java.compat.version>1.8</java.compat.version> <java.compat.version>8</java.compat.version>
<jetty.version>8.1.10.v20130312</jetty.version> <!-- HACK: the enforce and forbiddenapis plugin does not like new versioning: -->
<java.legacy-compat.version>1.${java.compat.version}</java.legacy-compat.version>
<jetty.version>9.3.8.v20160314</jetty.version>
<!-- RandomizedTesting library system properties --> <!-- RandomizedTesting library system properties -->
<tests.iters>1</tests.iters> <tests.iters>1</tests.iters>
@ -166,7 +168,7 @@
The checker simply passes by default and only prints a warning. The checker simply passes by default and only prints a warning.
--> -->
<failOnUnsupportedJava>false</failOnUnsupportedJava> <failOnUnsupportedJava>false</failOnUnsupportedJava>
<targetVersion>${java.compat.version}</targetVersion> <targetVersion>${java.legacy-compat.version}</targetVersion>
<suppressAnnotations> <suppressAnnotations>
<suppressAnnotation>**.SuppressForbidden</suppressAnnotation> <suppressAnnotation>**.SuppressForbidden</suppressAnnotation>
</suppressAnnotations> </suppressAnnotations>
@ -381,7 +383,7 @@
<rules> <rules>
<requireJavaVersion> <requireJavaVersion>
<message>Java ${java.compat.version}+ is required.</message> <message>Java ${java.compat.version}+ is required.</message>
<version>[${java.compat.version},)</version> <version>[${java.legacy-compat.version},)</version>
</requireJavaVersion> </requireJavaVersion>
<requireMavenVersion> <requireMavenVersion>
<message>Maven 2.2.1+ is required.</message> <message>Maven 2.2.1+ is required.</message>

View File

@ -189,11 +189,11 @@ def checkJARMetaData(desc, jarFile, gitRevision, version):
'Specification-Vendor: The Apache Software Foundation', 'Specification-Vendor: The Apache Software Foundation',
'Implementation-Vendor: The Apache Software Foundation', 'Implementation-Vendor: The Apache Software Foundation',
# Make sure 1.8 compiler was used to build release bits: # Make sure 1.8 compiler was used to build release bits:
'X-Compile-Source-JDK: 1.8', 'X-Compile-Source-JDK: 8',
# Make sure 1.8 ant was used to build release bits: (this will match 1.8+) # Make sure 1.8 ant was used to build release bits: (this will match 1.8+)
'Ant-Version: Apache Ant 1.8', 'Ant-Version: Apache Ant 1.8',
# Make sure .class files are 1.8 format: # Make sure .class files are 1.8 format:
'X-Compile-Target-JDK: 1.8', 'X-Compile-Target-JDK: 8',
'Specification-Version: %s' % version, 'Specification-Version: %s' % version,
# Make sure the release was compiled with 1.8: # Make sure the release was compiled with 1.8:
'Created-By: 1.8'): 'Created-By: 1.8'):

View File

@ -133,6 +133,12 @@ Other
* SOLR-9109/SOLR-9121: Allow specification of a custom Ivy settings file via system * SOLR-9109/SOLR-9121: Allow specification of a custom Ivy settings file via system
property "ivysettings.xml". (Misha Dmitriev, Christine Poerschke, Uwe Schindler, Steve Rowe) property "ivysettings.xml". (Misha Dmitriev, Christine Poerschke, Uwe Schindler, Steve Rowe)
Build
* LUCENE-7292: Use '-release' instead of '-source/-target' during
compilation on Java 9+ to ensure real cross-compilation.
(Uwe Schindler)
======================= Lucene 6.0.1 ======================= ======================= Lucene 6.0.1 =======================
(No Changes) (No Changes)

View File

@ -161,9 +161,8 @@
<property name="javac.deprecation" value="off"/> <property name="javac.deprecation" value="off"/>
<property name="javac.debug" value="on"/> <property name="javac.debug" value="on"/>
<property name="javac.source" value="1.8"/> <property name="javac.release" value="8"/>
<property name="javac.target" value="1.8"/> <property name="javac.args" value="-Xlint -Xlint:-deprecation -Xlint:-serial"/>
<property name="javac.args" value="-Xlint -Xlint:-deprecation -Xlint:-serial -Xlint:-options"/>
<property name="javac.profile.args" value="-profile compact2"/> <property name="javac.profile.args" value="-profile compact2"/>
<property name="javadoc.link" value="https://docs.oracle.com/javase/8/docs/api/"/> <property name="javadoc.link" value="https://docs.oracle.com/javase/8/docs/api/"/>
<property name="javadoc.link.junit" value="http://junit.sourceforge.net/javadoc/"/> <property name="javadoc.link.junit" value="http://junit.sourceforge.net/javadoc/"/>
@ -178,34 +177,6 @@
<property name="javadoc.doclint.args" value="-Xdoclint:all -Xdoclint:-missing"/> <property name="javadoc.doclint.args" value="-Xdoclint:all -Xdoclint:-missing"/>
<property name="javac.doclint.args" value="-Xdoclint:all/protected -Xdoclint:-missing"/> <property name="javac.doclint.args" value="-Xdoclint:all/protected -Xdoclint:-missing"/>
<!-- detect bootclasspath from given bootjdk path (including crazy AppleJDK special case) -->
<first id="-boot-rt.jar">
<fileset dir="${bootjdk}" erroronmissingdir="false" followsymlinks="true">
<include name="jre/lib/rt.jar" /><!-- Oracle JDK -->
<include name="lib/rt.jar" /><!-- Oracle JRE -->
<include name="bundle/Classes/classes.jar" /><!-- Apple JDK -->
</fileset>
</first>
<property name="bootclasspath" value="${toString:-boot-rt.jar}" />
<fail message="Invalid 'bootjdk' parameter, because it contains no class library JAR: ${bootjdk}">
<condition>
<and>
<isset property="bootjdk" />
<equals arg1="${bootclasspath}" arg2=""/>
</and>
</condition>
</fail>
<fail message="Invalid 'bootclasspath' parameter, because it does not point to a valid class library JAR: ${bootclasspath}">
<condition>
<not>
<or>
<equals arg1="${bootclasspath}" arg2=""/>
<available classname="java.lang.StringBuilder" classpath="${bootclasspath}" ignoresystemclasses="true"/>
</or>
</not>
</condition>
</fail>
<!-- Javadoc classpath --> <!-- Javadoc classpath -->
<path id="javadoc.classpath"> <path id="javadoc.classpath">
<path refid="classpath"/> <path refid="classpath"/>
@ -691,8 +662,8 @@
value="${version} ${checkoutid} - ${user.name} - ${DSTAMP} ${TSTAMP}"/> value="${version} ${checkoutid} - ${user.name} - ${DSTAMP} ${TSTAMP}"/>
<attribute name="Implementation-Vendor" <attribute name="Implementation-Vendor"
value="The Apache Software Foundation"/> value="The Apache Software Foundation"/>
<attribute name="X-Compile-Source-JDK" value="${javac.source}"/> <attribute name="X-Compile-Source-JDK" value="${javac.release}"/>
<attribute name="X-Compile-Target-JDK" value="${javac.target}"/> <attribute name="X-Compile-Target-JDK" value="${javac.release}"/>
<additional-manifest-attributes /> <additional-manifest-attributes />
</manifest> </manifest>
</sequential> </sequential>
@ -828,14 +799,12 @@
<attribute name="srcdir"/> <attribute name="srcdir"/>
<attribute name="destdir"/> <attribute name="destdir"/>
<attribute name="test.classpath"/> <attribute name="test.classpath"/>
<attribute name="javac.source" default="${javac.source}"/> <attribute name="javac.release" default="${javac.release}"/>
<attribute name="javac.target" default="${javac.target}"/>
<sequential> <sequential>
<compile <compile
srcdir="@{srcdir}" srcdir="@{srcdir}"
destdir="@{destdir}" destdir="@{destdir}"
javac.source="@{javac.source}" javac.release="@{javac.release}">
javac.target="@{javac.source}">
<classpath refid="@{test.classpath}"/> <classpath refid="@{test.classpath}"/>
</compile> </compile>
@ -1950,29 +1919,30 @@ ${ant.project.name}.test.dependencies=${test.classpath.list}
<macrodef name="compile"> <macrodef name="compile">
<attribute name="srcdir"/> <attribute name="srcdir"/>
<attribute name="destdir"/> <attribute name="destdir"/>
<attribute name="javac.source" default="${javac.source}"/> <attribute name="javac.release" default="${javac.release}"/>
<attribute name="javac.target" default="${javac.target}"/>
<attribute name="includeantruntime" default="${javac.includeAntRuntime}" /> <attribute name="includeantruntime" default="${javac.includeAntRuntime}" />
<element name="nested" implicit="yes" optional="yes"/> <element name="nested" implicit="yes" optional="yes"/>
<sequential> <sequential>
<local name="javac.release.args"/>
<condition property="javac.release.args" value="-source @{javac.release} -target @{javac.release}" else="-release @{javac.release}">
<equals arg1="${build.java.runtime}" arg2="1.8"/>
</condition>
<mkdir dir="@{destdir}"/> <mkdir dir="@{destdir}"/>
<javac <javac
includeAntRuntime="@{includeantruntime}" includeAntRuntime="@{includeantruntime}"
encoding="${build.encoding}" encoding="${build.encoding}"
bootclasspath="${bootclasspath}"
srcdir="@{srcdir}" srcdir="@{srcdir}"
destdir="@{destdir}" destdir="@{destdir}"
deprecation="${javac.deprecation}" deprecation="${javac.deprecation}"
debug="${javac.debug}" debug="${javac.debug}">
source="@{javac.source}"
target="@{javac.target}">
<nested/> <nested/>
<!-- <compilerarg line="-Xmaxwarns 10000000"/> <!-- <compilerarg line="-Xmaxwarns 10000000"/>
<compilerarg line="-Xmaxerrs 10000000"/> --> <compilerarg line="-Xmaxerrs 10000000"/> -->
<compilerarg line="${javac.args}"/> <compilerarg line="${javac.args}"/>
<compilerarg line="${javac.profile.args}"/> <compilerarg line="${javac.profile.args}"/>
<compilerarg line="${javac.release.args}"/>
<compilerarg line="${javac.doclint.args}"/> <compilerarg line="${javac.doclint.args}"/>
</javac> </javac>
</sequential> </sequential>
@ -2024,7 +1994,7 @@ ${ant.project.name}.test.dependencies=${test.classpath.list}
<macrodef name="ecj-macro"> <macrodef name="ecj-macro">
<attribute name="srcdir"/> <attribute name="srcdir"/>
<attribute name="javac.source" default="${javac.source}"/> <attribute name="javac.release" default="${javac.release}"/>
<attribute name="includeantruntime" default="${javac.includeAntRuntime}" /> <attribute name="includeantruntime" default="${javac.includeAntRuntime}" />
<attribute name="configuration"/> <attribute name="configuration"/>
@ -2040,8 +2010,8 @@ ${ant.project.name}.test.dependencies=${test.classpath.list}
encoding="${build.encoding}" encoding="${build.encoding}"
srcdir="@{srcdir}" srcdir="@{srcdir}"
destdir="${ecj.trash.out}" destdir="${ecj.trash.out}"
source="@{javac.source}" source="@{javac.release}"
target="@{javac.source}" target="@{javac.release}"
taskname="ecj-lint"> taskname="ecj-lint">
<ecj-component/> <ecj-component/>
<nested/> <nested/>
@ -2085,13 +2055,16 @@ ${ant.project.name}.test.dependencies=${test.classpath.list}
<attribute name="overview" default="${src.dir}/overview.html"/> <attribute name="overview" default="${src.dir}/overview.html"/>
<attribute name="linksource" default="no"/> <attribute name="linksource" default="no"/>
<sequential> <sequential>
<local name="javadoc.release.args"/>
<condition property="javadoc.release.args" value="-source ${javac.release}" else="-release ${javac.release}">
<equals arg1="${build.java.runtime}" arg2="1.8"/>
</condition>
<antcall target="download-java8-javadoc-packagelist"/> <antcall target="download-java8-javadoc-packagelist"/>
<delete file="@{destdir}/stylesheet.css" failonerror="false"/> <delete file="@{destdir}/stylesheet.css" failonerror="false"/>
<copy todir="@{destdir}" file="${prettify.dir}/prettify.js" overwrite="false" /> <copy todir="@{destdir}" file="${prettify.dir}/prettify.js" overwrite="false" />
<record name="@{destdir}/log_javadoc.txt" action="start" append="no"/> <record name="@{destdir}/log_javadoc.txt" action="start" append="no"/>
<javadoc <javadoc
overview="@{overview}" overview="@{overview}"
bootclasspath="${bootclasspath}"
packagenames="org.apache.lucene.*,org.apache.solr.*" packagenames="org.apache.lucene.*,org.apache.solr.*"
destdir="@{destdir}" destdir="@{destdir}"
access="${javadoc.access}" access="${javadoc.access}"
@ -2105,7 +2078,6 @@ ${ant.project.name}.test.dependencies=${test.classpath.list}
linksource="@{linksource}" linksource="@{linksource}"
use="true" use="true"
failonerror="true" failonerror="true"
source="${javac.source}"
locale="en_US" locale="en_US"
windowtitle="${Name} ${version} API" windowtitle="${Name} ${version} API"
doctitle="@{title}" doctitle="@{title}"
@ -2137,6 +2109,7 @@ ${ant.project.name}.test.dependencies=${test.classpath.list}
<sources /> <sources />
<classpath refid="javadoc.classpath"/> <classpath refid="javadoc.classpath"/>
<arg line="${javadoc.release.args}"/>
<arg line="${javadoc.doclint.args}"/> <arg line="${javadoc.doclint.args}"/>
</javadoc> </javadoc>
<record name="@{destdir}/log_javadoc.txt" action="stop"/> <record name="@{destdir}/log_javadoc.txt" action="stop"/>
@ -2389,8 +2362,9 @@ ${ant.project.name}.test.dependencies=${test.classpath.list}
<target name="-check-forbidden-all" depends="-init-forbidden-apis,compile-core,compile-test"> <target name="-check-forbidden-all" depends="-init-forbidden-apis,compile-core,compile-test">
<forbidden-apis internalRuntimeForbidden="true" suppressAnnotation="**.SuppressForbidden" classpathref="forbidden-apis.allclasses.classpath"> <forbidden-apis internalRuntimeForbidden="true" suppressAnnotation="**.SuppressForbidden" classpathref="forbidden-apis.allclasses.classpath">
<signatures> <signatures>
<bundled name="jdk-unsafe-${javac.target}"/> <!-- TODO: fix this in forbiddenapis 2.1+ -->
<bundled name="jdk-deprecated-${javac.target}"/> <bundled name="jdk-unsafe-1.${javac.release}"/>
<bundled name="jdk-deprecated-1.${javac.release}"/>
<fileset dir="${common.dir}/tools/forbiddenApis"> <fileset dir="${common.dir}/tools/forbiddenApis">
<include name="base.txt"/> <include name="base.txt"/>
<include name="lucene.txt" if="forbidden-isLucene"/> <include name="lucene.txt" if="forbidden-isLucene"/>

View File

@ -36,9 +36,6 @@
<ibiblio name="maven.restlet.org" root="http://maven.restlet.org" m2compatible="true" /> <ibiblio name="maven.restlet.org" root="http://maven.restlet.org" m2compatible="true" />
<ibiblio name="releases.cloudera.com" root="http://repository.cloudera.com/content/repositories/releases" m2compatible="true" /> <ibiblio name="releases.cloudera.com" root="http://repository.cloudera.com/content/repositories/releases" m2compatible="true" />
<!-- needed only for newer svnkit releases, e.g. 1.8.x -->
<ibiblio name="svnkit-releases" root="http://maven.tmatesoft.com/content/repositories/releases" m2compatible="true" />
<!-- you might need to tweak this from china so it works --> <!-- you might need to tweak this from china so it works -->
<ibiblio name="working-chinese-mirror" root="http://uk.maven.org/maven2" m2compatible="true" /> <ibiblio name="working-chinese-mirror" root="http://uk.maven.org/maven2" m2compatible="true" />
@ -56,7 +53,6 @@
<resolver ref="maven.restlet.org" /> <resolver ref="maven.restlet.org" />
<resolver ref="sonatype-releases" /> <resolver ref="sonatype-releases" />
<resolver ref="releases.cloudera.com"/> <resolver ref="releases.cloudera.com"/>
<!-- <resolver ref="svnkit-releases" /> -->
<resolver ref="working-chinese-mirror" /> <resolver ref="working-chinese-mirror" />
</chain> </chain>
</resolvers> </resolvers>

View File

@ -165,7 +165,7 @@ import org.apache.lucene.queryparser.flexible.core.messages.*;"
target="@{target}" target="@{target}"
outputDirectory="@{outputDir}" outputDirectory="@{outputDir}"
javacchome="${build.dir}/javacc" javacchome="${build.dir}/javacc"
jdkversion="${javac.source}" jdkversion="1.${javac.release}"
/> />
<fixcrlf srcdir="@{outputDir}" includes="*.java" encoding="UTF-8"> <fixcrlf srcdir="@{outputDir}" includes="*.java" encoding="UTF-8">
<containsregexp expression="Generated.*By.*JavaCC"/> <containsregexp expression="Generated.*By.*JavaCC"/>

View File

@ -25,10 +25,9 @@
<property name="Name" value="Solr" /> <property name="Name" value="Solr" />
<!-- solr uses 1.8 --> <!-- solr uses Java 8 -->
<property name="javac.source" value="1.8"/> <property name="javac.release" value="8"/>
<property name="javac.target" value="1.8"/> <property name="javac.args" value="-Xlint:-deprecation"/>
<property name="javac.args" value="-Xlint:-deprecation -Xlint:-options"/>
<property name="javac.profile.args" value=""/> <property name="javac.profile.args" value=""/>
<property name="dest" location="${common-solr.dir}/build" /> <property name="dest" location="${common-solr.dir}/build" />
@ -508,8 +507,9 @@
<property prefix="ivyversions" file="${common.dir}/ivy-versions.properties"/> <!-- for commons-io version --> <property prefix="ivyversions" file="${common.dir}/ivy-versions.properties"/> <!-- for commons-io version -->
<forbidden-apis internalRuntimeForbidden="true" suppressAnnotation="**.SuppressForbidden" classpathref="forbidden-apis.allclasses.classpath"> <forbidden-apis internalRuntimeForbidden="true" suppressAnnotation="**.SuppressForbidden" classpathref="forbidden-apis.allclasses.classpath">
<signatures> <signatures>
<bundled name="jdk-unsafe-${javac.target}"/> <!-- TODO: fix this in forbiddenapis 2.1+ -->
<bundled name="jdk-deprecated-${javac.target}"/> <bundled name="jdk-unsafe-1.${javac.release}"/>
<bundled name="jdk-deprecated-1.${javac.release}"/>
<bundled name="commons-io-unsafe-${ivyversions./commons-io/commons-io}"/> <bundled name="commons-io-unsafe-${ivyversions./commons-io/commons-io}"/>
<fileset dir="${common.dir}/tools/forbiddenApis"> <fileset dir="${common.dir}/tools/forbiddenApis">
<include name="base.txt" /> <include name="base.txt" />

View File

@ -110,7 +110,7 @@
target="@{target}" target="@{target}"
outputDirectory="@{outputDir}" outputDirectory="@{outputDir}"
javacchome="${build.dir}/javacc" javacchome="${build.dir}/javacc"
jdkversion="${javac.source}" jdkversion="1.${javac.release}"
/> />
<fixcrlf srcdir="@{outputDir}" includes="*.java" encoding="UTF-8"> <fixcrlf srcdir="@{outputDir}" includes="*.java" encoding="UTF-8">
<containsregexp expression="Generated.*By.*JavaCC"/> <containsregexp expression="Generated.*By.*JavaCC"/>