Source files in src_managed are not part of project sources in SBT












1















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.










share|improve this question



























    1















    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.










    share|improve this question

























      1












      1








      1








      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.










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 25 '18 at 11:01









      Alexander KondaurovAlexander Kondaurov

      57611132




      57611132
























          2 Answers
          2






          active

          oldest

          votes


















          1















          "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:





          1. Make them unmanaged sources

            That basically means make your script to create the sources in src/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.



          2. 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 the build.sbt file.

            For a more production ready version of the generator, including appropriate location, dependency segregation and testing you may take a look at this.







          share|improve this answer
























          • 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



















          0














          I think i found answer, now it works:



          unmanagedSourceDirectories in Compile += baseDirectory.value.getParentFile.getParentFile / "protos" / "generated" / "scala"





          share|improve this answer























            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            1















            "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:





            1. Make them unmanaged sources

              That basically means make your script to create the sources in src/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.



            2. 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 the build.sbt file.

              For a more production ready version of the generator, including appropriate location, dependency segregation and testing you may take a look at this.







            share|improve this answer
























            • 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
















            1















            "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:





            1. Make them unmanaged sources

              That basically means make your script to create the sources in src/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.



            2. 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 the build.sbt file.

              For a more production ready version of the generator, including appropriate location, dependency segregation and testing you may take a look at this.







            share|improve this answer
























            • 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














            1












            1








            1








            "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:





            1. Make them unmanaged sources

              That basically means make your script to create the sources in src/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.



            2. 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 the build.sbt file.

              For a more production ready version of the generator, including appropriate location, dependency segregation and testing you may take a look at this.







            share|improve this answer














            "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:





            1. Make them unmanaged sources

              That basically means make your script to create the sources in src/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.



            2. 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 the build.sbt file.

              For a more production ready version of the generator, including appropriate location, dependency segregation and testing you may take a look at this.








            share|improve this answer












            share|improve this answer



            share|improve this answer










            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



















            • 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













            0














            I think i found answer, now it works:



            unmanagedSourceDirectories in Compile += baseDirectory.value.getParentFile.getParentFile / "protos" / "generated" / "scala"





            share|improve this answer




























              0














              I think i found answer, now it works:



              unmanagedSourceDirectories in Compile += baseDirectory.value.getParentFile.getParentFile / "protos" / "generated" / "scala"





              share|improve this answer


























                0












                0








                0







                I think i found answer, now it works:



                unmanagedSourceDirectories in Compile += baseDirectory.value.getParentFile.getParentFile / "protos" / "generated" / "scala"





                share|improve this answer













                I think i found answer, now it works:



                unmanagedSourceDirectories in Compile += baseDirectory.value.getParentFile.getParentFile / "protos" / "generated" / "scala"






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 25 '18 at 20:23









                Alexander KondaurovAlexander Kondaurov

                57611132




                57611132






























                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Futebolista

                    Feedback on college project

                    Albești (Vaslui)