Bug 578306 - Support '*' in module source path expressions
Summary: Support '*' in module source path expressions
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.22   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact: Jay Arthanareeswaran CLA
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2022-01-21 00:04 EST by Alexander Kriegisch CLA
Modified: 2024-01-12 14:07 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Kriegisch CLA 2022-01-21 00:04:11 EST
Javac supports '*' in module path expressions, where '*' is the module name.

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

E.g. if you compile in multi-module mode and the directory layout is

modules
  org.acme.first
    src
  org.acme.second
    src

then you can use:
  --module-source-path "modules/*/src"

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

If the layout is maven-ish like

org.acme.first
  src
    main
      java
org.acme.second
  src
    main
      java

then you can use:
  --module-source-path "*/src/main/java"

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

The closest I found, someone mentioning the '*' jokers and even more comples expressions with curly braces (which I did not try yet) from JEP 261, was this remark in the original issue for Java 9 support in the batch compiler: https://bugs.eclipse.org/bugs/show_bug.cgi?id=487421#c3

Anyway, it seems as if this was never implemented (or I am making a silly mistake), because when trying to replace Javac by ECJ stand-alone (I tested 3.28.0), using a command line like

  --module-source-path "modules/*/src"
or in a unix-oid shell
  --module-source-path "modules/\*/src"

the compiler says:

  ERROR in ...\modules\org.acme.second\src\module-info.java (at line 2)
        exports org.acme.second;
                ^^^^^^^^^^^^^^^
  The package org.acme.second does not exist or is empty

This seems due to the fact that the multi-module directory layout is not preserved but all classes from both modules are compiled into a single target directory, one module-info.class overwriting the other.

The '--module-source-path' option only seems to work correctly when using the default layout and not using '*', e.g.

modules
  org.acme.first
  org.acme.second

where the latter two directly contain the sources of the so named modules.
Comment 1 Jay Arthanareeswaran CLA 2022-01-21 00:07:57 EST
(In reply to Alexander Kriegisch from comment #0)
> 
> The closest I found, someone mentioning the '*' jokers and even more comples
> expressions with curly braces (which I did not try yet) from JEP 261, was
> this remark in the original issue for Java 9 support in the batch compiler:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=487421#c3
> 
> Anyway, it seems as if this was never implemented (or I am making a silly
> mistake), because when trying to replace Javac by ECJ stand-alone (I tested
> 3.28.0), using a command line like

You are right. I don't recall me or anyone working on this feature. Would be nice if someone takes this up. Not sure if I can get to this any time soon.
Comment 2 Alexander Kriegisch CLA 2022-01-21 06:53:06 EST
Actually, there is one more thing: ECJ also does not support the '-m, --module' options, see [1] and comments below [2]. As you can see, I actually bumped into this because of the AspectJ compiler. As you probably remember, it forks ECJ. Therefore, implementing this in order to be compatible with Javac would not only enable users to do the same things as Javac users from the console or from Maven, but also benefit the AspectJ project as a side effect.

Do we need an extra issue for '-m, --module'?

[1] https://github.com/eclipse/org.aspectj/issues/118#issuecomment-1018221942
[2] https://stackoverflow.com/a/70778762/1082681
Comment 3 Alexander Kriegisch CLA 2022-01-21 23:57:28 EST
See [3] and the linked ZIP archive, if you need an example project with two modules to play with.

[3] https://github.com/eclipse/org.aspectj/issues/118#issuecomment-1019051812
Comment 4 Eclipse Genie CLA 2024-01-12 14:07:03 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.