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 14:09:11 GMT
Hello Simon,
oh, that is not going to be as easy as you would like to have it. Basically
you can use the includes/excludes attribute of the javac task. this should do
the trick. There you can define classes or whole directories. 
I am not sure, what kind of directory structure is recommended by Eric, but
everything seems to be better then your current structure. 

Regards,

marcus

> Marcus,
> Thanks for coming back to me on this. The problem is that in the real
> world,
> there are classes in the 1st package that I don't want compiled (and
> indeed
> will fail to compile). I only want the classes from the 1st package
> compiled
> if they are referenced by the 2nd package. This is what the command line
> gives you, and I'm sure that And can to the same, if only I know how to
> ask
> it. ;-)
> 
> Now I know that this is a shockingly bad package structure, but I'm hoping
> to use Ant in an existing project (replacing some gruesome batch files),
> and
> the structure is a given. *Next* project, I'll try for a sane directory &
> package structure - "Java Development with Ant" by Hatcher & Loughran has
> advice on this, which I'll follow.
> 
> Cheers,
> Simon Brunning
> TriSystems Ltd.
> sbrunning@trisystems.co.uk
> 
> > -----Original Message-----
> > From:	mmay@gmx.net [SMTP:mmay@gmx.net]
> > Sent:	Tuesday, February 25, 2003 1:45 PM
> > To:	Ant Users List
> > Subject:	Re: Dependency checking, and the javac task
> > 
> > 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\St
> > ri
> > > 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\St
> > ri
> > > 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\St
> > ri
> > > 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\St
> > ri
> > > 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!
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> > 
> > 
> > 
> > 
> -----------------------------------------------------------------------
> 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