ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/compilers DefaultCompilerAdapter.java
Date Fri, 29 Oct 2004 07:35:17 GMT
bodewig     2004/10/29 00:35:17

  Modified:    .        build.xml
               src/main/org/apache/tools/ant/taskdefs/compilers
                        DefaultCompilerAdapter.java
  Log:
  Make handling of javac -source easier.  Simply make JDK 1.4.1's
  interface upwards compatible.
  
  Revision  Changes    Path
  1.438     +7 -27     ant/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/ant/build.xml,v
  retrieving revision 1.437
  retrieving revision 1.438
  diff -u -r1.437 -r1.438
  --- build.xml	28 Oct 2004 09:38:24 -0000	1.437
  +++ build.xml	29 Oct 2004 07:35:17 -0000	1.438
  @@ -376,28 +376,6 @@
   
     <!--
          ===================================================================
  -         Set up a preset def for javac depending on
  -         the java version
  -       ===================================================================
  -  -->
  -
  -  <target name="javac.preset" depends="javac.preset.1.5+,javac.preset.1.5-"/>
  -  <target name="javac.preset.1.5+" depends="check_for_optional_packages"
  -          if="jdk1.5+">
  -    <presetdef name="javac.preset">
  -      <javac source="${javac.source}"/>
  -    </presetdef>
  -  </target>
  -  <target name="javac.preset.1.5-" depends="check_for_optional_packages"
  -          unless="jdk1.5+">
  -    <presetdef name="javac.preset">
  -      <javac/>
  -    </presetdef>
  -  </target>
  -
  -
  -  <!--
  -       ===================================================================
            Check to see what optional dependencies are available
          ===================================================================
     -->
  @@ -642,17 +620,18 @@
          ===================================================================
     -->
     <target name="build"
  -          depends="prepare, check_for_optional_packages, javac.preset"
  +          depends="prepare, check_for_optional_packages"
             description="--> compiles the source code">
       <mkdir dir="${build.dir}"/>
       <mkdir dir="${build.classes}"/>
       <mkdir dir="${build.lib}"/>
   
  -    <javac.preset srcdir="${java.dir}"
  +    <javac srcdir="${java.dir}"
              destdir="${build.classes}"
              debug="${debug}"
              deprecation="${deprecation}"
              target="${javac.target}"
  +           source="${javac.source}"
              optimize="${optimize}" >
         <classpath refid="classpath"/>
   
  @@ -701,7 +680,7 @@
             </or>
           </not>
         </selector>
  -    </javac.preset>
  +    </javac>
   
       <copy todir="${build.classes}">
         <fileset dir="${java.dir}">
  @@ -1406,15 +1385,16 @@
     <target name="compile-tests" depends="build" if="junit.present">
       <mkdir dir="${build.tests}"/>
   
  -    <javac.preset srcdir="${tests.dir}"
  +    <javac srcdir="${tests.dir}"
              destdir="${build.tests}"
              debug="${debug}"
              target="${javac.target}"
  +           source="${javac.source}"
              deprecation="${deprecation}" >
         <classpath refid="tests-classpath"/>
   
         <selector refid="conditional-patterns"/>
  -    </javac.preset>
  +    </javac>
   
       <!-- Used by AntlibTest.testAntlibResource: -->
       <jar jarfile="${build.tests}/org/apache/tools/ant/taskdefs/test2-antlib.jar">
  
  
  
  1.50      +23 -1     ant/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  
  Index: DefaultCompilerAdapter.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- DefaultCompilerAdapter.java	6 Oct 2004 22:41:52 -0000	1.49
  +++ DefaultCompilerAdapter.java	29 Oct 2004 07:35:17 -0000	1.50
  @@ -297,7 +297,15 @@
           setupJavacCommandlineSwitches(cmd, true);
           if (attributes.getSource() != null && !assumeJava13()) {
               cmd.createArgument().setValue("-source");
  -            cmd.createArgument().setValue(attributes.getSource());
  +            String source = attributes.getSource();
  +            if (assumeJava14() && 
  +                (source.equals("1.1") || source.equals("1.2"))) {
  +                // support for -source 1.1 and -source 1.2 has been
  +                // added with JDK 1.4.2
  +                cmd.createArgument().setValue("1.3");
  +            } else {
  +                cmd.createArgument().setValue(source);
  +            }
           }
           return cmd;
       }
  @@ -499,6 +507,20 @@
                   && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3))
               || ("extJavac".equals(attributes.getCompilerVersion())
                   && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3));
  +    }
  +
  +    /**
  +     * Shall we assume JDK 1.4 command line switches?
  +     * @since Ant 1.6.3
  +     */
  +    protected boolean assumeJava14() {
  +        return "javac1.4".equals(attributes.getCompilerVersion())
  +            || ("classic".equals(attributes.getCompilerVersion())
  +                && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4))
  +            || ("modern".equals(attributes.getCompilerVersion())
  +                && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4))
  +            || ("extJavac".equals(attributes.getCompilerVersion())
  +                && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4));
       }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message