Re: javac task question
Alan Snyder <[email protected]> Wed, 20 Dec 2023 15:37:51 -0800
| Newsgroups | gmane.comp.jakarta.ant.user |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_6EF4912D-B86A-43C0-8C6F-8F53AB3D9CCC
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=utf-8
This actually does what I want:
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
<project name=3D"test" default=3D"t" basedir=3D".">
<path id=3D"p">
<fileset dir=3D"a"/>
<fileset dir=3D"b"/>
</path>
<target name=3D"t">
<javac srcdir=3D"." sourcepathref=3D"p"/>
</target>
</project>
The problem is that I don=E2=80=99t really want to specify srcdir, but =
if I leave it out, the build fails (see below).
I would need to create a fake directory to use as srcdir to be sure that =
I don=E2=80=99t accidentally compile unwanted sources.
Apache Ant(TM) version 1.10.14 compiled on August 16 2023
Trying the default build file: build.xml
Buildfile: /Users/alan/testAnt1/build.xml
Detected Java version: 21 in: =
/Library/Java/JavaVirtualMachines/jdk-21.0.1.jdk/Contents/Home
Detected OS: Mac OS X
parsing buildfile /Users/alan/testAnt1/build.xml with URI =3D =
file:/Users/alan/testAnt1/build.xml
Project base dir set to: /Users/alan/testAnt1
parsing buildfile =
jar:file:/Users/alan/.ant/lib/vbuilder-ant-uber-1.0-SNAPSHOT.jar!/org/apac=
he/tools/ant/antlib.xml with URI =3D =
jar:file:/Users/alan/.ant/lib/vbuilder-ant-uber-1.0-SNAPSHOT.jar!/org/apac=
he/tools/ant/antlib.xml from a zip file
parsing buildfile =
jar:file:/usr/local/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml =
with URI =3D =
jar:file:/usr/local/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml =
from a zip file
Build sequence for target(s) `t' is [t]
Complete build sequence is [t, ]
t:
BUILD FAILED
/Users/alan/testAnt1/build.xml:11: either srcdir or modulesourcepath =
attribute must be set!
at =
org.apache.tools.ant.taskdefs.Javac.checkParameters(Javac.java:1309)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:1080)
at =
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)
at =
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMet=
hodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at =
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)=
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.Target.execute(Target.java:449)
at org.apache.tools.ant.Target.performTasks(Target.java:470)
at =
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401)
at org.apache.tools.ant.Project.executeTarget(Project.java:1374)
at =
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor=
.java:41)
at =
org.apache.tools.ant.Project.executeTargets(Project.java:1264)
at org.apache.tools.ant.Main.runBuild(Main.java:818)
at org.apache.tools.ant.Main.startAnt(Main.java:223)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
Total time: 0 seconds
> On Dec 19, 2023, at 10:17=E2=80=AFPM, Jaikiran Pai =
<[email protected]> wrote:
>=20
> Hello Alan,
>=20
> It's hard to say what's going on. Do you have a build file (or a =
snippet) to show what issue you are running into?
>=20
> Which version of Java and Ant is this showing up on?
>=20
> -Jaikiran
>=20
> On 18/12/23 1:44 am, Alan Snyder wrote:
>> I know of a couple of ways to run javac on more than one source tree.
>>=20
>> One way is to use nested src elements.
>>=20
>> Another way is like this:
>>=20
>> srcdir=3D"${src}:${src2}=E2=80=9D
>>=20
>> I would like to generalize this solution to a dynamicly determined =
list of source trees.
>>=20
>> I thought that I could use srcpath for this purpose, but the task =
would fail if srcdir was not specified or it did not identify a valid =
directory.
>> That restriction defeats my purpose.
>>=20
>> Is there a solution?
>>=20
>> Is the inability to use srcpath by itself a bug?
>>=20
>> Thank you.
>>=20
>>=20
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>=20
>=20
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>=20
--Apple-Mail=_6EF4912D-B86A-43C0-8C6F-8F53AB3D9CCC--