Skip to content

Commit b929959

Browse files
committed
move module-info.java out of the java directory to avoid problems in eclipse
1 parent 69946c6 commit b929959

3 files changed

Lines changed: 62 additions & 12 deletions

File tree

pom.xml

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
--add-opens org.htmlunit/org.htmlunit.util.quercus.servlet=ALL-UNNAMED
4141
</surefire.argLine.modules>
4242

43-
<htmlunitcsp.version>5.0.0-SNAPSHOT</htmlunitcsp.version>
44-
<htmlunitcssparser.version>5.0.0-SNAPSHOT</htmlunitcssparser.version>
45-
<htmlunitcorejs.version>5.0.0-SNAPSHOT</htmlunitcorejs.version>
46-
<htmlunitneko.version>5.0.0-SNAPSHOT</htmlunitneko.version>
47-
<htmlunitwebsocketclient.version>4.21.0</htmlunitwebsocketclient.version>
48-
<htmlunitxpath.version>5.0.0-SNAPSHOT</htmlunitxpath.version>
43+
<htmlunit-csp.version>5.0.0-SNAPSHOT</htmlunit-csp.version>
44+
<htmlunit-cssparser.version>5.0.0-SNAPSHOT</htmlunit-cssparser.version>
45+
<htmlunit-corejs.version>5.0.0-SNAPSHOT</htmlunit-corejs.version>
46+
<htmlunit-neko.version>5.0.0-SNAPSHOT</htmlunit-neko.version>
47+
<htmlunit-websocketclient.version>4.21.0</htmlunit-websocketclient.version>
48+
<htmlunit-xpath.version>5.0.0-SNAPSHOT</htmlunit-xpath.version>
4949

5050
<httpcomponents.version>4.5.14</httpcomponents.version>
5151
<commons-lang3.version>3.20.0</commons-lang3.version>
@@ -81,6 +81,7 @@
8181

8282
<!-- plugins -->
8383
<central-publishing-plugin.version>0.9.0</central-publishing-plugin.version>
84+
<build-helper-plugin.version>3.6.1</build-helper-plugin.version>
8485
<checkstyle-plugin.version>3.6.0</checkstyle-plugin.version>
8586
<pmd-plugin.version>3.28.0</pmd-plugin.version>
8687
<spotbugs-plugin.version>4.9.8.2</spotbugs-plugin.version>
@@ -100,6 +101,26 @@
100101

101102
<build>
102103
<plugins>
104+
<plugin>
105+
<groupId>org.codehaus.mojo</groupId>
106+
<artifactId>build-helper-maven-plugin</artifactId>
107+
<version>${build-helper-plugin.version}</version>
108+
<executions>
109+
<execution>
110+
<id>add-module-source</id>
111+
<phase>generate-sources</phase>
112+
<goals>
113+
<goal>add-source</goal>
114+
</goals>
115+
<configuration>
116+
<sources>
117+
<source>src/main/module-info</source>
118+
</sources>
119+
</configuration>
120+
</execution>
121+
</executions>
122+
</plugin>
123+
103124
<plugin>
104125
<groupId>org.apache.maven.plugins</groupId>
105126
<artifactId>maven-compiler-plugin</artifactId>
@@ -1364,32 +1385,32 @@
13641385
<dependency>
13651386
<groupId>org.htmlunit</groupId>
13661387
<artifactId>htmlunit-core-js</artifactId>
1367-
<version>${htmlunitcorejs.version}</version>
1388+
<version>${htmlunit-corejs.version}</version>
13681389
</dependency>
13691390
<dependency>
13701391
<groupId>org.htmlunit</groupId>
13711392
<artifactId>neko-htmlunit</artifactId>
1372-
<version>${htmlunitneko.version}</version>
1393+
<version>${htmlunit-neko.version}</version>
13731394
</dependency>
13741395
<dependency>
13751396
<groupId>org.htmlunit</groupId>
13761397
<artifactId>htmlunit-cssparser</artifactId>
1377-
<version>${htmlunitcssparser.version}</version>
1398+
<version>${htmlunit-cssparser.version}</version>
13781399
</dependency>
13791400
<dependency>
13801401
<groupId>org.htmlunit</groupId>
13811402
<artifactId>htmlunit-xpath</artifactId>
1382-
<version>${htmlunitxpath.version}</version>
1403+
<version>${htmlunit-xpath.version}</version>
13831404
</dependency>
13841405
<dependency>
13851406
<groupId>org.htmlunit</groupId>
13861407
<artifactId>htmlunit-csp</artifactId>
1387-
<version>${htmlunitcsp.version}</version>
1408+
<version>${htmlunit-csp.version}</version>
13881409
</dependency>
13891410
<dependency>
13901411
<groupId>org.htmlunit</groupId>
13911412
<artifactId>htmlunit-websocket-client</artifactId>
1392-
<version>${htmlunitwebsocketclient.version}</version>
1413+
<version>${htmlunit-websocketclient.version}</version>
13931414
</dependency>
13941415

13951416
<dependency>

src/main/module-info/readme.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Module Info Directory
2+
3+
This directory contains the `module-info.java` file for the Java Platform Module System (JPMS).
4+
5+
## Why is this in a separate directory?
6+
7+
The `module-info.java` file is kept separate from `src/main/java/` for the following reasons:
8+
9+
1. **Eclipse IDE Compatibility**: Eclipse has known issues with Java modules, particularly when the project uses older Java versions or has complex module configurations. Keeping `module-info.java` separate prevents Eclipse from attempting to process it during development.
10+
11+
2. **Build-Time Integration**: The module descriptor is added to the compilation during the Maven build process via the `build-helper-maven-plugin`, which adds this directory as a source folder only during the build.
12+
13+
3. **IDE Independence**: This approach allows developers to use Eclipse without module-related compilation errors while still producing proper modular JARs when building with Maven.
14+
15+
## How it works
16+
17+
The Maven build process:
18+
1. Compiles all regular Java sources from `src/main/java/`
19+
2. Adds `src/main/module-info/` as an additional source directory
20+
3. Compiles `module-info.java`
21+
4. Packages everything into a proper modular JAR
22+
23+
## For Developers
24+
25+
- **Eclipse users**: You don't need to worry about this file - Eclipse won't see it
26+
- **IntelliJ users**: IntelliJ handles modules better and can work with this setup
27+
- **Maven builds**: The module descriptor is automatically included in the final JAR
28+
29+
If you need to modify the module descriptor, edit `src/main/module-info/module-info.java` directly.

0 commit comments

Comments
 (0)