The following comment has been added to this issue:

     Author: Trevor Lohrbeer
    Created: Wed, 14 Apr 2004 4:44 PM
       Body:
One more thing. Under JDK 1.2, the maven.compile.jdk.classpath variable may need to be 
set to '${maven.compile.jdk.home}/lib/tools.jar;${maven.compile.jdk.home}/lib/dt.jar' 
[You would need to figure out a way to use the platform-specific classpath separator 
instead of ';']. 

I didn't run into any problems without it, but the searches I did on required 
classpaths for various JDKs seemed to indicate that this is what JDK 1.2 needed.

....trevor
---------------------------------------------------------------------
View this comment:
  
http://jira.codehaus.org/secure/ViewIssue.jspa?key=MPJAVA-17&page=comments#action_18622

---------------------------------------------------------------------
View the issue:
  http://jira.codehaus.org/secure/ViewIssue.jspa?key=MPJAVA-17

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: MPJAVA-17
    Summary: java:compile uses switches that are incompatible with JDK 1.1
       Type: Bug

     Status: Open
   Priority: Major

 Original Estimate: Unknown
 Time Spent: Unknown
  Remaining: Unknown

    Project: maven-java-plugin

   Assignee: Jason van Zyl
   Reporter: Trevor Lohrbeer

    Created: Wed, 14 Apr 2004 4:39 PM
    Updated: Wed, 14 Apr 2004 4:44 PM
Environment: Maven running against JDK 1.4.2, forking to JDK 1.1.8 to do the compile.

Description:
The current Jelly script for the java:compile goal sets options on the ant:javac tag 
that cause the -sourcepath and -target options to be passed to javac. These options 
are not supported under JDK 1.1 and cause an error to be thrown if you attempt to fork 
and compile using the JDK 1.1 javac.

Below is a modified maven-java-plugin-1.3/plugin.jelly script that corrects the 
problem. This script adds three additional properties that configure how compilation 
will occur:

   maven.compile.jdk           
      The JDK to compile against, eg: 1.1, 1.2

   maven.compile.jdk.home 
      The home directory of the JDK installation, eg: C:\Java\jdk1.1.8

   maven.compile.jdk.classpath
      Any required classes for this JDK version that need to be specially added to the 
classpath. If this is null, this will be constructed automatically using the jdk.home. 
For 1.1, it gets set to ${maven.compile.jdk.home}/lib/classes.zip, which contains the 
java.* classes.

These properties are ignored if maven.compile.fork is not set to 'yes', since Maven 
doesn't run under 1.1 and doesn't seem to run under 1.2

If maven.compile.executable is not set, but maven.compile.jdk is, then 
maven.compile.executable will be set automatically to 
${maven.compile.jdk.home}/bin/javac. This prevents having to define the executable 
separately.

When java:compile is executed, an echo message is printed that indicates which JDK you 
are compiling against if fork is 'yes'.

That's about it. I've tested this script compiling using JDK 1.1.8 and JDK 1.2.2 with 
the above options set, and JDK 1.4.2 with the options not set [My Maven installation 
runs natively off of JDK 1.4.2].

--------------------------------------------------------------------

<?xml version="1.0"?>

<project 
  xmlns:j="jelly:core"
  xmlns:ant="jelly:ant"
  xmlns:define="jelly:define"
  xmlns:maven="jelly:maven">

  <!-- ================================================================== -->
  <!-- P R E P A R E  F I L E  S Y S T E M                                -->
  <!-- ================================================================== -->

  <goal name="java:prepare-filesystem"
        description="Create the directory structure needed to compile">
    <ant:mkdir dir="${maven.build.dest}"/>
  </goal>

  <!-- ================================================================== -->
  <!-- C O M P I L E                                                      -->
  <!-- ================================================================== -->

  <goal name="java:compile"
        description="Compile the project"
        prereqs="java:prepare-filesystem">
    <ant:echo>Compiling to ${maven.build.dest}</ant:echo>
    <j:choose>
      <j:when test="${sourcesPresent == 'true'}">

        <!-- ***ADDED*** -->
        <j:choose>
          <j:when test="${context.getVariable('maven.compile.fork') == 'yes'}">

            <j:choose>
              <j:when test="${context.getVariable('maven.compile.jdk') != null}">
                <echo>Using JDK ${maven.compile.jdk} to compile</echo>
              </j:when>
              <j:otherwise>
                <echo>Using default JDK to compile</echo>
              </j:otherwise>
            </j:choose>

            <j:switch on="${maven.compile.jdk}">
              <j:case value="1.1">
                <j:set var="maven.compile.srcdir" value="${pom.build.sourceDirectory}" 
/>
                <j:set var="maven.compile.sourcepath" value="" />
                <j:set var="maven.compile.target.local" value="${null}" />

                <j:if test="${context.getVariable('maven.compile.executable') == 
null}">
                  <j:set var="maven.compile.executable" 
value="${maven.compile.jdk.home}/bin/javac" />
                </j:if>

                <j:if test="${context.getVariable('maven.compile.jdk.classpath') == 
null}">
                  <j:set var="maven.compile.jdk.classpath" 
value="${maven.compile.jdk.home}/lib/classes.zip" />
                </j:if>
              </j:case>

              <j:default>
                <j:if test="${context.getVariable('maven.compile.jdk.home') != null}">
                  <j:if test="${context.getVariable('maven.compile.executable') == 
null}">
                    <j:set var="maven.compile.executable" 
value="${maven.compile.jdk.home}/bin/javac" />
                  </j:if>
                </j:if>

                <j:set var="maven.compile.target.local" 
value="${maven.compile.target}" />
              </j:default>
            </j:switch>
          </j:when>

          <j:otherwise>
            <j:set var="maven.compile.target.local" value="${maven.compile.target}" />
          </j:otherwise>
        </j:choose>

        <!-- ***REMOVED*** Moved target attribute to be conditionally set below. -->
        <ant:javac
          destdir="${maven.build.dest}"
          excludes="**/package.html"
          debug="${maven.compile.debug}"
          deprecation="${maven.compile.deprecation}"
          optimize="${maven.compile.optimize}">

          <!-- ***MODIFIED*** Made it so the element is only added if the srcdir 
attribute is
                              null; otherwise rely on srcdir.
            -->
          <j:if test="${context.getVariable('maven.compile.srcdir') == null}">
            <ant:src>
              <ant:path refid="maven.compile.src.set"/>
            </ant:src>
          </j:if>

          <!--
           | 
           | Source Modifications.
           |
          -->
      
          <j:forEach var="sm" items="${pom.build.sourceModifications}">
            <ant:available property="classPresent" classname="${sm.className}"/>
            <j:if test="${classPresent != 'true'}">
              <j:forEach var="exclude" items="${sm.excludes}">
                <ant:exclude name="${exclude}"/>
              </j:forEach>
              <j:forEach var="include" items="${sm.includes}">
                <ant:include name="${include}"/>
              </j:forEach>
            </j:if>
          </j:forEach>

          <!-- ***ADDED*** Path element for maven.compile.jdk.classpath -->      
          <ant:classpath>
            <j:if test="${context.getVariable('maven.compile.jdk.classpath') != null}">
              <ant:pathelement path="${maven.compile.jdk.classpath}" />
            </j:if>
            <ant:path refid="maven.dependency.classpath"/>
            <ant:pathelement path="${maven.build.dest}"/>
          </ant:classpath>

          <j:if test="${context.getVariable('maven.compile.compilerargs') != null}">
            <ant:compilerarg line="${maven.compile.compilerargs}" />
          </j:if>

          <!-- ***ADDED*** srcdir -->
          <j:if test="${context.getVariable('maven.compile.srcdir') != null}">
            <ant:setProperty name="srcdir" value="${maven.compile.srcdir}" />
          </j:if>

          <!-- ***ADDED*** target
               ***NOTE*** I use the maven.compile.target.local variable here so I 
                          can override the maven.compile.target variable without
                          affecting other scripts.
            -->
          <j:if test="${context.getVariable('maven.compile.target.local') != null}">
            <ant:setProperty name="target" value="${maven.compile.target.local}" />
          </j:if>

          <!-- ***ADDED*** sourcepath -->
          <j:if test="${context.getVariable('maven.compile.sourcepath') != null}">
            <ant:setProperty name="sourcepath" value="${maven.compile.sourcepath}" />
          </j:if>
          
          <j:if test="${context.getVariable('maven.compile.encoding') != null}">
            <ant:setProperty name="encoding" value="${maven.compile.encoding}" />
          </j:if>
          
          <j:if test="${context.getVariable('maven.compile.executable') != null}">
            <ant:setProperty name="executable" value="${maven.compile.executable}" />
          </j:if>
          
          <j:if test="${context.getVariable('maven.compile.fork') != null}">
            <ant:setProperty name="fork" value="${maven.compile.fork}" />
          </j:if>
          
          <j:if test="${context.getVariable('maven.compile.source') != null}">
            <ant:setProperty name="source" value="${maven.compile.source}" />
          </j:if>
          
          <j:if test="${context.getVariable('maven.compile.verbose') != null}">
            <ant:setProperty name="verbose" value="${maven.compile.verbose}" />
          </j:if>

        </ant:javac>
      </j:when>
      <j:otherwise>
        <ant:echo>No java source files to compile.</ant:echo>
      </j:otherwise>      
    </j:choose>
  </goal>
  
  <goal name="java:jar"
        description="Create the deliverable jar file."
        prereqs="jar:jar">
        <ant:echo>java:jar is deprecated and will be removed. Please use 
jar:jar</ant:echo>
  </goal>

  <!-- ================================================================== -->
  <!-- J A R  R E S O U R C E S                                           -->
  <!-- ================================================================== -->

  <goal name="java:jar-resources"
        description="Copy any resources that must be present in the deployed JAR file">
        
    <j:if test="${!pom.build.resources.isEmpty()}">
      <maven:copy-resources
        resources="${pom.build.resources}"
        todir="${maven.build.dest}"/>
    </j:if>
  </goal>
  
  <define:taglib uri="java">
    <define:tag name="dependency-handle">
      <!-- XXX Use this tag to allow this plugin to be loaded into another -->
    </define:tag>
  </define:taglib>
</project>



---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to