apache / apache/maven-jmod-plugin

[MJMOD-25] Multimodule project test problems with JPMS

Open
#70 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
16
Forks
11
Avg merge
7h 10m
Merged PRs (30d)
1

Description

**[Timo Heinonen](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=_zap_)** opened **[MJMOD-25](https://issues.apache.org/jira/browse/MJMOD-25?redirect=false)** and commented

I'm using multimodule maven project with JPMS and can't get all tests to work, because classes are not found. It's possible to run all tests successfully using java 8 and classpath, but with modulepath classes from module A's test sources can not access classes from module B's test sources. 

Project structure:
*  Module A
* src/main/java
*** Packages
**** a.foo
*** module-info.java (name: a, exports a.foo)
* src/test/java
*** Packages
**** a.foo (includes tests for a.foo)
**** a.bar (includes helper classes needed by module B's integration tests)
*** module-info.java (name: a, exports a.bar)
* Module B
* src/main/java
*** Packages
**** b.foo
*** module-info.java (name: b, requires a)
* src/test/java
*** Packages
**** b.foo (includes tests for b.foo)
**** b.bar (includes integration tests that require access to module A's a.bar-package)
*** module-info.java (name: b, requires a)

I have added additional module-info.java for test sources in both modules because a.bar and b.bar are additional packages that need to be exported (https://issues.apache.org/jira/browse/MCOMPILER-341). Basically tests in package b.bar depend on classes in a.bar and therefore module A's test classes should be available when running module B's tests. However, when tests are run from module B, modulepath contains two jars from module A: module compiled from sources and module compiled from test sources. Both modules have same module name and classes required by B's tests are not found. 

I guess I could get all tests to work by moving all integraton tests from module B to separate test module, but I wouldn't like to do that because my project already has quite many modules. Also, I moved all classes from a.bar to a.test.bar package and renamed module created from module A's sources to a.test so that I could define requires directly to a.test in module B's test module. This fixed integration tests in module B, but broke unit tests in module A, because modules generated from module A (normal & test module) are not patched together anymore. 

---

**Affects:** 3.0.0-alpha-1

**Attachments:**
- [mcompiler-364-test-case.zip](https://issues.apache.org/jira/secure/attachment/12952411/mcompiler-364-test-case.zip) (_13.08 kB_)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by examining the attached mcompiler-364-test-case.zip and its multimodule JPMS test setup. Reproduce the modulepath failure described for Module B's integration tests, then verify that test classes from Module A are resolved correctly without breaking Module A's unit tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.