JDK9 Automatic Modules and “Split Packages” Dependencies
up vote
0
down vote
favorite
I am converting a java project to use modules. One of my modules depends on hamcrest
library, and it needs both of the jar files hamcrest.core
and hamcrest.library
. These two jar files both have org.hamcrest
package. So when my module wants to treat these two jars as automatic modules, it fails because two modules in a module-path cannot have packages with same name. I searched a lot and found some related stuff on stackoverflow. It seems that I have two reasonable options if I do not want to rebuild those dependencies:
- Merge the two jars into one jar using my build automation tool (which is maven).
- Somehow tell java compiler that these two jars should be treated as a single automatic module.
So here are my questions:
- Is any of these two options possible? If yes, how?
- Is there any better option?
Thanks in advance
java maven java-9 hamcrest java-module
add a comment |
up vote
0
down vote
favorite
I am converting a java project to use modules. One of my modules depends on hamcrest
library, and it needs both of the jar files hamcrest.core
and hamcrest.library
. These two jar files both have org.hamcrest
package. So when my module wants to treat these two jars as automatic modules, it fails because two modules in a module-path cannot have packages with same name. I searched a lot and found some related stuff on stackoverflow. It seems that I have two reasonable options if I do not want to rebuild those dependencies:
- Merge the two jars into one jar using my build automation tool (which is maven).
- Somehow tell java compiler that these two jars should be treated as a single automatic module.
So here are my questions:
- Is any of these two options possible? If yes, how?
- Is there any better option?
Thanks in advance
java maven java-9 hamcrest java-module
3
The cleanest of all solutions would be to report and get it fixed in the library itself. Some links/reports useful in such cases -github.com/hamcrest/JavaHamcrest/issues/187, github.com/hamcrest/JavaHamcrest/issues/205
– nullpointer
Nov 11 at 5:18
That's right for sure but I am in hurry :)
– Feri
Nov 11 at 16:52
Did you try to let those jars remain on the classpath instead of modulepath to result into an unnamed module? Not sure though that would be something you're looking for.
– nullpointer
Nov 11 at 17:07
Unfortunately explicit module cannot read classpath. It says if the explicit module is treatd as unnamed module "TEMPORARILY", that would work but I've no idea what this even means!
– Feri
Nov 11 at 18:34
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am converting a java project to use modules. One of my modules depends on hamcrest
library, and it needs both of the jar files hamcrest.core
and hamcrest.library
. These two jar files both have org.hamcrest
package. So when my module wants to treat these two jars as automatic modules, it fails because two modules in a module-path cannot have packages with same name. I searched a lot and found some related stuff on stackoverflow. It seems that I have two reasonable options if I do not want to rebuild those dependencies:
- Merge the two jars into one jar using my build automation tool (which is maven).
- Somehow tell java compiler that these two jars should be treated as a single automatic module.
So here are my questions:
- Is any of these two options possible? If yes, how?
- Is there any better option?
Thanks in advance
java maven java-9 hamcrest java-module
I am converting a java project to use modules. One of my modules depends on hamcrest
library, and it needs both of the jar files hamcrest.core
and hamcrest.library
. These two jar files both have org.hamcrest
package. So when my module wants to treat these two jars as automatic modules, it fails because two modules in a module-path cannot have packages with same name. I searched a lot and found some related stuff on stackoverflow. It seems that I have two reasonable options if I do not want to rebuild those dependencies:
- Merge the two jars into one jar using my build automation tool (which is maven).
- Somehow tell java compiler that these two jars should be treated as a single automatic module.
So here are my questions:
- Is any of these two options possible? If yes, how?
- Is there any better option?
Thanks in advance
java maven java-9 hamcrest java-module
java maven java-9 hamcrest java-module
asked Nov 11 at 3:37
Feri
110110
110110
3
The cleanest of all solutions would be to report and get it fixed in the library itself. Some links/reports useful in such cases -github.com/hamcrest/JavaHamcrest/issues/187, github.com/hamcrest/JavaHamcrest/issues/205
– nullpointer
Nov 11 at 5:18
That's right for sure but I am in hurry :)
– Feri
Nov 11 at 16:52
Did you try to let those jars remain on the classpath instead of modulepath to result into an unnamed module? Not sure though that would be something you're looking for.
– nullpointer
Nov 11 at 17:07
Unfortunately explicit module cannot read classpath. It says if the explicit module is treatd as unnamed module "TEMPORARILY", that would work but I've no idea what this even means!
– Feri
Nov 11 at 18:34
add a comment |
3
The cleanest of all solutions would be to report and get it fixed in the library itself. Some links/reports useful in such cases -github.com/hamcrest/JavaHamcrest/issues/187, github.com/hamcrest/JavaHamcrest/issues/205
– nullpointer
Nov 11 at 5:18
That's right for sure but I am in hurry :)
– Feri
Nov 11 at 16:52
Did you try to let those jars remain on the classpath instead of modulepath to result into an unnamed module? Not sure though that would be something you're looking for.
– nullpointer
Nov 11 at 17:07
Unfortunately explicit module cannot read classpath. It says if the explicit module is treatd as unnamed module "TEMPORARILY", that would work but I've no idea what this even means!
– Feri
Nov 11 at 18:34
3
3
The cleanest of all solutions would be to report and get it fixed in the library itself. Some links/reports useful in such cases -github.com/hamcrest/JavaHamcrest/issues/187, github.com/hamcrest/JavaHamcrest/issues/205
– nullpointer
Nov 11 at 5:18
The cleanest of all solutions would be to report and get it fixed in the library itself. Some links/reports useful in such cases -github.com/hamcrest/JavaHamcrest/issues/187, github.com/hamcrest/JavaHamcrest/issues/205
– nullpointer
Nov 11 at 5:18
That's right for sure but I am in hurry :)
– Feri
Nov 11 at 16:52
That's right for sure but I am in hurry :)
– Feri
Nov 11 at 16:52
Did you try to let those jars remain on the classpath instead of modulepath to result into an unnamed module? Not sure though that would be something you're looking for.
– nullpointer
Nov 11 at 17:07
Did you try to let those jars remain on the classpath instead of modulepath to result into an unnamed module? Not sure though that would be something you're looking for.
– nullpointer
Nov 11 at 17:07
Unfortunately explicit module cannot read classpath. It says if the explicit module is treatd as unnamed module "TEMPORARILY", that would work but I've no idea what this even means!
– Feri
Nov 11 at 18:34
Unfortunately explicit module cannot read classpath. It says if the explicit module is treatd as unnamed module "TEMPORARILY", that would work but I've no idea what this even means!
– Feri
Nov 11 at 18:34
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Ok I finally managed to solve it like this:
- Create a new maven module called
hamcrest-all
and add dependencies onhamcrest-core
andhamcrest-library
. - add
maven-assembly-plugin
to this module withappendAssemblyId
set to false. - remove the dependency to
hamcrest-core
andhamcrest-library
from other maven modules and instead add dependency tohamcrest-all
. - exclude
hamcrest-core
andhamcrest-library
when including dependency tohamcrest-all
.
What it actually does is that it unpacks hamcrest-core
and hamcrest-library
in the jar file created for hamrest-all
. And because each jar file is treated as one module by JMPS, the problem is gone :)
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Ok I finally managed to solve it like this:
- Create a new maven module called
hamcrest-all
and add dependencies onhamcrest-core
andhamcrest-library
. - add
maven-assembly-plugin
to this module withappendAssemblyId
set to false. - remove the dependency to
hamcrest-core
andhamcrest-library
from other maven modules and instead add dependency tohamcrest-all
. - exclude
hamcrest-core
andhamcrest-library
when including dependency tohamcrest-all
.
What it actually does is that it unpacks hamcrest-core
and hamcrest-library
in the jar file created for hamrest-all
. And because each jar file is treated as one module by JMPS, the problem is gone :)
add a comment |
up vote
0
down vote
accepted
Ok I finally managed to solve it like this:
- Create a new maven module called
hamcrest-all
and add dependencies onhamcrest-core
andhamcrest-library
. - add
maven-assembly-plugin
to this module withappendAssemblyId
set to false. - remove the dependency to
hamcrest-core
andhamcrest-library
from other maven modules and instead add dependency tohamcrest-all
. - exclude
hamcrest-core
andhamcrest-library
when including dependency tohamcrest-all
.
What it actually does is that it unpacks hamcrest-core
and hamcrest-library
in the jar file created for hamrest-all
. And because each jar file is treated as one module by JMPS, the problem is gone :)
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Ok I finally managed to solve it like this:
- Create a new maven module called
hamcrest-all
and add dependencies onhamcrest-core
andhamcrest-library
. - add
maven-assembly-plugin
to this module withappendAssemblyId
set to false. - remove the dependency to
hamcrest-core
andhamcrest-library
from other maven modules and instead add dependency tohamcrest-all
. - exclude
hamcrest-core
andhamcrest-library
when including dependency tohamcrest-all
.
What it actually does is that it unpacks hamcrest-core
and hamcrest-library
in the jar file created for hamrest-all
. And because each jar file is treated as one module by JMPS, the problem is gone :)
Ok I finally managed to solve it like this:
- Create a new maven module called
hamcrest-all
and add dependencies onhamcrest-core
andhamcrest-library
. - add
maven-assembly-plugin
to this module withappendAssemblyId
set to false. - remove the dependency to
hamcrest-core
andhamcrest-library
from other maven modules and instead add dependency tohamcrest-all
. - exclude
hamcrest-core
andhamcrest-library
when including dependency tohamcrest-all
.
What it actually does is that it unpacks hamcrest-core
and hamcrest-library
in the jar file created for hamrest-all
. And because each jar file is treated as one module by JMPS, the problem is gone :)
answered Nov 15 at 23:27
Feri
110110
110110
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245628%2fjdk9-automatic-modules-and-split-packages-dependencies%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
3
The cleanest of all solutions would be to report and get it fixed in the library itself. Some links/reports useful in such cases -github.com/hamcrest/JavaHamcrest/issues/187, github.com/hamcrest/JavaHamcrest/issues/205
– nullpointer
Nov 11 at 5:18
That's right for sure but I am in hurry :)
– Feri
Nov 11 at 16:52
Did you try to let those jars remain on the classpath instead of modulepath to result into an unnamed module? Not sure though that would be something you're looking for.
– nullpointer
Nov 11 at 17:07
Unfortunately explicit module cannot read classpath. It says if the explicit module is treatd as unnamed module "TEMPORARILY", that would work but I've no idea what this even means!
– Feri
Nov 11 at 18:34