Eclipse m2e doesn't support Maven test-jar with JPMS modules










1















I have a project 'java11-core' that generates a test jar artifact to share with project 'java11-app'. These projects build fine with command line Maven, but within Eclipse, the classes shared in the test jar cannot be found.



Version Info:



  • Apache Maven 3.6.0 (command line and Eclipse)

  • Java version: 11.0.1, vendor: Oracle Corporation

  • Eclipse IDE: Version: 2018-09 (4.9.0)

  • M2E Plugin: 1.9.1.20180912-1601

I originally created these to projects as tradition non-JPMS projects. These projects compiled and ran tests normally as expected. After I added module-info.java to both java11-core and java11-app, the Eclipse compiler could not recognize the shared test files from the core project.



Here is a snapshot of the package explorer for an overview of the project structure.



enter image description here



The added java11-app and java11-core module-info contents respectively:



module com.java11.app 

exports com.java11.app;
requires com.java11.core;


module com.java11.core

exports com.java11.core;



As you can see, I do not export the test utilities package from com.java11.core. I do not want to export the test packages because this would make the test classes publicly available. I also do not wish to introduce a new test project, because in real-world scenarios, this is very likely to require cyclic dependencies between test utilities and the projects they assist in testing.



enter image description here



Build errors for in AppTest.java. The failure reported by Eclipse is interesting is that it does not claim it cannot find the CoreTestUtil class, but rather:



The type com.java11.test.core.util.CoreTestUtil is not accessible AppTest.java /java11-app/src/test/java/com/java11/app line 8 Java Problem
CoreTestUtil cannot be resolved AppTest.java /java11-app/src/test/java/com/java11/app line 21 Java Problem


My assumption is that the lack of an export for this package from java11-core and/or the lack of a requires for this package in java11-app make eclipse believe the access is restricted, even though the classes exist in a separate test-jar.



The module path for java11-app shows it includes java11-core as a module, and the Without test code is set to No.



enter image description here



I know I am working with newly release features and suspect that sharing test classes across Eclipse JPMS project is not yet supported. But, I am not sure where to look (Eclipse? M2E plugin) for an update on it being supported. I am also not aware of a work-around that would allow me to be productive while adopting JPMS for my software projects.



For those that believe test utilities should not be shared this way...



This subject has been characterized as a best-practice issue that should be resolved by refactoring test utilities into a separate module. I respect this perspective, but in attempting to follow that guidance, I found myself being forced to violate other best-practices, including DRY (Don't Repeat Yourself), and cyclic dependencies between packages.



It is common for a test utility to emerge while developing a module that both assists in effective testing of that module, as well as depends on that module. This creates a cycle if those utilities are pulled out to separate module. Furthermore, some of these utilities can be equally useful when testing other modules that depend upon that module. This creates duplicate code if those utilities are copied to a new test module for dependents. This reasoning may have been why Maven 'test-jar' support was originally added.










share|improve this question
























  • Can you please add the full error message output ...

    – khmarbaise
    Nov 15 '18 at 11:41











  • I added the complete error messages available from Eclipse to the summary. I also added the source file that is failing to build. These are the full messages from the Eclipse Problems view. No additional log entries were available under the m2e plugin log, nor under the Eclipse workspace log.

    – NaderNader
    Nov 15 '18 at 18:10















1















I have a project 'java11-core' that generates a test jar artifact to share with project 'java11-app'. These projects build fine with command line Maven, but within Eclipse, the classes shared in the test jar cannot be found.



Version Info:



  • Apache Maven 3.6.0 (command line and Eclipse)

  • Java version: 11.0.1, vendor: Oracle Corporation

  • Eclipse IDE: Version: 2018-09 (4.9.0)

  • M2E Plugin: 1.9.1.20180912-1601

I originally created these to projects as tradition non-JPMS projects. These projects compiled and ran tests normally as expected. After I added module-info.java to both java11-core and java11-app, the Eclipse compiler could not recognize the shared test files from the core project.



Here is a snapshot of the package explorer for an overview of the project structure.



enter image description here



The added java11-app and java11-core module-info contents respectively:



module com.java11.app 

exports com.java11.app;
requires com.java11.core;


module com.java11.core

exports com.java11.core;



As you can see, I do not export the test utilities package from com.java11.core. I do not want to export the test packages because this would make the test classes publicly available. I also do not wish to introduce a new test project, because in real-world scenarios, this is very likely to require cyclic dependencies between test utilities and the projects they assist in testing.



enter image description here



Build errors for in AppTest.java. The failure reported by Eclipse is interesting is that it does not claim it cannot find the CoreTestUtil class, but rather:



The type com.java11.test.core.util.CoreTestUtil is not accessible AppTest.java /java11-app/src/test/java/com/java11/app line 8 Java Problem
CoreTestUtil cannot be resolved AppTest.java /java11-app/src/test/java/com/java11/app line 21 Java Problem


My assumption is that the lack of an export for this package from java11-core and/or the lack of a requires for this package in java11-app make eclipse believe the access is restricted, even though the classes exist in a separate test-jar.



The module path for java11-app shows it includes java11-core as a module, and the Without test code is set to No.



enter image description here



I know I am working with newly release features and suspect that sharing test classes across Eclipse JPMS project is not yet supported. But, I am not sure where to look (Eclipse? M2E plugin) for an update on it being supported. I am also not aware of a work-around that would allow me to be productive while adopting JPMS for my software projects.



For those that believe test utilities should not be shared this way...



This subject has been characterized as a best-practice issue that should be resolved by refactoring test utilities into a separate module. I respect this perspective, but in attempting to follow that guidance, I found myself being forced to violate other best-practices, including DRY (Don't Repeat Yourself), and cyclic dependencies between packages.



It is common for a test utility to emerge while developing a module that both assists in effective testing of that module, as well as depends on that module. This creates a cycle if those utilities are pulled out to separate module. Furthermore, some of these utilities can be equally useful when testing other modules that depend upon that module. This creates duplicate code if those utilities are copied to a new test module for dependents. This reasoning may have been why Maven 'test-jar' support was originally added.










share|improve this question
























  • Can you please add the full error message output ...

    – khmarbaise
    Nov 15 '18 at 11:41











  • I added the complete error messages available from Eclipse to the summary. I also added the source file that is failing to build. These are the full messages from the Eclipse Problems view. No additional log entries were available under the m2e plugin log, nor under the Eclipse workspace log.

    – NaderNader
    Nov 15 '18 at 18:10













1












1








1








I have a project 'java11-core' that generates a test jar artifact to share with project 'java11-app'. These projects build fine with command line Maven, but within Eclipse, the classes shared in the test jar cannot be found.



Version Info:



  • Apache Maven 3.6.0 (command line and Eclipse)

  • Java version: 11.0.1, vendor: Oracle Corporation

  • Eclipse IDE: Version: 2018-09 (4.9.0)

  • M2E Plugin: 1.9.1.20180912-1601

I originally created these to projects as tradition non-JPMS projects. These projects compiled and ran tests normally as expected. After I added module-info.java to both java11-core and java11-app, the Eclipse compiler could not recognize the shared test files from the core project.



Here is a snapshot of the package explorer for an overview of the project structure.



enter image description here



The added java11-app and java11-core module-info contents respectively:



module com.java11.app 

exports com.java11.app;
requires com.java11.core;


module com.java11.core

exports com.java11.core;



As you can see, I do not export the test utilities package from com.java11.core. I do not want to export the test packages because this would make the test classes publicly available. I also do not wish to introduce a new test project, because in real-world scenarios, this is very likely to require cyclic dependencies between test utilities and the projects they assist in testing.



enter image description here



Build errors for in AppTest.java. The failure reported by Eclipse is interesting is that it does not claim it cannot find the CoreTestUtil class, but rather:



The type com.java11.test.core.util.CoreTestUtil is not accessible AppTest.java /java11-app/src/test/java/com/java11/app line 8 Java Problem
CoreTestUtil cannot be resolved AppTest.java /java11-app/src/test/java/com/java11/app line 21 Java Problem


My assumption is that the lack of an export for this package from java11-core and/or the lack of a requires for this package in java11-app make eclipse believe the access is restricted, even though the classes exist in a separate test-jar.



The module path for java11-app shows it includes java11-core as a module, and the Without test code is set to No.



enter image description here



I know I am working with newly release features and suspect that sharing test classes across Eclipse JPMS project is not yet supported. But, I am not sure where to look (Eclipse? M2E plugin) for an update on it being supported. I am also not aware of a work-around that would allow me to be productive while adopting JPMS for my software projects.



For those that believe test utilities should not be shared this way...



This subject has been characterized as a best-practice issue that should be resolved by refactoring test utilities into a separate module. I respect this perspective, but in attempting to follow that guidance, I found myself being forced to violate other best-practices, including DRY (Don't Repeat Yourself), and cyclic dependencies between packages.



It is common for a test utility to emerge while developing a module that both assists in effective testing of that module, as well as depends on that module. This creates a cycle if those utilities are pulled out to separate module. Furthermore, some of these utilities can be equally useful when testing other modules that depend upon that module. This creates duplicate code if those utilities are copied to a new test module for dependents. This reasoning may have been why Maven 'test-jar' support was originally added.










share|improve this question
















I have a project 'java11-core' that generates a test jar artifact to share with project 'java11-app'. These projects build fine with command line Maven, but within Eclipse, the classes shared in the test jar cannot be found.



Version Info:



  • Apache Maven 3.6.0 (command line and Eclipse)

  • Java version: 11.0.1, vendor: Oracle Corporation

  • Eclipse IDE: Version: 2018-09 (4.9.0)

  • M2E Plugin: 1.9.1.20180912-1601

I originally created these to projects as tradition non-JPMS projects. These projects compiled and ran tests normally as expected. After I added module-info.java to both java11-core and java11-app, the Eclipse compiler could not recognize the shared test files from the core project.



Here is a snapshot of the package explorer for an overview of the project structure.



enter image description here



The added java11-app and java11-core module-info contents respectively:



module com.java11.app 

exports com.java11.app;
requires com.java11.core;


module com.java11.core

exports com.java11.core;



As you can see, I do not export the test utilities package from com.java11.core. I do not want to export the test packages because this would make the test classes publicly available. I also do not wish to introduce a new test project, because in real-world scenarios, this is very likely to require cyclic dependencies between test utilities and the projects they assist in testing.



enter image description here



Build errors for in AppTest.java. The failure reported by Eclipse is interesting is that it does not claim it cannot find the CoreTestUtil class, but rather:



The type com.java11.test.core.util.CoreTestUtil is not accessible AppTest.java /java11-app/src/test/java/com/java11/app line 8 Java Problem
CoreTestUtil cannot be resolved AppTest.java /java11-app/src/test/java/com/java11/app line 21 Java Problem


My assumption is that the lack of an export for this package from java11-core and/or the lack of a requires for this package in java11-app make eclipse believe the access is restricted, even though the classes exist in a separate test-jar.



The module path for java11-app shows it includes java11-core as a module, and the Without test code is set to No.



enter image description here



I know I am working with newly release features and suspect that sharing test classes across Eclipse JPMS project is not yet supported. But, I am not sure where to look (Eclipse? M2E plugin) for an update on it being supported. I am also not aware of a work-around that would allow me to be productive while adopting JPMS for my software projects.



For those that believe test utilities should not be shared this way...



This subject has been characterized as a best-practice issue that should be resolved by refactoring test utilities into a separate module. I respect this perspective, but in attempting to follow that guidance, I found myself being forced to violate other best-practices, including DRY (Don't Repeat Yourself), and cyclic dependencies between packages.



It is common for a test utility to emerge while developing a module that both assists in effective testing of that module, as well as depends on that module. This creates a cycle if those utilities are pulled out to separate module. Furthermore, some of these utilities can be equally useful when testing other modules that depend upon that module. This creates duplicate code if those utilities are copied to a new test module for dependents. This reasoning may have been why Maven 'test-jar' support was originally added.







java eclipse maven m2e module-info






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 18:07







NaderNader

















asked Nov 14 '18 at 21:24









NaderNaderNaderNader

9626




9626












  • Can you please add the full error message output ...

    – khmarbaise
    Nov 15 '18 at 11:41











  • I added the complete error messages available from Eclipse to the summary. I also added the source file that is failing to build. These are the full messages from the Eclipse Problems view. No additional log entries were available under the m2e plugin log, nor under the Eclipse workspace log.

    – NaderNader
    Nov 15 '18 at 18:10

















  • Can you please add the full error message output ...

    – khmarbaise
    Nov 15 '18 at 11:41











  • I added the complete error messages available from Eclipse to the summary. I also added the source file that is failing to build. These are the full messages from the Eclipse Problems view. No additional log entries were available under the m2e plugin log, nor under the Eclipse workspace log.

    – NaderNader
    Nov 15 '18 at 18:10
















Can you please add the full error message output ...

– khmarbaise
Nov 15 '18 at 11:41





Can you please add the full error message output ...

– khmarbaise
Nov 15 '18 at 11:41













I added the complete error messages available from Eclipse to the summary. I also added the source file that is failing to build. These are the full messages from the Eclipse Problems view. No additional log entries were available under the m2e plugin log, nor under the Eclipse workspace log.

– NaderNader
Nov 15 '18 at 18:10





I added the complete error messages available from Eclipse to the summary. I also added the source file that is failing to build. These are the full messages from the Eclipse Problems view. No additional log entries were available under the m2e plugin log, nor under the Eclipse workspace log.

– NaderNader
Nov 15 '18 at 18:10












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308935%2feclipse-m2e-doesnt-support-maven-test-jar-with-jpms-modules%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308935%2feclipse-m2e-doesnt-support-maven-test-jar-with-jpms-modules%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto