Bug 63309 - Javac should not require modulepath with source, and target < 9
Summary: Javac should not require modulepath with source, and target < 9
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.10.1
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
Depends on:
Reported: 2019-04-02 09:17 UTC by Jochen Wiedmann
Modified: 2019-04-02 18:26 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Jochen Wiedmann 2019-04-02 09:17:03 UTC
In a basic Jar project, with source=target=1.8, I am getting this message:

  either srcdir or modulesourcepath attribute must be set!

While this might make perfect sense with source=target=9, it is (at best) surprising, and unnecessary in a 1.8 project.

What's worse: In the special case of modules, it is far from obvious what to fill in here, at least without some knowledge of Java 9. (The error message could help with that.)
Comment 1 Stefan Bodewig 2019-04-02 09:22:28 UTC
You need to tell Ant where to find your sources. In a Java project prior to Java 9 you specify srcdir and that's it. modulesourcepath is not required at all.

Before we started to support modulesourcepath srcdir was required and the error message has said so.
Comment 2 Jochen Wiedmann 2019-04-02 11:14:11 UTC
Okay, that works, if I am using the nested src element, or the srcdir attribute. It doesn't with sourcepath, or sourcepathref, though. (Which may, admittedly, be another problem.)
Comment 3 Stefan Bodewig 2019-04-02 11:57:35 UTC
It is supposed to work with sourcepath and sourcepathref as well, so maybe we just need to change this issue's subject :-)
Comment 4 Jochen Wiedmann 2019-04-02 12:28:56 UTC
Okay, only I can't do that, AFAICT.
Comment 5 Stefan Bodewig 2019-04-02 14:02:56 UTC
Not sure whether you could do it, but I've had a look at the code and I have simply been wrong.

The sourceath(ref) attributes or nested sourcepath elements correspond to javac's -sourcepath CLI arg. srcdir and the nested src element are there to create filesets that Ant uses to find all the files you want to compile. srcdir/src can not be replaced by sourcepath. My recollection has just been wrong.

So your basic jar project should use srcdir or nested src element and should never have used sourcepath at all. Has this worked with any older version of Ant?
Comment 6 Jochen Wiedmann 2019-04-02 18:26:50 UTC
Not sure. I can confirm, that it used to work with srcdir, rather than sourcepath, or sourcepathref, before. However, I recently had the need to add another source directory.