How to create jigsaw module in SBT?
up vote
3
down vote
favorite
I would like to use jlink for creating self-contained application packages for all platforms (darwin, linux, windows) from Scala source code. It seems that jlink only works with new (relatively) jigsaw modules - so I need to package my code as a module. In Java world it seems to be easily achieved by placing special module-info.java file to the package that will become a module.
I tried to follow intuition and just placed this module-info.java into src/main/java/my.package.name/module-info.java. Though this doesn't work. It seems that scalac is trying to read module-info.java as usual Java file (which is not the case), hence the error
module-info.java:1:8: illegal start of type declaration
[error] module my.package.name {
[error] ^
What do I need to do to package my Scala code as a module?
Open JDK: 11
Scala: 2.12.4
SBT: 1.1.6
java scala sbt java-11 module-info
add a comment |
up vote
3
down vote
favorite
I would like to use jlink for creating self-contained application packages for all platforms (darwin, linux, windows) from Scala source code. It seems that jlink only works with new (relatively) jigsaw modules - so I need to package my code as a module. In Java world it seems to be easily achieved by placing special module-info.java file to the package that will become a module.
I tried to follow intuition and just placed this module-info.java into src/main/java/my.package.name/module-info.java. Though this doesn't work. It seems that scalac is trying to read module-info.java as usual Java file (which is not the case), hence the error
module-info.java:1:8: illegal start of type declaration
[error] module my.package.name {
[error] ^
What do I need to do to package my Scala code as a module?
Open JDK: 11
Scala: 2.12.4
SBT: 1.1.6
java scala sbt java-11 module-info
1
If scalac doesn't know anything about modules then you might have to compile the module-info.java separately, with javac -d specifying the output directory where the scalac compiler has emitted the class files for the contents of the module.
– Alan Bateman
Nov 20 at 8:46
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I would like to use jlink for creating self-contained application packages for all platforms (darwin, linux, windows) from Scala source code. It seems that jlink only works with new (relatively) jigsaw modules - so I need to package my code as a module. In Java world it seems to be easily achieved by placing special module-info.java file to the package that will become a module.
I tried to follow intuition and just placed this module-info.java into src/main/java/my.package.name/module-info.java. Though this doesn't work. It seems that scalac is trying to read module-info.java as usual Java file (which is not the case), hence the error
module-info.java:1:8: illegal start of type declaration
[error] module my.package.name {
[error] ^
What do I need to do to package my Scala code as a module?
Open JDK: 11
Scala: 2.12.4
SBT: 1.1.6
java scala sbt java-11 module-info
I would like to use jlink for creating self-contained application packages for all platforms (darwin, linux, windows) from Scala source code. It seems that jlink only works with new (relatively) jigsaw modules - so I need to package my code as a module. In Java world it seems to be easily achieved by placing special module-info.java file to the package that will become a module.
I tried to follow intuition and just placed this module-info.java into src/main/java/my.package.name/module-info.java. Though this doesn't work. It seems that scalac is trying to read module-info.java as usual Java file (which is not the case), hence the error
module-info.java:1:8: illegal start of type declaration
[error] module my.package.name {
[error] ^
What do I need to do to package my Scala code as a module?
Open JDK: 11
Scala: 2.12.4
SBT: 1.1.6
java scala sbt java-11 module-info
java scala sbt java-11 module-info
edited Nov 20 at 2:02
nullpointer
38.4k1073146
38.4k1073146
asked Nov 19 at 22:07
vladimir
84521124
84521124
1
If scalac doesn't know anything about modules then you might have to compile the module-info.java separately, with javac -d specifying the output directory where the scalac compiler has emitted the class files for the contents of the module.
– Alan Bateman
Nov 20 at 8:46
add a comment |
1
If scalac doesn't know anything about modules then you might have to compile the module-info.java separately, with javac -d specifying the output directory where the scalac compiler has emitted the class files for the contents of the module.
– Alan Bateman
Nov 20 at 8:46
1
1
If scalac doesn't know anything about modules then you might have to compile the module-info.java separately, with javac -d specifying the output directory where the scalac compiler has emitted the class files for the contents of the module.
– Alan Bateman
Nov 20 at 8:46
If scalac doesn't know anything about modules then you might have to compile the module-info.java separately, with javac -d specifying the output directory where the scalac compiler has emitted the class files for the contents of the module.
– Alan Bateman
Nov 20 at 8:46
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
In general seems like that scala doesn't completely support Java9+, at least their compatibility notes read so.
As of Scala 2.12.6 and 2.11.12, JDK 9+ support is incomplete. Notably,
scalac will not enforce the restrictions of the Java Platform Module
System, which means that code that typechecks may incur linkage errors
at runtime. Scala 2.13.x will provide rudimentary support for this,
but likely only in nightlies built on Java 11.
You can follow Support features of JDK 9+ and Java 11 testing for further updates.
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',
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%2f53383330%2fhow-to-create-jigsaw-module-in-sbt%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
2
down vote
In general seems like that scala doesn't completely support Java9+, at least their compatibility notes read so.
As of Scala 2.12.6 and 2.11.12, JDK 9+ support is incomplete. Notably,
scalac will not enforce the restrictions of the Java Platform Module
System, which means that code that typechecks may incur linkage errors
at runtime. Scala 2.13.x will provide rudimentary support for this,
but likely only in nightlies built on Java 11.
You can follow Support features of JDK 9+ and Java 11 testing for further updates.
add a comment |
up vote
2
down vote
In general seems like that scala doesn't completely support Java9+, at least their compatibility notes read so.
As of Scala 2.12.6 and 2.11.12, JDK 9+ support is incomplete. Notably,
scalac will not enforce the restrictions of the Java Platform Module
System, which means that code that typechecks may incur linkage errors
at runtime. Scala 2.13.x will provide rudimentary support for this,
but likely only in nightlies built on Java 11.
You can follow Support features of JDK 9+ and Java 11 testing for further updates.
add a comment |
up vote
2
down vote
up vote
2
down vote
In general seems like that scala doesn't completely support Java9+, at least their compatibility notes read so.
As of Scala 2.12.6 and 2.11.12, JDK 9+ support is incomplete. Notably,
scalac will not enforce the restrictions of the Java Platform Module
System, which means that code that typechecks may incur linkage errors
at runtime. Scala 2.13.x will provide rudimentary support for this,
but likely only in nightlies built on Java 11.
You can follow Support features of JDK 9+ and Java 11 testing for further updates.
In general seems like that scala doesn't completely support Java9+, at least their compatibility notes read so.
As of Scala 2.12.6 and 2.11.12, JDK 9+ support is incomplete. Notably,
scalac will not enforce the restrictions of the Java Platform Module
System, which means that code that typechecks may incur linkage errors
at runtime. Scala 2.13.x will provide rudimentary support for this,
but likely only in nightlies built on Java 11.
You can follow Support features of JDK 9+ and Java 11 testing for further updates.
answered Nov 20 at 2:00
nullpointer
38.4k1073146
38.4k1073146
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%2f53383330%2fhow-to-create-jigsaw-module-in-sbt%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
1
If scalac doesn't know anything about modules then you might have to compile the module-info.java separately, with javac -d specifying the output directory where the scalac compiler has emitted the class files for the contents of the module.
– Alan Bateman
Nov 20 at 8:46