Bug 538159 - [9] ANT tasks swallow error messages (with classpath/modulepath problem)
Summary: [9] ANT tasks swallow error messages (with classpath/modulepath problem)
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 4.8   Edit
Hardware: PC Windows 10
: P3 major (vote)
Target Milestone: 4.10 M3   Edit
Assignee: Sarika Sinha CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-22 08:43 EDT by M H CLA
Modified: 2018-11-19 23:14 EST (History)
2 users (show)

See Also:


Attachments
Eclipse .log entries when clicking a simple ANT target (3.58 KB, text/plain)
2018-08-22 08:48 EDT, M H CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description M H CLA 2018-08-22 08:43:37 EDT
After fighting through the hassles of Java 9 (compiler compliance), I finally got my Java projects compiling again (main problem were missing JARs that needed to be added because of the new module system). 

The second step is now to convert a Java project to a module instead of a simple JAR. Well, it's still a simple JAR but with module-info.class included. I got a module-info.java for my first project compiling (required module for SOAP has to be added manually as Eclipse's Configure > Create module-info.java didn't generate this one.) Result was a compiling Java project with a "correct" module-info.java.

Now, the last step is remmaining: createing a JAR from my project. Because of misc reasons we use custom ANT build files to create our JARs. Eclipse's ANT view helps to just douple click the "CreateJAR" target. Now, with the project "converted" to a module (just added module-info.java), the ANT target doesn't work anymore!

The bad thing is: there is NO ERRO MESSAGE or anything else indicating what's wrong/missing! Even the simplest "init" target which just echo's text is not executed anymore. The only indicator is in the "Debug" View that shows

<terminated, exit value:1>

I didn't change anything in the ANT build file. As soon as I remove the module-info.java from the project (and go through dozens of Eclispe rebuild/clena cycles :-)), the ANT targets get back working.
Comment 1 M H CLA 2018-08-22 08:48:14 EDT
Created attachment 275491 [details]
Eclipse .log entries when clicking a simple ANT target
Comment 2 Stephan Herrmann CLA 2018-08-22 16:45:47 EDT
What happens if you run ant from the command line?
Comment 3 M H CLA 2018-08-24 03:12:46 EDT
Test with ANT (1.10.3) from command line with the same build.xml file:

A) without module-info.java : build es expected.

B) with module.info.java:

[javac] warning: [options] bootstrap class path not set in conjunction with -source 9
[javac] error: module not found: iCLibrary
[javac] error: module not found: junit
[javac] error: module not found: java.xml.soap
[javac] 3 errors
[javac] 1 warning

Eclipse compiles/builds fine with the module-java.info. The first 2 references leads just to warnings in Eclipse:

"Name of automatic module 'iCLibrary' is unstable, it is derived from the module's file name."
"Name of automatic module 'junit' is unstable, it is derived from the module's file name."

And for the last one I had to manually insert

requires java.xml.soap;

in the module-info.java for Eclipse to fully built the project. The classpath of the ANT file have the same entries as the Eclipse project.

So I guess, ANT has problems with "automatic modules". However, it would be good if Eclipse's ANT would also print these/such error messages to have at least some error messages.

But this doesn't solve the specific problem of the ANT build files not working anymore when module-info.java is present.
Comment 4 M H CLA 2018-08-24 03:20:20 EDT
And because it is so very annoying: just deleting the module-info.java from the project makes the wohle Java projects in the workingset (14 Java Projects in 1 Working set) completely red! I have to go randomly through dozens (!) of refresh/built/clean single/all projects multiple times until somewhen all red icons vanish.  :-(
Comment 5 Stephan Herrmann CLA 2018-08-24 03:36:40 EDT
Several things to consider:

org.eclipse.ant should check if any errors from ant are swallowed. Moving the bug to them.

M H should fix his ant files. Perhaps some dependencies should be moved from classpath to modulepath, but that's just a wild guess. There has been a lot of discussion how maven builds need to be updated to migrate to modules. I assume similar steps are needed for ant, too, but I'm unaware of any public discussions in this regard.

M H is invited to file a separate new bug report about excessively required clean cycles, if he is able to provide reproducing steps.
Comment 6 Sarika Sinha CLA 2018-08-24 04:18:37 EDT
Have you tried "Run in the same JRE as the workspace" ?
Comment 7 M H CLA 2018-08-28 01:01:53 EDT
Well, I'm not a tester but a developer, so I have to find time for such tests and as it takes 10-20 minutes alone to get all projects compiling again per test, I only can report a bug by description.

"Fixing" ANT files is the wrong term: as I understand you, ANT targets need to be written differently if Java modules exist. I thought Java modules are backwards compatible as they only contain the new java-module.class which is ignored by other/older processes.

The JRE doesn't seem to matter - I tried misc configurations. It seems to be restricted to the classpath/module path.
Comment 8 Stephan Herrmann CLA 2018-08-28 05:39:53 EDT
(In reply to M H from comment #7)
> Well, I'm not a tester but a developer, so I have to find time for such
> tests and as it takes 10-20 minutes alone to get all projects compiling
> again per test, I only can report a bug by description.

I appreciate any effort you take
 
> "Fixing" ANT files is the wrong term: as I understand you, ANT targets need
> to be written differently if Java modules exist. I thought Java modules are
> backwards compatible as they only contain the new java-module.class which is
> ignored by other/older processes.

Here I must correct you. The net is full of reports and guides for migrating to Java 9, which demonstrates that this migration can require substantial amount of tweaks and modifications. Java 9 is a breaking change (and Eclipse is just not the cause of it, only the "messenger").
 
While I'm not a committer on the Ant integration in Eclipse, I suggest to focus this bug report on the issue "there is NO ERRO MESSAGE or anything else indicating what's wrong/missing!" from comment 0. Swallowing error messages can cause all kinds of confusion, so that should be avoided with priority.
Comment 9 Eclipse Genie CLA 2018-11-09 06:40:31 EST
New Gerrit change created: https://git.eclipse.org/r/132184
Comment 11 Sarika Sinha CLA 2018-11-12 23:39:13 EST
Ant scripts in modular projects build fine now.

As ant class being run by java is still not modular it is run without the module option.
Comment 12 Sarika Sinha CLA 2018-11-19 23:14:14 EST
Verified using
Eclipse SDK

Version: 2018-12 (4.10)
Build id: I20181119-0600