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 |
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
);
);
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
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 |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
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