Skip to content

Problems using ecj for modular project #147

Closed
@hallvard

Description

@hallvard

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions