|
View:
New views
10 Messages
—
Rating Filter:
Alert me
|
|
|
Advanced includes/excludes for javacHi there,
I have a problem with the javac task that I cannot solve, maybe somebody can help me. Let's say I have a directory layout like this: src/proj1/Class1.java src/proj1/Class2.java src/proj2/Class1.java src/proj2/Class2.java Now I want to compile Class1 from proj1 and Class2 from proj2 and exclude the other two. Also, I need to compile those in one go because they depend on each other. I didn't find a way to implement this using the srcdir attribute, or nested src tags. Any ideas? Cheers, Roman -- http://kennke.org/blog/ |
|
|
Re: Advanced includes/excludes for javacGive this a try:
<javac ..> <include name="src/proj1/Class1.java src/proj2/Class2.java"/> </javac> This is not something I typically do...and don't have time to test it... The javac task HTML has some more information on this... On Mon, 23 Jun 2008, Roman Kennke wrote: > Hi there, > > I have a problem with the javac task that I cannot solve, maybe somebody > can help me. Let's say I have a directory layout like this: > > src/proj1/Class1.java > src/proj1/Class2.java > src/proj2/Class1.java > src/proj2/Class2.java > > Now I want to compile Class1 from proj1 and Class2 from proj2 and > exclude the other two. Also, I need to compile those in one go because > they depend on each other. I didn't find a way to implement this using > the srcdir attribute, or nested src tags. Any ideas? > > Cheers, Roman > > -- > http://kennke.org/blog/ > 27 Lake Royale Louisburg, NC 27549 252-478-8087 (Home) 919-754-4592 (Work) Chief Architect JPlate http://sourceforge.net/projects/jplate Chief Architect JavaPIM http://sourceforge.net/projects/javapim Architect Keros http://sourceforge.net/projects/keros --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Advanced includes/excludes for javacHi Scot,
> Give this a try: > > <javac ..> > <include name="src/proj1/Class1.java src/proj2/Class2.java"/> > </javac> I don't think this works because the include/exclude is always relative to the src dirs. I think I could trick it by setting the source dir to some common top-level dir of the two subprojects, but then the javac task could not map the source to class files anymore and I would end up compiling all the stuff all the time (something I'd like to avoid). > The javac task HTML has some more information on this... Yeah, I already read through it and tried a couple of options, but none of them seemed to work, for example: <javac> <src> <pathelement location="proj1" /> <exclude name="Class1.java" /> </src> <src> <pathelement location="proj2" /> </src> </javac> doesn't work. <javac> <src> <fileset dir="proj1"> <include name="Class1.java" /> </fileset> <fileset dir="proj2"> <include name="Class2.java" /> </fileset> </src> </javac> Doesn't work either. Etc etc. The basic problem is that javac only accepts one set of includes/excludes per javac task, but I need one set of includes/excludes per srcdir. I'm hoping that I simply overlooked something...? If this is really not possible, I'd think about extending the javac task for that, OR implement a special task that can do this. Then I'd like to discuss at which point you think I should add the includes/excludes. /Roman -- http://kennke.org/blog/ |
|
|
Re: Advanced includes/excludes for javacHmm...
I'm at a loss... Just curious, why are you doing this or need to do this? On Mon, 23 Jun 2008, Roman Kennke wrote: > Hi Scot, > >> Give this a try: >> >> <javac ..> >> <include name="src/proj1/Class1.java src/proj2/Class2.java"/> >> </javac> > > I don't think this works because the include/exclude is always relative > to the src dirs. I think I could trick it by setting the source dir to > some common top-level dir of the two subprojects, but then the javac > task could not map the source to class files anymore and I would end up > compiling all the stuff all the time (something I'd like to avoid). > >> The javac task HTML has some more information on this... > > Yeah, I already read through it and tried a couple of options, but none > of them seemed to work, for example: > > <javac> > <src> > <pathelement location="proj1" /> > <exclude name="Class1.java" /> > </src> > <src> > <pathelement location="proj2" /> > </src> > </javac> > > doesn't work. > > <javac> > <src> > <fileset dir="proj1"> > <include name="Class1.java" /> > </fileset> > <fileset dir="proj2"> > <include name="Class2.java" /> > </fileset> > </src> > </javac> > > Doesn't work either. Etc etc. The basic problem is that javac only > accepts one set of includes/excludes per javac task, but I need one set > of includes/excludes per srcdir. I'm hoping that I simply overlooked > something...? > > If this is really not possible, I'd think about extending the javac task > for that, OR implement a special task that can do this. Then I'd like to > discuss at which point you think I should add the includes/excludes. > > /Roman > > -- > http://kennke.org/blog/ > 27 Lake Royale Louisburg, NC 27549 252-478-8087 (Home) 919-754-4592 (Work) Chief Architect JPlate http://sourceforge.net/projects/jplate Chief Architect JavaPIM http://sourceforge.net/projects/javapim Architect Keros http://sourceforge.net/projects/keros --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Advanced includes/excludes for javacRoman Kennke wrote:
> Hi there, > > I have a problem with the javac task that I cannot solve, maybe somebody > can help me. Let's say I have a directory layout like this: > > src/proj1/Class1.java > src/proj1/Class2.java > src/proj2/Class1.java > src/proj2/Class2.java > > Now I want to compile Class1 from proj1 and Class2 from proj2 and > exclude the other two. Also, I need to compile those in one go because > they depend on each other. I didn't find a way to implement this using > the srcdir attribute, or nested src tags. Any ideas? > You are in trouble as javac is going to take over. If it wants something, it may take it anyway. If you have to do this -and the only place I've even encountered such a thing was laptop bioses- the trick is to copy all the files you want to one location, and none of the files you dont want. This will build, but leave you with another nightmare, working out which files are actually included. I would strongly encourage you not to do this. The laptop bioses almost made sense, because they had to fit into a small amount of memory, but even then the copies and the mess of #ifdef blocks meant the usual test for 'is some code in the build' was to edit the file so that it couldn't compile, then see if that broke the build. -- Steve Loughran http://www.1060.org/blogxter/publish/5 Author: Ant in Action http://antbook.org/ --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Advanced includes/excludes for javacHi there,
> I'm at a loss... > > Just curious, why are you doing this or need to do this? I'm developer of a Java VM project, and we are using most of the class library from GNU Classpath or OpenJDK, and replace some pieces, like the java.lang package (the stuff that is closest to the VM basically). We also wouldn't like to delete .java files from the external class library path. Our current solution is to build the list of java classes to be compiled using a complicated script and passing the result list to javac, but using ant would be much nicer. (As a side note, the Eclispe IDE is able to handle such complex includes/excludes too.) Cheers, Roman -- http://kennke.org/blog/ |
|
|
Re: Advanced includes/excludes for javacAh gotcha...makes sense :)
On Mon, 23 Jun 2008, Roman Kennke wrote: > Hi there, > >> I'm at a loss... >> >> Just curious, why are you doing this or need to do this? > > I'm developer of a Java VM project, and we are using most of the class > library from GNU Classpath or OpenJDK, and replace some pieces, like the > java.lang package (the stuff that is closest to the VM basically). We > also wouldn't like to delete .java files from the external class library > path. > > Our current solution is to build the list of java classes to be compiled > using a complicated script and passing the result list to javac, but > using ant would be much nicer. (As a side note, the Eclispe IDE is able > to handle such complex includes/excludes too.) > > Cheers, Roman > > -- > http://kennke.org/blog/ > Scot P. Floess 27 Lake Royale Louisburg, NC 27549 252-478-8087 (Home) 919-754-4592 (Work) Chief Architect JPlate http://sourceforge.net/projects/jplate Chief Architect JavaPIM http://sourceforge.net/projects/javapim Architect Keros http://sourceforge.net/projects/keros --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Advanced includes/excludes for javacOn Mon, Jun 23, 2008 at 5:40 AM, Roman Kennke <roman@...> wrote:
> I have a problem with the javac task that I cannot solve, maybe somebody > can help me. Let's say I have a directory layout like this: > > src/proj1/Class1.java > src/proj1/Class2.java > src/proj2/Class1.java > src/proj2/Class2.java > > Now I want to compile Class1 from proj1 and Class2 from proj2 and > exclude the other two. Also, I need to compile those in one go because > they depend on each other. I didn't find a way to implement this using > the srcdir attribute, or nested src tags. Any ideas? The only way to do this is by resetting srcdir to an empty string. That's the technique <compilewithwalls> and others (including me) have used in the past. That way, Javac will compile *only* the file explicitly given to it, and never implicitly compile files the explicitly given classes depend on (which will lead to compile failures if the depend classes aren't found via the classpath). AFAIK, <javac> will accept several nested <fileset>s, so that's how you include source files from several directories (but remember to scrdir=""). --DD |
|
|
Re: Advanced includes/excludes for javacHi Dominique,
> > I have a problem with the javac task that I cannot solve, maybe somebody > > can help me. Let's say I have a directory layout like this: > > > > src/proj1/Class1.java > > src/proj1/Class2.java > > src/proj2/Class1.java > > src/proj2/Class2.java > > > > Now I want to compile Class1 from proj1 and Class2 from proj2 and > > exclude the other two. Also, I need to compile those in one go because > > they depend on each other. I didn't find a way to implement this using > > the srcdir attribute, or nested src tags. Any ideas? > > The only way to do this is by resetting srcdir to an empty string. > That's the technique <compilewithwalls> and others (including me) have > used in the past. > > That way, Javac will compile *only* the file explicitly given to it, > and never implicitly compile files the explicitly given classes depend > on (which will lead to compile failures if the depend classes aren't > found via the classpath). > > AFAIK, <javac> will accept several nested <fileset>s, so that's how > you include source files from several directories (but remember to > scrdir=""). --DD the javac task could not map the sources to the .class files, and would recompile everything on each invocation. Correct me if I'm wrong. However, I think I found a better solution that works for me. Instead of compiling it in one go, I compile it in 2 steps, and in the 1st step I set the -sourcepath to the other sources dir, so that javac pulls in the required sources from the other project. Then in the second step, I set the classpath to the directory into which the 1st step built its classes, so that it picks up the correct dependencies again. In both steps I can set the necessary includes/excludes. For the simplified example I gave above, this would look like: <javac srcdir="proj1" excludes="Class2.java" destdir="classes" sourcepath="proj2"/> <javac srcdir="proj2" excludes="Class1.java" destdir="classes" classpath="classes" /> Of course, having this in one javac task invocation would be much nicer. *hint* Cheers, Roman -- http://kennke.org/blog/ |
|
|
Re: Advanced includes/excludes for javacOn Mon, Jun 23, 2008 at 2:25 PM, Roman Kennke <roman@...> wrote:
>> The only way to do this is by resetting srcdir to an empty string. >> That's the technique <compilewithwalls> and others (including me) have >> used in the past. >> >> That way, Javac will compile *only* the file explicitly given to it, >> and never implicitly compile files the explicitly given classes depend >> on (which will lead to compile failures if the depend classes aren't >> found via the classpath). >> >> AFAIK, <javac> will accept several nested <fileset>s, so that's how >> you include source files from several directories (but remember to >> scrdir=""). --DD > > Yeah, I suppose this would work. But it would have the disadvantage that > the javac task could not map the sources to the .class files, and would > recompile everything on each invocation. Correct me if I'm wrong. I think it may be... (note the "may" here). I don't have time to double-check, but I believe <javac> checks against the destdir to find out is a .java is up-to-date, not the srcdir. (And when I say <javac>, I mean Ant's wrapper around Sun's Javac compiler, since Javac itself do not do that). Thinking about it, it has to be that way, because I used this technique for a large project that was doing incremental compiles. > However, I think I found a better solution that works for me. Instead of > compiling it in one go, I compile it in 2 steps, and in the 1st step I > set the -sourcepath to the other sources dir, so that javac pulls in the > required sources from the other project. Then in the second step, I set > the classpath to the directory into which the 1st step built its > classes, so that it picks up the correct dependencies again. In both > steps I can set the necessary includes/excludes. Whatever works for you ;-) --DD --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
| Free Forum Powered by Nabble | Forum Help |