Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems using ecj for modular project #147

Closed
hallvard opened this issue Aug 13, 2021 · 2 comments
Closed

Problems using ecj for modular project #147

hallvard opened this issue Aug 13, 2021 · 2 comments

Comments

@hallvard
Copy link

I have a modular javafx project and would like to use ecj, so I configured it in my pom:

					<artifactId>maven-compiler-plugin</artifactId>
					<version>3.8.1</version>
					<dependencies>
						<dependency>
							<groupId>org.codehaus.plexus</groupId>
							<artifactId>plexus-compiler-eclipse</artifactId>
							<version>2.8.8</version>
						</dependency>
						<dependency>
						    <groupId>org.eclipse.jdt</groupId>
						    <artifactId>ecj</artifactId>
						    <version>3.26.0</version>
						</dependency>
					</dependencies>

I immediately get lots of errors, both concerning missing modules (e.g. cannot find javafx.controls) and types within my own module that cannot be resolved (classes in the same package). When running maven (with javac) and the -X options I see that maven itself seems to be aware of the modules and that the information is passed along to javac:

[DEBUG] Classpath:
[DEBUG]  /Users/hal/java/git/tdt4100-2021/sensur-kont2021/candidates/10001/target/classes
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-fxml/16/javafx-fxml-16.jar
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-controls/16/javafx-controls-16.jar
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-graphics/16/javafx-graphics-16.jar
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-base/16/javafx-base-16.jar
[DEBUG] Modulepath:
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-fxml/16/javafx-fxml-16-mac.jar
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-controls/16/javafx-controls-16-mac.jar
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-graphics/16/javafx-graphics-16-mac.jar
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-base/16/javafx-base-16-mac.jar
[DEBUG] Source roots:
[DEBUG]  /Users/hal/java/git/tdt4100-2021/sensur-kont2021/candidates/10001/src/main/java
[DEBUG]  /Users/hal/java/git/tdt4100-2021/sensur-kont2021/candidates/10001/target/generated-sources/annotations
[DEBUG] Command line options:
[DEBUG] -d /Users/hal/java/git/tdt4100-2021/sensur-kont2021/candidates/10001/target/classes -classpath /Users/hal/java/git/tdt4100-2021/sensur-kont2021/candidates/10001/target/classes:/Users/hal/.m2/repository/org/openjfx/javafx-fxml/16/javafx-fxml-16.jar:/Users/hal/.m2/repository/org/openjfx/javafx-controls/16/javafx-controls-16.jar:/Users/hal/.m2/repository/org/openjfx/javafx-graphics/16/javafx-graphics-16.jar:/Users/hal/.m2/repository/org/openjfx/javafx-base/16/javafx-base-16.jar: --module-path /Users/hal/.m2/repository/org/openjfx/javafx-fxml/16/javafx-fxml-16-mac.jar:/Users/hal/.m2/repository/org/openjfx/javafx-controls/16/javafx-controls-16-mac.jar:/Users/hal/.m2/repository/org/openjfx/javafx-graphics/16/javafx-graphics-16-mac.jar:/Users/hal/.m2/repository/org/openjfx/javafx-base/16/javafx-base-16-mac.jar: -sourcepath /Users/hal/java/git/tdt4100-2021/sensur-kont2021/candidates/10001/src/main/java:/Users/hal/java/git/tdt4100-2021/sensur-kont2021/candidates/10001/target/generated-sources/annotations: -s /Users/hal/java/git/tdt4100-2021/sensur-kont2021/candidates/10001/target/generated-sources/annotations -g -nowarn --release 15 --module-version 0.0.1-SNAPSHOT

Compilation works for javac with these options.

However, the corresponding output for ecj is as follows:

[DEBUG] Classpath:
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-fxml/16/javafx-fxml-16.jar
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-controls/16/javafx-controls-16.jar
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-graphics/16/javafx-graphics-16.jar
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-base/16/javafx-base-16.jar
[DEBUG] Modulepath:
[DEBUG]  /Users/hal/java/git/tdt4100-2021/sensur-kont2021/candidates/10001/target/classes
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-fxml/16/javafx-fxml-16-mac.jar
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-controls/16/javafx-controls-16-mac.jar
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-graphics/16/javafx-graphics-16-mac.jar
[DEBUG]  /Users/hal/.m2/repository/org/openjfx/javafx-base/16/javafx-base-16-mac.jar
[DEBUG] Source roots:
[DEBUG]  /Users/hal/java/git/tdt4100-2021/sensur-kont2021/candidates/10001/src/main/java
[DEBUG]  /Users/hal/java/git/tdt4100-2021/sensur-kont2021/candidates/10001/target/generated-sources/annotations
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[DEBUG] incrementalBuildHelper#beforeRebuildExecution
[DEBUG] Using JSR-199 EclipseCompiler
[DEBUG] ecj: using character set UTF-8
[DEBUG] ecj command line: [-noExit, -preserveAllLocals, -g:lines,vars,source, --release, 15, -warn:none, -properties, /Users/hal/java/git/tdt4100-2021/sensur-kont2021/candidates/10001/../../template/.settings/org.eclipse.jdt.core.prefs, -proceedOnError, -verbose, --module-version, 0.0.1-SNAPSHOT, -d, /Users/hal/java/git/tdt4100-2021/sensur-kont2021/candidates/10001/target/classes, -proceedOnError:Fatal, -classpath, /Users/hal/.m2/repository/org/openjfx/javafx-fxml/16/javafx-fxml-16.jar:/Users/hal/.m2/repository/org/openjfx/javafx-controls/16/javafx-controls-16.jar:/Users/hal/.m2/repository/org/openjfx/javafx-graphics/16/javafx-graphics-16.jar:/Users/hal/.m2/repository/org/openjfx/javafx-base/16/javafx-base-16.jar:/Users/hal/java/git/tdt4100-2021/sensur-kont2021/candidates/10001/target/classes:]

There is no trace of the modules in the command line options. Inspecting the code, this isn't surprising as the code doesn't seem to look for or handle module-path related stuff. I assume the maven's module path information is available, so wonder why it's not used?

@tomaswolf
Copy link
Contributor

tomaswolf commented Nov 13, 2021

so wonder why it's not used?

Probably because nobody implemented it. The info is available. Just adding it would be simple enough, but I don't know enough about module-based builds to know what else might be needed.

Why is .../target/classes shown on the classpath for javac, but in the modulepath for ECJ?

tomaswolf added a commit to tomaswolf/plexus-compiler that referenced this issue Nov 14, 2021
Simply add the path from the CompilerConfiguration to the command-line
arguments.
tomaswolf added a commit to tomaswolf/plexus-compiler that referenced this issue Nov 14, 2021
Simply add the path from the CompilerConfiguration to the command-line
arguments.

Also fix the --processor-module-path argument.
slachiewicz pushed a commit that referenced this issue Nov 21, 2021
Simply add the path from the CompilerConfiguration to the command-line
arguments.

Also fix the --processor-module-path argument.
@slachiewicz
Copy link
Member

should be fixed with 2.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants