ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@gmx.net
Subject Re: Dependency checking, and the javac task
Date Tue, 25 Feb 2003 13:45:24 GMT
Hello Simon,
you should try to give the sourcedirectory to ANT and not the
packagedirectory. This means due to the fact, that your sources are in the ant-test-01
directory (directly) just set the sourcedirectory to 
./ or even better to the ${basedir}. Then the Anttask will find all packages
and therefor all the sources needed to compile.

Have fun

Markus 

> New Ant user here, so please be gentle.
> 
> I have a bit of a problem with my first real build file. I've put together
> a
> simple example which shows the same problem.
> 
> I have two Java classes; (in
>
D:\Dev\eclipse-workspace\ant-test-01\smallvaluesofcool\anttest\package1\Stri
> ngProvider.java):
> 
> package smallvaluesofcool.anttest.package1;
> 
> public class StringProvider {
> 
>     public static String getString() {
>         return "Hello from
> smallvaluesofcool.anttest.package1.StringProvider";
>     }
> 
> }
> 
> ...and (in
>
D:\Dev\eclipse-workspace\ant-test-01\smallvaluesofcool\anttest\package2\Stri
> ngUser.java):
> 
> package smallvaluesofcool.anttest.package2;
> 
> import smallvaluesofcool.anttest.package1.StringProvider;
> 
> public class StringUser {
> 
>     public static void main(String[] args) {
>         System.out.println(StringProvider.getString());
>     }
> }
> 
> Running Sun's javac command tool from the command line as follows...
> 
> D:\Dev\eclipse-workspace\ant-test-01>javac
> smallvaluesofcool\anttest\package2\*.java -d d:\temp
> 
> ...works fine - both classes from both packages are compiled, even though
> I
> specified only the second.
> 
> Now, I try doing this with Ant. My build file (in
> D:\Dev\eclipse-workspace\ant-test-01\build.xml):
> 
> <?xml version="1.0"?>
> <project name="Ant test" default="all" basedir=".">
>   
>   <property name="sourcedirectory"
> value="./smallvaluesofcool/anttest/package2"/>
>   
>   <property name="destinationdirectory" value="D:\temp"/>
> 
>   <target name="build">
> 	
> 	<javac destdir="${destinationdirectory}"
> srcdir="${sourcedirectory}"/>
>     
>   </target>
> 
>   <target name="all" depends="build">
>   </target>
> 
> </project>
> 
> Running this (after clearing my temp directory), I get:
> 
> D:\Dev\eclipse-workspace\ant-test-01>ant
> Buildfile: build.xml
> 
> build:
>     [javac] Compiling 1 source file to D:\temp
>     [javac]
>
D:\Dev\eclipse-workspace\ant-test-01\smallvaluesofcool\anttest\package2\Stri
> ngUser.java:9: package smallvaluesofcool.anttest.package1 does not exist
>     [javac] import smallvaluesofcool.anttest.package1.StringProvider;
>     [javac]                                           ^
>     [javac]
>
D:\Dev\eclipse-workspace\ant-test-01\smallvaluesofcool\anttest\package2\Stri
> ngUser.java:17: cannot resolve symbol
>     [javac] symbol  : variable StringProvider
>     [javac] location: class smallvaluesofcool.anttest.package2.StringUser
>     [javac]         System.out.println(StringProvider.getString());
>     [javac]                            ^
>     [javac] 2 errors
> 
> BUILD FAILED
> file:D:/Dev/eclipse-workspace/ant-test-01/build.xml:10: Compile failed;
> see
> the compiler error output for details.
> 
> Total time: 2 seconds
> 
> Why doesn't ant pick up the fact that package2 depends on a class in
> package1, and compile this too? The command line version does.
> 
> Using Java 1.4, Ant 1.5, Wndows NT.
> 
> Cheers,
> Simon Brunning
> TriSystems Ltd.
> sbrunning@trisystems.co.uk
> 
> 
> 
> 
> 
> -----------------------------------------------------------------------
> The information in this email is confidential and may be legally
> privileged.
> It is intended solely for the addressee. Access to this email by anyone
> else
> is unauthorised. If you are not the intended recipient, any disclosure,
> copying, distribution, or any action taken or omitted to be taken in
> reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
> accept liability for statements made which are clearly the senders own.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
Bitte l├Ącheln! Fotogalerie online mit GMX ohne eigene Homepage!


Mime
View raw message