-
Notifications
You must be signed in to change notification settings - Fork 414
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
Handle module projects with separate module-info.java for main and test sources #2116
Comments
Related issue - #2090 (comment) |
This is the core issue to look into: eclipse-m2e/m2e-core#173 |
The problem is that there is no standard way at the JEP level to tell the tooling how to handle test sources. Each tool has to tweak it in their own way. The upstream JDT issues https://bugs.eclipse.org/bugs/show_bug.cgi?id=520667 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=559601 are still under discussion, waiting for a spec or standard to deal with it. @brunoborges There is a workaround to unlock your use of VS Code for <profiles>
<profile>
<id>m2e</id>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler-plugin.version}</version>
<configuration>
<compilerArgs>
<arg>--module-version=${project.version}</arg>
<arg>-Xlint:unchecked</arg>
</compilerArgs>
<testExcludes>
<testExclude>**/module-info.java</testExclude>
</testExcludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles> This can bypass the duplicate module-info.java check, and the Java tooling will use the classpath way to handle test files. This profile only takes effect in VS Code environment, and not affect your maven command line. If you want, i can submit a PR in gctoolkit project. |
Thanks @testforstephen I'll give it a try! |
the profiles will be inherited by submodules (yeah Maven) |
I have the same issue with gradle. :( |
The workaournd allows to operate VSCode, but it is not possible to run tests from VSCode directly - in case there are some test dependencies etc PS. It is not a technical argument, but maybe a product argument: |
Any updates on this? This is was is keeping me from using VSCode for my java courses (I am a teacher). |
Here is a Java 11 maven module project: https://github.com/microsoft/gctoolkit. The project is a multi-module maven project. One submodule is "api", see its file structure as follows. It describes the module-info.java file in the main sources and the test sources respectively.
However, when opening this project in VS Code, it doesn't work. It reports a compile error: "The project was not built due to "Build path contains duplicate entry: 'module-info.java' for project 'api'". Fix the problem, then try refreshing this project and building it since it may be inconsistent". It doesn't support multiple module-info.java files in one Java project.
The same project works in maven command line. There should be some gap in the JDT compiler that needs to be fixed.
The text was updated successfully, but these errors were encountered: