ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers DefaultCompilerAdapter.java
Date Thu, 14 Feb 2002 17:34:19 GMT
bodewig     02/02/14 09:34:19

  Modified:    .        WHATSNEW
               docs/manual/CoreTasks javac.html
               src/main/org/apache/tools/ant/taskdefs Javac.java
               src/main/org/apache/tools/ant/taskdefs/compilers
                        DefaultCompilerAdapter.java
  Log:
  Allow -sourcepath for <javac> to be set explicitly.
  
  PR: 5268
  Submitted by:	Alex Rosen <arosen@silverstream.com>
  
  Revision  Changes    Path
  1.209     +2 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.208
  retrieving revision 1.209
  diff -u -r1.208 -r1.209
  --- WHATSNEW	9 Feb 2002 22:49:42 -0000	1.208
  +++ WHATSNEW	14 Feb 2002 17:34:19 -0000	1.209
  @@ -161,6 +161,8 @@
     
   * <tstamp> now supports a new "prefix" attribute to prefix properties set.
   
  +* you can now specify the -sourcepath for <javac> explicitly.
  +
   Changes from Ant 1.4 to Ant 1.4.1
   ===========================================
   
  
  
  
  1.24      +20 -7     jakarta-ant/docs/manual/CoreTasks/javac.html
  
  Index: javac.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/javac.html,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- javac.html	3 Feb 2002 22:00:42 -0000	1.23
  +++ javac.html	14 Feb 2002 17:34:19 -0000	1.24
  @@ -117,6 +117,11 @@
       <td align="center" valign="top">No</td>
     </tr>
     <tr>
  +    <td valign="top">sourcepath</td>
  +    <td valign="top">the sourcepath to use; defaults to the value of the srcdir attribute
(or <code>&lt;src&gt;</code> elements).</td>
  +    <td align="center" valign="top">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">bootclasspath</td>
       <td valign="top">location of bootstrap class files.</td>
       <td align="center" valign="top">No</td>
  @@ -128,6 +133,12 @@
       <td align="center" valign="top">No</td>
     </tr>
     <tr>
  +    <td valign="top">sourcepathref</td>
  +    <td valign="top">the sourcepath to use, given as a
  +      <a href="../using.html#references">reference</a> to a PATH defined elsewhere.</td>
  +    <td align="center" valign="top">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">bootclasspathref</td>
       <td valign="top">location of bootstrap class files, given as a
         <a href="../using.html#references">reference</a> to a PATH defined elsewhere.</td>
  @@ -255,14 +266,16 @@
   (<code>dir</code> becomes <code>srcdir</code>) as well as the nested
   <code>&lt;include&gt;</code>, <code>&lt;exclude&gt;</code>
and
   <code>&lt;patternset&gt;</code> elements.</p>
  -<h4><code>src</code>, <code>classpath</code>, <code>bootclasspath</code>
and <code>extdirs</code></h4>
  +<h4><code>src</code>, <code>classpath</code>, <code>sourcepath</code>,

  +<code>bootclasspath</code> and <code>extdirs</code></h4>
   <p><code>Javac</code>'s <i>srcdir</i>, <i>classpath</i>,
  -<i>bootclasspath</i> and <i>extdirs</i> attributes are <a
  +<i>sourcepath</i>, <i>bootclasspath</i> and <i>extdirs</i>
attributes are <a
   href="../using.html#path">path-like structures</a> and can also be set via nested
  -<code>&lt;src&gt</code>,
  -<code>&lt;classpath&gt</code>,
  -<code>&lt;bootclasspath&gt</code> and
  -<code>&lt;extdirs&gt</code> elements, respectively.</p>
  +<code>&lt;src&gt;</code>,
  +<code>&lt;classpath&gt;</code>,
  +<code>&lt;sourcepath&gt;</code>,
  +<code>&lt;bootclasspath&gt;</code> and
  +<code>&lt;extdirs&gt;</code> elements, respectively.</p>
   
   <h4>compilerarg</h4>
   
  @@ -425,7 +438,7 @@
     </tr>
   </table>
   <hr>
  -<p align="center">Copyright &copy; 2001 Apache Software Foundation. All rights
  +<p align="center">Copyright &copy; 2001-2002 Apache Software Foundation. All
rights
   Reserved.</p>
   
   </body>
  
  
  
  1.83      +34 -0     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javac.java
  
  Index: Javac.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javac.java,v
  retrieving revision 1.82
  retrieving revision 1.83
  diff -u -r1.82 -r1.83
  --- Javac.java	8 Feb 2002 15:02:17 -0000	1.82
  +++ Javac.java	14 Feb 2002 17:34:19 -0000	1.83
  @@ -111,6 +111,7 @@
       private Path src;
       private File destDir;
       private Path compileClasspath;
  +    private Path compileSourcepath;
       private String encoding;
       private boolean debug = false;
       private boolean optimize = false;
  @@ -220,6 +221,39 @@
        */
       public File getDestdir() {
           return destDir;
  +    }
  +
  +    /**
  +     * Set the sourcepath to be used for this compilation.
  +     */
  +    public void setSourcepath(Path sourcepath) {
  +        if (compileSourcepath == null) {
  +            compileSourcepath = sourcepath;
  +        } else {
  +            compileSourcepath.append(sourcepath);
  +        }
  +    }
  +
  +    /** Gets the sourcepath to be used for this compilation. */
  +    public Path getSourcepath() {
  +        return compileSourcepath;
  +    }
  +
  +    /**
  +     * Maybe creates a nested sourcepath element.
  +     */
  +    public Path createSourcepath() {
  +        if (compileSourcepath == null) {
  +            compileSourcepath = new Path(project);
  +        }
  +        return compileSourcepath.createPath();
  +    }
  +
  +    /**
  +     * Adds a reference to a CLASSPATH defined elsewhere.
  +     */
  +    public void setSourcepathRef(Reference r) {
  +        createSourcepath().setRefid(r);
       }
   
       /**
  
  
  
  1.20      +17 -4     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  
  Index: DefaultCompilerAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- DefaultCompilerAdapter.java	20 Jan 2002 20:45:56 -0000	1.19
  +++ DefaultCompilerAdapter.java	14 Feb 2002 17:34:19 -0000	1.20
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -97,6 +97,7 @@
       protected Path bootclasspath;
       protected Path extdirs;
       protected Path compileClasspath;
  +    protected Path compileSourcepath;
       protected Project project;
       protected Location location;
       protected boolean includeAntRuntime;
  @@ -125,6 +126,7 @@
           extdirs = attributes.getExtdirs();
           compileList = attributes.getFileList();
           compileClasspath = attributes.getClasspath();
  +        compileSourcepath = attributes.getSourcepath();
           project = attributes.getProject();
           location = attributes.getLocation();
           includeAntRuntime = attributes.getIncludeantruntime();
  @@ -184,6 +186,14 @@
       protected Commandline setupJavacCommandlineSwitches(Commandline cmd,
                                                           boolean useDebugLevel) {
           Path classpath = getCompileClasspath();
  +        // For -sourcepath, use the "sourcepath" value if present.
  +        // Otherwise default to the "srcdir" value.
  +        Path sourcepath = null;
  +        if (compileSourcepath != null) {
  +            sourcepath = compileSourcepath;
  +        } else {
  +            sourcepath = src;
  +        }
   
           // we cannot be using Java 1.0 when forking, so we only have to
           // distinguish between Java 1.1, and Java 1.2 and higher, as Java 1.1
  @@ -237,12 +247,15 @@
                   cp.addExtdirs(extdirs);
               }
               cp.append(classpath);
  -            cp.append(src);
  +            cp.append(sourcepath);
               cmd.createArgument().setPath(cp);
           } else {
               cmd.createArgument().setPath(classpath);
  -            cmd.createArgument().setValue("-sourcepath");
  -            cmd.createArgument().setPath(src);
  +            // If the buildfile specifies sourcepath="", then don't output any sourcepath.
  +            if (sourcepath.size() > 0) {
  +                cmd.createArgument().setValue("-sourcepath");
  +                cmd.createArgument().setPath(sourcepath);
  +            }
               if (target != null) {
                   cmd.createArgument().setValue("-target");
                   cmd.createArgument().setValue(target);
  
  
  

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


Mime
View raw message