How to override libraryDependencies in a sbt plugin?












1















How would one override the libraryDependencies ?
I tried:



  Keys.libraryDependencies in Compile := {
val libraryDependencies = (Keys.libraryDependencies in Compile).value
val allLibraries = UpdateDependencies(libraryDependencies)
allLibraries
}


So that seem to work, when I add print statement, the allLibraries is correct.



However, in the next steps, it doesn't seem to have the right values:



  Keys.update in Compile := Def.taskDyn {
val u = (Keys.update in Compile).value

Def.task {
val allModules= u.configurations.flatMap(_.allModules)
log.info(s"Read ${allModules.size} modules:")
u
}
}.value


The print statement only have a few modules instead of all the one I would have added in the previous step.



Anyone have a solution ? Thanks !










share|improve this question























  • Could you clarify what you mean by "override"? Like the build user adds some library X 1.0, and you want to remove it and add Y 1.0 instead?

    – Eugene Yokota
    Dec 16 '18 at 23:53


















1















How would one override the libraryDependencies ?
I tried:



  Keys.libraryDependencies in Compile := {
val libraryDependencies = (Keys.libraryDependencies in Compile).value
val allLibraries = UpdateDependencies(libraryDependencies)
allLibraries
}


So that seem to work, when I add print statement, the allLibraries is correct.



However, in the next steps, it doesn't seem to have the right values:



  Keys.update in Compile := Def.taskDyn {
val u = (Keys.update in Compile).value

Def.task {
val allModules= u.configurations.flatMap(_.allModules)
log.info(s"Read ${allModules.size} modules:")
u
}
}.value


The print statement only have a few modules instead of all the one I would have added in the previous step.



Anyone have a solution ? Thanks !










share|improve this question























  • Could you clarify what you mean by "override"? Like the build user adds some library X 1.0, and you want to remove it and add Y 1.0 instead?

    – Eugene Yokota
    Dec 16 '18 at 23:53
















1












1








1








How would one override the libraryDependencies ?
I tried:



  Keys.libraryDependencies in Compile := {
val libraryDependencies = (Keys.libraryDependencies in Compile).value
val allLibraries = UpdateDependencies(libraryDependencies)
allLibraries
}


So that seem to work, when I add print statement, the allLibraries is correct.



However, in the next steps, it doesn't seem to have the right values:



  Keys.update in Compile := Def.taskDyn {
val u = (Keys.update in Compile).value

Def.task {
val allModules= u.configurations.flatMap(_.allModules)
log.info(s"Read ${allModules.size} modules:")
u
}
}.value


The print statement only have a few modules instead of all the one I would have added in the previous step.



Anyone have a solution ? Thanks !










share|improve this question














How would one override the libraryDependencies ?
I tried:



  Keys.libraryDependencies in Compile := {
val libraryDependencies = (Keys.libraryDependencies in Compile).value
val allLibraries = UpdateDependencies(libraryDependencies)
allLibraries
}


So that seem to work, when I add print statement, the allLibraries is correct.



However, in the next steps, it doesn't seem to have the right values:



  Keys.update in Compile := Def.taskDyn {
val u = (Keys.update in Compile).value

Def.task {
val allModules= u.configurations.flatMap(_.allModules)
log.info(s"Read ${allModules.size} modules:")
u
}
}.value


The print statement only have a few modules instead of all the one I would have added in the previous step.



Anyone have a solution ? Thanks !







scala sbt






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 5:18









WonayWonay

394112




394112













  • Could you clarify what you mean by "override"? Like the build user adds some library X 1.0, and you want to remove it and add Y 1.0 instead?

    – Eugene Yokota
    Dec 16 '18 at 23:53





















  • Could you clarify what you mean by "override"? Like the build user adds some library X 1.0, and you want to remove it and add Y 1.0 instead?

    – Eugene Yokota
    Dec 16 '18 at 23:53



















Could you clarify what you mean by "override"? Like the build user adds some library X 1.0, and you want to remove it and add Y 1.0 instead?

– Eugene Yokota
Dec 16 '18 at 23:53







Could you clarify what you mean by "override"? Like the build user adds some library X 1.0, and you want to remove it and add Y 1.0 instead?

– Eugene Yokota
Dec 16 '18 at 23:53














1 Answer
1






active

oldest

votes


















0














So I understand where my problem was.
I was not understanding correctly how settings and tasks were working together.



settings are only evaluated once when sbt start.



and tasks are only evaluated once when sbt start a task / command which will require it.



So you cannot read and then rewrite settings like that.



It was so convoluted, I even wrote a whole article about it






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%2f53312891%2fhow-to-override-librarydependencies-in-a-sbt-plugin%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









    0














    So I understand where my problem was.
    I was not understanding correctly how settings and tasks were working together.



    settings are only evaluated once when sbt start.



    and tasks are only evaluated once when sbt start a task / command which will require it.



    So you cannot read and then rewrite settings like that.



    It was so convoluted, I even wrote a whole article about it






    share|improve this answer




























      0














      So I understand where my problem was.
      I was not understanding correctly how settings and tasks were working together.



      settings are only evaluated once when sbt start.



      and tasks are only evaluated once when sbt start a task / command which will require it.



      So you cannot read and then rewrite settings like that.



      It was so convoluted, I even wrote a whole article about it






      share|improve this answer


























        0












        0








        0







        So I understand where my problem was.
        I was not understanding correctly how settings and tasks were working together.



        settings are only evaluated once when sbt start.



        and tasks are only evaluated once when sbt start a task / command which will require it.



        So you cannot read and then rewrite settings like that.



        It was so convoluted, I even wrote a whole article about it






        share|improve this answer













        So I understand where my problem was.
        I was not understanding correctly how settings and tasks were working together.



        settings are only evaluated once when sbt start.



        and tasks are only evaluated once when sbt start a task / command which will require it.



        So you cannot read and then rewrite settings like that.



        It was so convoluted, I even wrote a whole article about it







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 17 '18 at 3:59









        WonayWonay

        394112




        394112
































            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%2f53312891%2fhow-to-override-librarydependencies-in-a-sbt-plugin%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

            Bressuire

            Vorschmack

            Quarantine