You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2009/01/13 22:07:14 UTC
svn commit: r734242 - in /db/derby/code/trunk: BUILDING.html build.xml
java/build/org/apache/derbyPreBuild/PropertySetter.java
Author: rhillegas
Date: Tue Jan 13 13:07:02 2009
New Revision: 734242
URL: http://svn.apache.org/viewvc?rev=734242&view=rev
Log:
DERBY-3989: Allow the build to succeed on machines which have a Java 6 environment but not a Java 5 environment.
Modified:
db/derby/code/trunk/BUILDING.html
db/derby/code/trunk/build.xml
db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertySetter.java
Modified: db/derby/code/trunk/BUILDING.html
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/BUILDING.html?rev=734242&r1=734241&r2=734242&view=diff
==============================================================================
--- db/derby/code/trunk/BUILDING.html (original)
+++ db/derby/code/trunk/BUILDING.html Tue Jan 13 13:07:02 2009
@@ -85,8 +85,7 @@
<TR>
<TD><b><i>Java Development Kit</i></b></TD>
<TD>You need to install a Java 5 or later JDK. Probably, your machine
- already has this JDK. If not, Sun and IBM supply free Java
- 5 JDKs for many machines.</TD>
+ already has this JDK. If not, Sun and IBM supply free JDKs for many machines.</TD>
</TR>
<TR>
@@ -453,25 +452,28 @@
<TR>
<TD><b><i>Java 6</i></b></TD>
<TD><b><i>java16compile.classpath</i></b></TD>
- <TD>If you have a Java 6 JDK on your machine, this should be the list of all the
- Java 6 jars. Sun and IBM provide free Java 6 JDKs for many machines.</TD>
- <TD><i>classes/stubs/jdbc4:${java15compile.classpath}</i></TD>
+ <TD>The Derby build tries to find a Java 6
+ JDK on your machine. The build fails if it can't find a Java 5
+ or Java 6 JDK.</TD>
+ <TD>The list of jars in your Java 6 JDK if the build can find them. Otherwise,
+ <i>classes/stubs/jdbc4:${java15compile.classpath}</i></TD>
</TR>
<TR>
<TD><b><i>Java 5</i></b></TD>
<TD><b><i>java15compile.classpath</i></b></TD>
<TD>The Derby build tries to find a Java 5
- JDK on your machine. The build fails if it can't find this JDK.</TD>
- <TD>The jars in your Java 5 JDK.</TD>
+ JDK on your machine. The build fails if it can't find a Java 5
+ or Java 6 JDK.</TD>
+ <TD>The list of jars in your Java 5 JDK if the build can find them. Otherwise,
+ <i>classes/stubs/jdbc3:${java16compile.classpath}</i></TD>
</TR>
<TR>
<TD><b><i>JDK 1.4.2</i></b></TD>
<TD><b><i>java14compile.classpath</i></b></TD>
<TD>The Derby build tries to find a 1.4 JDK
- on your machine. If the build finds that JDK, then this
- variable is set to the list of jars there. Again, Sun and IBM supply free 1.4.2 JDKs for many machines.</TD>
+ on your machine. Note that Sun and IBM supply free 1.4.2 JDKs for many machines.</TD>
<TD>The list of jars in your 1.4 JDK if the build can find
them. Otherwise,
<i>${java15compile.classpath}:tools/java/xalan.jar:tools/java/serializer.jar</i>
@@ -531,6 +533,15 @@
<TD>Optional variable. No default value.</TD>
</TR>
+ <TR>
+ <TD><b><i>j16lib</i></b></TD>
+ <TD>If you set this variable to be the directory which contains
+ your Java 6 jars, then the Derby build will set
+ <i>java16compile.classpath</i> to be the list of jars in that directory.
+ </TD>
+ <TD>Optional variable. No default value.</TD>
+ </TR>
+
</TBODY>
</TABLE>
Modified: db/derby/code/trunk/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/build.xml?rev=734242&r1=734241&r2=734242&view=diff
==============================================================================
--- db/derby/code/trunk/build.xml (original)
+++ db/derby/code/trunk/build.xml Tue Jan 13 13:07:02 2009
@@ -196,6 +196,10 @@
classpath="${out.dir}"
/>
+ <!--
+ After setting the JDK properties, we expect that java15compile.classpath or
+ java16compile.classpath will be set. If neither is set, PropertySetter aborts the build.
+ -->
<setJdkProperties/>
<property file="${properties.dir}/defaultcompiler.properties"/>
@@ -203,12 +207,18 @@
<!-- Compile-time classpath`< properties files -->
<property file="${properties.dir}/extrapath.properties"/>
+
<!--
If a Java 6 JDK isn't present, then use the Java 5 environment to build the JDBC 4 support
-->
<property name="java16compile.classpath" value="${out.jdbc4.dir}:${java15compile.classpath}"/>
<!--
+ If a Java 5 JDK isn't present, then use the Java 6 environment to build the Java 5 support
+ -->
+ <property name="java15compile.classpath" value="${out.jdbc3.dir}:${java16compile.classpath}"/>
+
+ <!--
If a 1.4 JDK is not present, then use the Java 5 environment to build the 1.4 support
-->
<property name="java14compile.classpath" value="${java15compile.classpath}:${xalan}:${serializer}"/>
@@ -255,6 +265,7 @@
<echo message="${checkEvent} java14compile.classpath = ${java14compile.classpath}"/>
<echo message="${checkEvent} j15lib = ${j15lib}"/>
<echo message="${checkEvent} java15compile.classpath = ${java15compile.classpath}"/>
+ <echo message="${checkEvent} j16lib = ${j16lib}"/>
<echo message="${checkEvent} java16compile.classpath = ${java16compile.classpath}"/>
</target>
Modified: db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertySetter.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertySetter.java?rev=734242&r1=734241&r2=734242&view=diff
==============================================================================
--- db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertySetter.java (original)
+++ db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertySetter.java Tue Jan 13 13:07:02 2009
@@ -46,6 +46,7 @@
* <ul>
* <li>java14compile.classpath</li>
* <li>java15compile.classpath</li>
+ * <li>java16compile.classpath</li>
* </ul>
*
* <p>
@@ -56,6 +57,7 @@
* <ul>
* <li>j14lib</li>
* <li>j15lib</li>
+ * <li>j16lib</li>
* </ul>
*
* <p>
@@ -113,6 +115,8 @@
private static final String JAVA_5 = "1.5";
+ private static final String PROPERTY_SETTER_DEBUG_FLAG = "propertySetterDebug";
+
/////////////////////////////////////////////////////////////////////////
//
// STATE
@@ -194,6 +198,11 @@
{
refreshProperties();
+ if ( isSet( PROPERTY_SETTER_DEBUG_FLAG ) )
+ {
+ echo( "\nPropertySetter environment =\n\n" + showEnvironment() + "\n\n" );
+ }
+
try {
//
// Check for settings which are known to cause problems.
@@ -203,7 +212,7 @@
//
// There's nothing to do if the classpath properties are already set.
//
- if ( isSet( J14CLASSPATH ) && isSet( J15CLASSPATH ) ) { return; }
+ if ( isSet( J14CLASSPATH ) && isSet( J15CLASSPATH ) && isSet( J16CLASSPATH ) ) { return; }
//
// If the library properties are set, then use them to set the
@@ -211,9 +220,11 @@
//
String j14lib = getProperty( J14LIB );
String j15lib = getProperty( J15LIB );
+ String j16lib = getProperty( J16LIB );
if ( j14lib != null ) { setClasspathFromLib(J14CLASSPATH, j14lib, true ); }
if ( j15lib != null ) { setClasspathFromLib(J15CLASSPATH, j15lib, true ); }
+ if ( j16lib != null ) { setClasspathFromLib(J16CLASSPATH, j16lib, true ); }
//
// If the library properties were not set, the following
@@ -249,8 +260,8 @@
// then the calling script will set J14CLASSPATH, based on J15CLASSPATH.
//
- // Require that these be set now.
- requireProperty( J15CLASSPATH );
+ // Require that at least one of these be set now.
+ requireAtLeastOneProperty( J15CLASSPATH, J16CLASSPATH );
}
/////////////////////////////////////////////////////////////////////////
@@ -267,7 +278,7 @@
private void setForAppleJDKs()
throws BuildException
{
- defaultSetter( APPLE_JAVA_ROOT + "/1.4/Classes", APPLE_JAVA_ROOT + "/1.5/Classes" );
+ defaultSetter( APPLE_JAVA_ROOT + "/1.4/Classes", APPLE_JAVA_ROOT + "/1.5/Classes", APPLE_JAVA_ROOT + "/1.6/Classes" );
}
/////////////////////////////////////////////////////////////////////////
@@ -284,7 +295,7 @@
private void setForIbmJDKs()
throws Exception
{
- setForMostJDKs( "142", "50" );
+ setForMostJDKs( "142", "50", "60" );
}
/////////////////////////////////////////////////////////////////////////
@@ -302,7 +313,7 @@
private void setForSunJDKs()
throws Exception
{
- setForMostJDKs( "1.4.", "1.5." );
+ setForMostJDKs( "1.4.", "1.5.", "1.6" );
}
/////////////////////////////////////////////////////////////////////////
@@ -316,21 +327,25 @@
* Set the properties needed to compile using most JDKs
* </p>
*/
- private void setForMostJDKs( String seed14, String seed15)
+ private void setForMostJDKs( String seed14, String seed15, String seed16 )
throws Exception
{
List<File> jdkParents = getJdkSearchPath();
-
+
String default_j14lib = getProperty( J14LIB );
String default_j15lib = getProperty( J15LIB );
+ String default_j16lib = getProperty( J16LIB );
if ( default_j14lib == null )
{ default_j14lib = searchForJreLib(jdkParents, seed14, false ); }
if ( default_j15lib == null )
- { default_j15lib = searchForJreLib(jdkParents, seed15, true ); }
+ { default_j15lib = searchForJreLib(jdkParents, seed15, false ); }
- defaultSetter( default_j14lib, default_j15lib );
+ if ( default_j16lib == null )
+ { default_j16lib = searchForJreLib(jdkParents, seed16, false ); }
+
+ defaultSetter( default_j14lib, default_j15lib, default_j16lib );
}
/**
@@ -466,20 +481,24 @@
* values will override the defaults that are passed in to this method.
* </p>
*/
- private void defaultSetter( String default_j14lib, String default_j15lib )
+ private void defaultSetter( String default_j14lib, String default_j15lib, String default_j16lib )
throws BuildException
{
String j14lib = getProperty( J14LIB, default_j14lib );
String j15lib = getProperty( J15LIB, default_j15lib );
+ String j16lib = getProperty( J16LIB, default_j16lib );
setClasspathFromLib( J14CLASSPATH, j14lib, false );
- setClasspathFromLib( J15CLASSPATH, j15lib, true );
+ setClasspathFromLib( J15CLASSPATH, j15lib, false );
+ setClasspathFromLib( J16CLASSPATH, j16lib, false );
}
/**
* <p>
* Set a classpath property to all of the jars in a directory.
* If the classpath property is already set, then it is not overridden.
+ * However, refuse to set certain properties if they will cause problems
+ * later on.
* Throws a BuildException if there's a problem.
* </p>
*/
@@ -491,6 +510,9 @@
// nothing to do if the property is already set. we can't override it.
if ( classpath != null ) { return; }
+ // refuse to set certain properties
+ if ( shouldNotSet( classpathProperty ) ) { return; }
+
String jars = listJars( libraryDirectory, squawkIfEmpty );
if ( squawkIfEmpty && (jars == null) )
@@ -603,18 +625,15 @@
*/
private void checkForProblematicSettings()
{
- //
- // The IBM Java 5 compiler raises version mismatch errors when used
- // with the IBM Java 6 libraries.
- //
- String jdkVendor = getProperty( JDK_VENDOR );
- String javaVersion = getProperty( JAVA_VERSION );
- if ( usingIBMjdk( jdkVendor ) && javaVersion.startsWith( JAVA_5 ) && isSet( J16CLASSPATH ) )
+ if (
+ shouldNotSet( J16CLASSPATH ) &&
+ ( isSet( J16CLASSPATH ) || isSet( J16LIB ) )
+ )
{
throw new BuildException
(
"\nThe build raises version mismatch errors when using the IBM Java 5 compiler with Java 6 libraries.\n" +
- "Please either use a Java 6 (or later) compiler or do not set the '" + J16CLASSPATH + "' variable.\n"
+ "Please either use a Java 6 (or later) compiler or do not set the '" + J16CLASSPATH + "' and '" + J16LIB + "' variables.\n"
);
}
@@ -622,6 +641,23 @@
/**
* <p>
+ * Returns true if the given property should not be set.
+ * </p>
+ */
+ private boolean shouldNotSet( String property )
+ {
+ //
+ // The IBM Java 5 compiler raises version mismatch errors when used
+ // with the IBM Java 6 libraries.
+ //
+ String jdkVendor = getProperty( JDK_VENDOR );
+ String javaVersion = getProperty( JAVA_VERSION );
+
+ return ( usingIBMjdk( jdkVendor ) && javaVersion.startsWith( JAVA_5 ) && J16CLASSPATH.equals( property ) );
+ }
+
+ /**
+ * <p>
* Return true if we are using an IBM JDK.
* </p>
*/
@@ -694,6 +730,24 @@
/**
* <p>
+ * Require that at least one of the passed in properties be set.
+ * </p>
+ */
+ private void requireAtLeastOneProperty( String... properties )
+ throws BuildException
+ {
+ int count = properties.length;
+
+ for ( String property : properties )
+ {
+ if ( getProperty( property ) != null ) { return; }
+ }
+
+ throw couldntSetProperty( properties );
+ }
+
+ /**
+ * <p>
* Require that a property be set.
* </p>
*/
@@ -705,26 +759,47 @@
/**
* <p>
- * Object that we couldn't set a property.
+ * Object that we couldn't set some properties.
* </p>
*/
- private BuildException couldntSetProperty( String property )
+ private BuildException couldntSetProperty( String... properties )
{
StringBuffer buffer = new StringBuffer();
-
- buffer.append( "Don't know how to set " + property );
+ int count = properties.length;
+
+ buffer.append( "Don't know how to set " );
+ for ( int i = 0; i < count; i++ )
+ {
+ if ( i > 0 ) { buffer.append( ", " ); }
+ buffer.append( properties[ i ] );
+ }
buffer.append( " using this environment:\n\n" );
+ buffer.append( showEnvironment() );
+ buffer.append( "\nPlease consult BUILDING.html for instructions on how to set the compiler-classpath properties." );
+
+ return new BuildException( buffer.toString() );
+ }
+
+ /**
+ * <p>
+ * Display the environment.
+ * </p>
+ */
+ private String showEnvironment()
+ {
+ StringBuffer buffer = new StringBuffer();
+
appendProperty( buffer, JDK_VENDOR );
appendProperty( buffer, JAVA_HOME );
appendProperty( buffer, JAVA_VERSION );
appendProperty( buffer, OPERATING_SYSTEM );
appendProperty( buffer, J14LIB );
appendProperty( buffer, J15LIB );
- buffer.append( "\nPlease consult BUILDING.html for instructions on how to set the compiler-classpath properties." );
-
- return new BuildException( buffer.toString() );
- }
+ appendProperty( buffer, J16LIB );
+ return buffer.toString();
+ }
+
/**
* <p>
* Append the value of a property to an evolving string buffer.