ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Tobias.H...@hm.com>
Subject RE: compile only valid java files, skipping uncompilable files
Date Wed, 12 Feb 2003 15:39:56 GMT

Ok thanks. Good suggestion! 

I did however solve it in another way. 
By changing compiler (but only when 
compiling the test-classes) to jikes
I could "workaround" it. Jikes compiles
as much as possible, and does not stop
on first error. 

On the JUnitDoclet-issue:

> I don't know about JUnitDoclet, but I am surprised 
> that generated test-case stubs won't even compile! 

Yes, that was what I imagined as well. Unfortunately
it tries to create an instance of all classes within 
the test-stubs with the default constructor (). All our
classes does not have that however (and shouldn't).

Regards, 
Tobias







-----Original Message-----
From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
Sent: den 12 februari 2003 13:27
To: user@ant.apache.org
Subject: AW: compile only valid java files, skipping uncompilable files


Yep. That idea is good:

<project name="javac-test" default="compile">

    <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>

    <property name="src.dir" value="." />
    <property name="classes.dir" value="." />

    <target name="compile">
        <foreach target="javac" param="file">
            <path>
                <fileset dir="${src.dir}" includes="**/*.java" />
            </path>
        </foreach>
    </target>

    <target name="javac">
        <basename property="file.name" file="${file}"/>
        <javac
            srcdir="${src.dir}"
            destdir="${classes.dir}"
            includes="${file.name}"
            failonerror="false"
        />
    </target>

</project>


The one java file is compiled the other not (of course):

OK.java
public class OK {
}

Fail.java
public class Fail {
// }


I had to use the <basename> because ${file} is absolute (I think) and
<javac> don´t like absolute 
filenames. If you don´t have classes with the same name in different
directories of your ${src.test.dir},
it should work.


Jan Matèrne

-----Ursprüngliche Nachricht-----
Von: Keith Hatton [mailto:khatton@axiomsystems.com]
Gesendet am: Mittwoch, 12. Februar 2003 12:59
An: Ant Users List
Betreff: RE: compile only valid java files, skipping uncompilable files

Hi Tobias,

I think you need two targets.

One target that excludes your test-case classes as Benoit describes.
Then another target that attempts to compile your test-case classes using
<javac failonerror="false">...</javac>

But this is still not really what you want, because javac itself may decide
to stop compiling if there are so many errors (so it may not compile the
test-case classes that would compile successfully). Perhaps you need to code
your ant script to attempt compilation of each test-case class on a
one-by-one basis - maybe look at the optional foreach task, for example
(check list archives for the URL for this task download).

I don't know about JUnitDoclet, but I am surprised that generated test-case
stubs won't even compile! (I would expect them to compile but fail at
runtime).

Really, the best solution is only to try and compile files that you expect
to compile.

Keith


-----Original Message-----
From: Tobias.Hill@hm.com [mailto:Tobias.Hill@hm.com]
Sent: 12 February 2003 10:50
To: user@ant.apache.org
Subject: RE: compile only valid java files, skipping uncompilable files


The problem is that the generated test-
stubs are very many and I (and the rest
of our team) would like to be able to 
finnish them of one by one and still be 
able to make builds (ony including the 
finnshed tests) The exclude strategy 
will work but will be quite tedious. 

I thought that there was some kind of 
support for this in the javac-task itself?

/Tobias





-----Original Message-----
From: Benoit Voisin [mailto:benoit.voisin@ergoidp.dk]
Sent: den 12 februari 2003 11:41
To: 'Ant Users List'
Subject: RE: compile only valid java files, skipping uncompilable files


Just an idea:
If you know which file will fail, you can try excluding them (excludes
attribute of the javac task).
And eventually rerun javac without exclusion to try compiling them anyway.

Benoit

-----Original Message-----
From: Tobias.Hill@hm.com [mailto:Tobias.Hill@hm.com]
Sent: 12 February 2003 11:14
To: user@ant.apache.org
Subject: compile only valid java files, skipping uncompilable files


Hi,

I would like to be able to compile all java-
files in a certain directory stucture and 
have them outputted to a destination dir. 
This in itself is very staightforward as
long as _all_ java-files in the source 
directory _can_ be compiled. But when there
are any file in the source directory that 
does not compile no class files at all will 
be put in the destnation dir!

In the certain situation I am in (I have some
"junitdoclet-generated" test java-stubs that 
does not compile (and intentionally I like to 
leave it that way)) I really need to get at 
least those class-files that do compile
to apear in the dest-dir. 

How do I do this? 
Please help me out here. 

/Tobias

- - - - - - - - - - - - - - - - - - - - - - 

Addendum:
The ant task looks like this

        <!-- Compile Java TEST classes for application -->
        <javac
            srcdir="${src.test.dir}"
            destdir="${build.classes.dir}/tests"
            classpathref="app.class.path"
            debug="${build.debug}"
            failonerror="false"
            >
            <include name="**/*"/>
            <exclude name="**/ejb/**/*"/>
            <exclude name="**/web/**/*"/>
        </javac>

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

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

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


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

Mime
View raw message