ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "XiaoWei Zhang" <XZh...@qilinsoft.com>
Subject RE: Newbie: <javac> task can't find my source files
Date Fri, 26 Aug 2011 03:03:03 GMT
Hi Ego,

I'm not sure what the root cause for your problem is. But I'd like to
share how we use 'javac' target in our production environment, hope it
would be of help.

Firstly, we defined a common target named 'common-compile' in a XML
which can be imported by the 'real' build XML files, the scriptlet of
invoking 'javac' in this target implementation is as following:
        <!-- options other than 'srcdir' are not displayed -->
        <javac srcdir="${src.dir}">
            <classpath refid="compile.classpath"/>
            <!-- Source includes/excludes passed in from calling build
file -->
            <patternset refid="compile.file.patternset"/>
            <!-- Optional compile arguments not directly supported as
attributed -->
            <compilerarg line="${compile.arg.list}"/>

To use this target, we wrote following lines in the build.xml:
        <target name="compile" description="Compile code"
depends="init">
            <patternset id="module.compile.file.patternset">
                <include name="*.java"/>
                <exclude name="folder1toexclude/*"/>
                <exclude name="folder2toexclude /*"/>
            </patternset>
            <antcall target="common-compile">
                <param name="src.dir" location="."/>
                <param name="dst.dir" location="${module.class.dir}"/>
                <reference refid="module.compile.classpath"
torefid="compile.classpath"/>
                <reference refid="module.compile.file.patternset"
                   torefid="compile.file.patternset"/>  
            </antcall>
        </target>

No matter where the build.xml was placed, you can run it smoothly as
long as you imported the common XML which defines 'common-compile'
target.

Also, I'd suggest not using ${basedir} in your build.properties, because
per your description it's a common properties file which may be shared
by other build XML files. While referenced from build XML files under
different folders, it can be of different values and in turn bring you
problem.

Regards,
-Xiaowei Zhang
-----Original Message-----
From: Ego [mailto:m47841-mailinglists@yahoo.it] 
Sent: Thursday, August 25, 2011 9:17 PM
To: Ant Users List
Cc: Scot P. Floess
Subject: Re: Newbie: <javac> task can't find my source files

SOLVED:
Still I can't say why all <include>/<exclude> statements fail in my
configuration, but at last I found a workaround. I'll post it in case
someone had similar issues.

build.properties
----------------
src.dir=${basedir}/projects/modules/src
# I overlooked subpackage sr2 previously, but that's not essential.
# Even including it (the old way, I mean) I get "[javac] No sources
found."
src1=${src.dir}/apps/gdv/
src2=${src.dir}/packages/gui/elements/
src3=${src.dir}/packages/sde/actor/
src4=${src.dir}/packages/sde/monitor/
src5=${src.dir}/packages/sde/semaphore/
src6=${src.dir}/packages/synch/
build.dir=${basedir}/projects/WEB-INF/build
dist.dir=${basedir}/projects/WEB-INF/dist
project.name=gdv
main-class=apps.gdv.GDVLauncher
# I wish I could be more platform independent here...
jar-classpath=.\\gdv.jar


And here's the 'compile' task:

<target name="compile" depends="init">
 <javac sourcepath="${src.dir}/apps/gdv/GDVLauncher.java"
	srcdir="${src1}:${src2}:${src3}:${src4}:${src5}:${src6}"
	includeantruntime="false"
	destdir="${build.dir}" 
	debug="on"
/>
</target>

---------------------------------------------------------------------
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