Source files in src_managed are not part of project sources in SBT
I'm not very skilled in SBT, may be i'm missing smth
I have bash script that generates some scala sources. I want to use them in my sbt project. I thought that putting them under target/src_managed/main directory would work, but it doesn't
In sbt shell i type sourceDirectories
sbt:root> model/sourceDirectories
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala-2.12
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala
[info] * /media/alex/kondaurov_hd/back/model/src/main/java
[info] * /media/alex/kondaurov_hd/back/model/target/scala-2.12/src_managed/main
src_managed should be available, no?
sbt:root> show model/sources
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala/model/ModelUtils.scala
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala/model/implicits/Response.scala
[success] Total time: 1 s, completed Nov 25, 2018 1:44:02 PM
I don't seed sources under src_managed directory.
scala sbt
add a comment |
I'm not very skilled in SBT, may be i'm missing smth
I have bash script that generates some scala sources. I want to use them in my sbt project. I thought that putting them under target/src_managed/main directory would work, but it doesn't
In sbt shell i type sourceDirectories
sbt:root> model/sourceDirectories
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala-2.12
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala
[info] * /media/alex/kondaurov_hd/back/model/src/main/java
[info] * /media/alex/kondaurov_hd/back/model/target/scala-2.12/src_managed/main
src_managed should be available, no?
sbt:root> show model/sources
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala/model/ModelUtils.scala
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala/model/implicits/Response.scala
[success] Total time: 1 s, completed Nov 25, 2018 1:44:02 PM
I don't seed sources under src_managed directory.
scala sbt
add a comment |
I'm not very skilled in SBT, may be i'm missing smth
I have bash script that generates some scala sources. I want to use them in my sbt project. I thought that putting them under target/src_managed/main directory would work, but it doesn't
In sbt shell i type sourceDirectories
sbt:root> model/sourceDirectories
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala-2.12
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala
[info] * /media/alex/kondaurov_hd/back/model/src/main/java
[info] * /media/alex/kondaurov_hd/back/model/target/scala-2.12/src_managed/main
src_managed should be available, no?
sbt:root> show model/sources
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala/model/ModelUtils.scala
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala/model/implicits/Response.scala
[success] Total time: 1 s, completed Nov 25, 2018 1:44:02 PM
I don't seed sources under src_managed directory.
scala sbt
I'm not very skilled in SBT, may be i'm missing smth
I have bash script that generates some scala sources. I want to use them in my sbt project. I thought that putting them under target/src_managed/main directory would work, but it doesn't
In sbt shell i type sourceDirectories
sbt:root> model/sourceDirectories
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala-2.12
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala
[info] * /media/alex/kondaurov_hd/back/model/src/main/java
[info] * /media/alex/kondaurov_hd/back/model/target/scala-2.12/src_managed/main
src_managed should be available, no?
sbt:root> show model/sources
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala/model/ModelUtils.scala
[info] * /media/alex/kondaurov_hd/back/model/src/main/scala/model/implicits/Response.scala
[success] Total time: 1 s, completed Nov 25, 2018 1:44:02 PM
I don't seed sources under src_managed directory.
scala sbt
scala sbt
asked Nov 25 '18 at 11:01
Alexander KondaurovAlexander Kondaurov
57611132
57611132
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
"I thought that putting them under target/src_managed/main directory would work, but it doesn't".
Well, it does not work, because as the name says, they are sources managed by SBT - that means SBT must know about them and be in the capacity of generate them.
Thus, you have two options:
Make them unmanaged sources
That basically means make your script to create the sources insrc/main/scala/some/package/GeneratedFile.scala- this is the simplest solution, but it has its owns problems.
- The generated files become part of the code repository - but since they are generated they aren't intended to be modified perse.
- You need to ensure that before each package/release/deploy the script is run.
Configure SBT to create the managed sources from your script
You can have a look at the sbt documentation about source generators - and the documentation about running external processes for help for running the bash script inside SBT.
You basically have to create an SBT task that creates the files - this may be more difficult at the beginning but it has the advantage that sbt will take care of generating the sources every time they are needed.
You may find this simple demo I made a few months ago as a reference for creating your own generator - the import code is in thebuild.sbtfile.
For a more production ready version of the generator, including appropriate location, dependency segregation and testing you may take a look at this.
I was thinking about option #2. The idea is to write a source generator that just reads files that were generated by external bash script (like a proxy). Thanks for help!
– Alexander Kondaurov
Nov 25 '18 at 18:49
Yeah that can work, the ideal scenario is that the generator calls the bash script to generate the files, and then return the list of generated files to be managed.
– Luis Miguel Mejía Suárez
Nov 25 '18 at 18:53
add a comment |
I think i found answer, now it works:
unmanagedSourceDirectories in Compile += baseDirectory.value.getParentFile.getParentFile / "protos" / "generated" / "scala"
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%2f53466799%2fsource-files-in-src-managed-are-not-part-of-project-sources-in-sbt%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
"I thought that putting them under target/src_managed/main directory would work, but it doesn't".
Well, it does not work, because as the name says, they are sources managed by SBT - that means SBT must know about them and be in the capacity of generate them.
Thus, you have two options:
Make them unmanaged sources
That basically means make your script to create the sources insrc/main/scala/some/package/GeneratedFile.scala- this is the simplest solution, but it has its owns problems.
- The generated files become part of the code repository - but since they are generated they aren't intended to be modified perse.
- You need to ensure that before each package/release/deploy the script is run.
Configure SBT to create the managed sources from your script
You can have a look at the sbt documentation about source generators - and the documentation about running external processes for help for running the bash script inside SBT.
You basically have to create an SBT task that creates the files - this may be more difficult at the beginning but it has the advantage that sbt will take care of generating the sources every time they are needed.
You may find this simple demo I made a few months ago as a reference for creating your own generator - the import code is in thebuild.sbtfile.
For a more production ready version of the generator, including appropriate location, dependency segregation and testing you may take a look at this.
I was thinking about option #2. The idea is to write a source generator that just reads files that were generated by external bash script (like a proxy). Thanks for help!
– Alexander Kondaurov
Nov 25 '18 at 18:49
Yeah that can work, the ideal scenario is that the generator calls the bash script to generate the files, and then return the list of generated files to be managed.
– Luis Miguel Mejía Suárez
Nov 25 '18 at 18:53
add a comment |
"I thought that putting them under target/src_managed/main directory would work, but it doesn't".
Well, it does not work, because as the name says, they are sources managed by SBT - that means SBT must know about them and be in the capacity of generate them.
Thus, you have two options:
Make them unmanaged sources
That basically means make your script to create the sources insrc/main/scala/some/package/GeneratedFile.scala- this is the simplest solution, but it has its owns problems.
- The generated files become part of the code repository - but since they are generated they aren't intended to be modified perse.
- You need to ensure that before each package/release/deploy the script is run.
Configure SBT to create the managed sources from your script
You can have a look at the sbt documentation about source generators - and the documentation about running external processes for help for running the bash script inside SBT.
You basically have to create an SBT task that creates the files - this may be more difficult at the beginning but it has the advantage that sbt will take care of generating the sources every time they are needed.
You may find this simple demo I made a few months ago as a reference for creating your own generator - the import code is in thebuild.sbtfile.
For a more production ready version of the generator, including appropriate location, dependency segregation and testing you may take a look at this.
I was thinking about option #2. The idea is to write a source generator that just reads files that were generated by external bash script (like a proxy). Thanks for help!
– Alexander Kondaurov
Nov 25 '18 at 18:49
Yeah that can work, the ideal scenario is that the generator calls the bash script to generate the files, and then return the list of generated files to be managed.
– Luis Miguel Mejía Suárez
Nov 25 '18 at 18:53
add a comment |
"I thought that putting them under target/src_managed/main directory would work, but it doesn't".
Well, it does not work, because as the name says, they are sources managed by SBT - that means SBT must know about them and be in the capacity of generate them.
Thus, you have two options:
Make them unmanaged sources
That basically means make your script to create the sources insrc/main/scala/some/package/GeneratedFile.scala- this is the simplest solution, but it has its owns problems.
- The generated files become part of the code repository - but since they are generated they aren't intended to be modified perse.
- You need to ensure that before each package/release/deploy the script is run.
Configure SBT to create the managed sources from your script
You can have a look at the sbt documentation about source generators - and the documentation about running external processes for help for running the bash script inside SBT.
You basically have to create an SBT task that creates the files - this may be more difficult at the beginning but it has the advantage that sbt will take care of generating the sources every time they are needed.
You may find this simple demo I made a few months ago as a reference for creating your own generator - the import code is in thebuild.sbtfile.
For a more production ready version of the generator, including appropriate location, dependency segregation and testing you may take a look at this.
"I thought that putting them under target/src_managed/main directory would work, but it doesn't".
Well, it does not work, because as the name says, they are sources managed by SBT - that means SBT must know about them and be in the capacity of generate them.
Thus, you have two options:
Make them unmanaged sources
That basically means make your script to create the sources insrc/main/scala/some/package/GeneratedFile.scala- this is the simplest solution, but it has its owns problems.
- The generated files become part of the code repository - but since they are generated they aren't intended to be modified perse.
- You need to ensure that before each package/release/deploy the script is run.
Configure SBT to create the managed sources from your script
You can have a look at the sbt documentation about source generators - and the documentation about running external processes for help for running the bash script inside SBT.
You basically have to create an SBT task that creates the files - this may be more difficult at the beginning but it has the advantage that sbt will take care of generating the sources every time they are needed.
You may find this simple demo I made a few months ago as a reference for creating your own generator - the import code is in thebuild.sbtfile.
For a more production ready version of the generator, including appropriate location, dependency segregation and testing you may take a look at this.
answered Nov 25 '18 at 14:11
Luis Miguel Mejía SuárezLuis Miguel Mejía Suárez
2,6741822
2,6741822
I was thinking about option #2. The idea is to write a source generator that just reads files that were generated by external bash script (like a proxy). Thanks for help!
– Alexander Kondaurov
Nov 25 '18 at 18:49
Yeah that can work, the ideal scenario is that the generator calls the bash script to generate the files, and then return the list of generated files to be managed.
– Luis Miguel Mejía Suárez
Nov 25 '18 at 18:53
add a comment |
I was thinking about option #2. The idea is to write a source generator that just reads files that were generated by external bash script (like a proxy). Thanks for help!
– Alexander Kondaurov
Nov 25 '18 at 18:49
Yeah that can work, the ideal scenario is that the generator calls the bash script to generate the files, and then return the list of generated files to be managed.
– Luis Miguel Mejía Suárez
Nov 25 '18 at 18:53
I was thinking about option #2. The idea is to write a source generator that just reads files that were generated by external bash script (like a proxy). Thanks for help!
– Alexander Kondaurov
Nov 25 '18 at 18:49
I was thinking about option #2. The idea is to write a source generator that just reads files that were generated by external bash script (like a proxy). Thanks for help!
– Alexander Kondaurov
Nov 25 '18 at 18:49
Yeah that can work, the ideal scenario is that the generator calls the bash script to generate the files, and then return the list of generated files to be managed.
– Luis Miguel Mejía Suárez
Nov 25 '18 at 18:53
Yeah that can work, the ideal scenario is that the generator calls the bash script to generate the files, and then return the list of generated files to be managed.
– Luis Miguel Mejía Suárez
Nov 25 '18 at 18:53
add a comment |
I think i found answer, now it works:
unmanagedSourceDirectories in Compile += baseDirectory.value.getParentFile.getParentFile / "protos" / "generated" / "scala"
add a comment |
I think i found answer, now it works:
unmanagedSourceDirectories in Compile += baseDirectory.value.getParentFile.getParentFile / "protos" / "generated" / "scala"
add a comment |
I think i found answer, now it works:
unmanagedSourceDirectories in Compile += baseDirectory.value.getParentFile.getParentFile / "protos" / "generated" / "scala"
I think i found answer, now it works:
unmanagedSourceDirectories in Compile += baseDirectory.value.getParentFile.getParentFile / "protos" / "generated" / "scala"
answered Nov 25 '18 at 20:23
Alexander KondaurovAlexander Kondaurov
57611132
57611132
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.
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%2f53466799%2fsource-files-in-src-managed-are-not-part-of-project-sources-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