You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by co...@locus.apache.org on 2000/06/25 14:36:47 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Javac.java

conor       00/06/25 05:36:46

  Modified:    src/main/org/apache/tools/ant/taskdefs Javac.java
  Log:
  Deprecate the implicit copying of support files by Javac.
  
  Revision  Changes    Path
  1.14      +17 -14    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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Javac.java	2000/06/24 10:55:45	1.13
  +++ Javac.java	2000/06/25 12:36:45	1.14
  @@ -237,6 +237,10 @@
           // copy the support files
   
           if (filecopyList.size() > 0) {
  +            project.log("The implicit copying of support files by javac has been deprecated. " + 
  +                        "Use the copydir task to copy support files explicitly.",
  +                        Project.MSG_WARN);
  +                
               project.log("Copying " + filecopyList.size() +
                           " support files to " + destDir.getAbsolutePath());
               Enumeration enum = filecopyList.keys();
  @@ -271,22 +275,21 @@
               File srcFile = new File(srcDir, files[i]);
               if (files[i].endsWith(".java")) {
                   File classFile = new File(destDir, files[i].substring(0,
  -                        files[i].indexOf(".java"))
  -                                                    + ".class");
  +                                          files[i].indexOf(".java")) + ".class");
   
  -                    if (srcFile.lastModified() > now) {
  -                        project.log("Warning: file modified in the future: " +
  -                            files[i], project.MSG_WARN);
  -                    }
  -
  -                    if (srcFile.lastModified() > classFile.lastModified()) {
  -                        compileList.addElement(srcFile.getAbsolutePath());
  -                    }
  -                } else {
  +                if (srcFile.lastModified() > now) {
  +                    project.log("Warning: file modified in the future: " +
  +                        files[i], project.MSG_WARN);
  +                }
  +
  +                if (srcFile.lastModified() > classFile.lastModified()) {
  +                    compileList.addElement(srcFile.getAbsolutePath());
  +                }
  +            } else {
                   File destFile = new File(destDir, files[i]);
  -                    if (srcFile.lastModified() > destFile.lastModified()) {
  -                        filecopyList.put(srcFile.getAbsolutePath(),
  -                                         destFile.getAbsolutePath());
  +                if (srcFile.lastModified() > destFile.lastModified()) {
  +                    filecopyList.put(srcFile.getAbsolutePath(),
  +                                     destFile.getAbsolutePath());
                   }
               }
           }
  
  
  

Re: cvscommit:jakarta-ant/src/main/org/apache/tools/ant/taskdefsJavac.java

Posted by James Todd <jw...@pacbell.net>.
thx for the pointer. i'll update and check out the new features.
i'm reluctant to break up the package tree just because i build
different flavours from time to time ... and i do hate having the
resource files hanging off on the side.

i'll give it a whirl,

- james

Conor MacNeill wrote:

> James,
>
> > hey conor -
> >
> >     i'm curious as to if this resolves or worsens a problem i've
> >     had with ant, that being that if i do a "build of a sub-branch"
> >     of a package tree any/all resource files (eg xml, properties)
> >     get reparented under the root package name.
> >
>
> All this patch does is to give a warning that copying of support files is
> deprecated and fix up some strange indenting.
>
> >     but, when i do a "branch build" using a tag as follows:
> >
> >         <javac srcdir="foo/bar/bop" ...
> >
>
> OK, the issue here is that javac (the compiler) relies on the package
> statement in your java source code to determine where to place the generated
> classes in the destination build area. javac (the task) uses the relative
> directory position to determine the location of support files. When you
> point srcdir into the middle of your source tree, the effect is to reparent
> the support files higher up in the destination hierarchy.
>
> I think it is best if your srcdir attribute always points to the root of
> your package hierarchy. To achieve your branch build, you should use
> appropriate <include> constructs in your javac task
>
>         <javac srcdir="dir above foo">
>           <include name="foo/bar/bop/**/*.java"/>
>         </javac>
>
> You may need to get an up to date version of ant for this capability - not
> sure.
>
> Conor


RE: cvs commit:jakarta-ant/src/main/org/apache/tools/ant/taskdefsJavac.java

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
James,

> hey conor -
>
>     i'm curious as to if this resolves or worsens a problem i've
>     had with ant, that being that if i do a "build of a sub-branch"
>     of a package tree any/all resource files (eg xml, properties)
>     get reparented under the root package name.
>

All this patch does is to give a warning that copying of support files is
deprecated and fix up some strange indenting.

>     but, when i do a "branch build" using a tag as follows:
>
>         <javac srcdir="foo/bar/bop" ...
>

OK, the issue here is that javac (the compiler) relies on the package
statement in your java source code to determine where to place the generated
classes in the destination build area. javac (the task) uses the relative
directory position to determine the location of support files. When you
point srcdir into the middle of your source tree, the effect is to reparent
the support files higher up in the destination hierarchy.

I think it is best if your srcdir attribute always points to the root of
your package hierarchy. To achieve your branch build, you should use
appropriate <include> constructs in your javac task

	<javac srcdir="dir above foo">
          <include name="foo/bar/bop/**/*.java"/>
	</javac>

You may need to get an up to date version of ant for this capability - not
sure.

Conor


Re: cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefsJavac.java

Posted by James Todd <jw...@pacbell.net>.
hey conor -

    i'm curious as to if this resolves or worsens a problem i've
    had with ant, that being that if i do a "build of a sub-branch"
    of a package tree any/all resource files (eg xml, properties)
    get reparented under the root package name.

    i'm presently using a 6 month old ant and just at this time
    am freeing up some cylces to upgrade and will again test my
    theory to see if the issue persists but seeing the following
    putback comments prompted me to again ask this question.

    here's a simple example source package structure:

        foo/bar/ bop/Bop.java
        foo/bar/bop/bop.xml

    now, when i build using a tag as follows (again, i could be
    dated on some usage details here to which i will appreciate
    gentle redirection):

        <javac srcdir="foo" ...

    all is well regarding the derived package structure:

        foo.bar.bop.Bop.class
        foo.bar.bop.bop.xml

    but, when i do a "branch build" using a tag as follows:

        <javac srcdir="foo/bar/bop" ...

    the "resource" files (ie bop.xml) are reparented in the
    derived package structure:

        foo.bar.bop.Bop.class
        bop.xml

    i get around this with a rather ugly and redundant
    "resource tree" and supporting copydir tags which i
    really want to do away with.

    is this a bug/is it fixed/is there a better way?

    thx much,

- james

conor@locus.apache.org wrote:

> conor       00/06/25 05:36:46
>
>   Modified:    src/main/org/apache/tools/ant/taskdefs Javac.java
>   Log:
>   Deprecate the implicit copying of support files by Javac.
>
>   Revision  Changes    Path
>   1.14      +17 -14    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.13
>   retrieving revision 1.14
>   diff -u -r1.13 -r1.14
>   --- Javac.java        2000/06/24 10:55:45     1.13
>   +++ Javac.java        2000/06/25 12:36:45     1.14
>   @@ -237,6 +237,10 @@
>            // copy the support files
>
>            if (filecopyList.size() > 0) {
>   +            project.log("The implicit copying of support files by javac has been deprecated. " +
>   +                        "Use the copydir task to copy support files explicitly.",
>   +                        Project.MSG_WARN);
>   +
>                project.log("Copying " + filecopyList.size() +
>                            " support files to " + destDir.getAbsolutePath());
>                Enumeration enum = filecopyList.keys();
>   @@ -271,22 +275,21 @@
>                File srcFile = new File(srcDir, files[i]);
>                if (files[i].endsWith(".java")) {
>                    File classFile = new File(destDir, files[i].substring(0,
>   -                        files[i].indexOf(".java"))
>   -                                                    + ".class");
>   +                                          files[i].indexOf(".java")) + ".class");
>
>   -                    if (srcFile.lastModified() > now) {
>   -                        project.log("Warning: file modified in the future: " +
>   -                            files[i], project.MSG_WARN);
>   -                    }
>   -
>   -                    if (srcFile.lastModified() > classFile.lastModified()) {
>   -                        compileList.addElement(srcFile.getAbsolutePath());
>   -                    }
>   -                } else {
>   +                if (srcFile.lastModified() > now) {
>   +                    project.log("Warning: file modified in the future: " +
>   +                        files[i], project.MSG_WARN);
>   +                }
>   +
>   +                if (srcFile.lastModified() > classFile.lastModified()) {
>   +                    compileList.addElement(srcFile.getAbsolutePath());
>   +                }
>   +            } else {
>                    File destFile = new File(destDir, files[i]);
>   -                    if (srcFile.lastModified() > destFile.lastModified()) {
>   -                        filecopyList.put(srcFile.getAbsolutePath(),
>   -                                         destFile.getAbsolutePath());
>   +                if (srcFile.lastModified() > destFile.lastModified()) {
>   +                    filecopyList.put(srcFile.getAbsolutePath(),
>   +                                     destFile.getAbsolutePath());
>                    }
>                }
>            }
>
>
>