ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Klas Eriksson <klas.eriks...@micronic.se>
Subject RE: ant/javac prepends destdir to classpath
Date Mon, 02 Aug 2004 09:26:38 GMT
Hi

I guess 'exclude' works on source code and doesn't operate on the classpath.

In my real-world example I have a couple of packages that should be
stand-alone
and re-usable, for example se.micronic.util1 and util2:

  <target name="kerTestPureCompilation"
     description="should ensure that util1 and util2 compile stand-alone">
<!-- doesn't work -->
     <javac srcdir="SRC/se/micronic/util1"
            destdir="classes"
            includeAntRuntime="no"
            classpath="3rdpartyjars/castor-xml.jar">
       <include name="**"/>
     </javac>
     <javac srcdir="SRC/se/micronic/util2"
            destdir="classes" 
            includeAntRuntime="no"
            classpath="3rdpartyjars/castor-xml.jar">
       <include name="**"/>
     </javac> 
  </target>

To rewrite the rule like

  <target name="kerTestPureCompilation"
     description="should ensure that util1 and util2 compile stand-alone">
<!-- doesn't work -->
     <javac srcdir="SRC"
            destdir="classes"
            includeAntRuntime="no"
            classpath="3rdpartyjars/castor-xml.jar">
       <include name="se/micronic/util1/**"/>
     </javac>
     <javac srcdir="SRC"
            destdir="classes" 
            includeAntRuntime="no"
            classpath="3rdpartyjars/castor-xml.jar">
       <include name="/se/micronic/util2/**"/>
     </javac> 
  </target>

is a bad idea. Javac is greedy and will automatically accept any strange
dependencies
to other code.
To combine with 'exclude' is a bad idea too. Then, build.xml would be very
hard to
maintain. Each time anyone adds a package, the build.xml would need to be
updated to
make sure util1 and util2 don't depend on the new pkg:(

The cmd-line
msdog>javac -classpath C:\work\3rdpartyjars\castor-xml.jar -sourcepath
SRC/se/micronic/util1 SRC/se/micronic/util1/*.java
works fine.
Seems wrong not to be able to use ant/javac for pure compilation.
I could use ant/exec:(

/klas
-----Original Message-----
From: mail.laconiadatasystems.com [mailto:webmaster@laconiadatasystems.com] 
Sent: Saturday, July 31, 2004 3:07 PM
To: Ant Users List
Subject: Re: ant/javac prepends destdir to classpath


Klas-
Does the same hold true if you use package exclude and package include ?
 <javac srcdir="${src}"
         destdir="${build}"
         includes="A/**"
         excludes="X/**"
         classpath="xyz.jar"
         debug="on"
  />
replik vars├ągod,
-martin
----- Original Message -----
From: "Klas Eriksson" <klas.eriksson@micronic.se>
To: <user@ant.apache.org>
Sent: Thursday, July 29, 2004 2:25 AM
Subject: ant/javac prepends destdir to classpath


> Hi
>
> I have illegal code, A.java, that doesn't compile using 'javac' manually
at
> cmd-line.
> Fine.
>
> But when I use ant/javac A.java compiles, and that's wrong since it refers
> to a package it shouldn't be able to access. (This package is available
for
> other code in directory X.)
> The problem is that ant/javac seems to automatically prepend the
> destdir="X" to the classpath when compiling.
> Is this a bug or how to I prevent ant/javac to improvise its own
classpath?
>
> When i run "ant -verbose" I clearly see that the directory "X" is
prepended
> to the classpath by ant.
> The problem is both in ant v1.5 and v1.6.
>
> /klas
>


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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message