How can I create an incremental build to derive output filenames from input filenames? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Gradle plugin for custom languageCan gradle extensions handle lazy evaluation of a property?How can I clean a custom incremental build?Could not find method compile() for arguments GradleGradle plugin best practices for tasks that depend on extension objectsGradle plugin task orderingShared @Input properties on Gradle Plugin tasks, ideally nested configjava.lang.NullPointerException (no error message)Gradle Build Error: Execution failed for task ':app:prepareDebugDependencies'SonarQube for Gradle: Component can't be nullStart groovysh with gradle task

How to avoid introduction cliches

How to open locks without disable device?

A faster way to compute the largest prime factor

Why did Israel vote against lifting the American embargo on Cuba?

"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?

How would I use different systems of magic when they are capable of the same effects?

Are these square matrices always diagonalisable?

Suing a Police Officer Instead of the Police Department

Prove the alternating sum of a decreasing sequence converging to 0 is Cauchy.

What's the difference between using dependency injection with a container and using a service locator?

Retract an already submitted recommendation letter (written for an undergrad student)

How to use @AuraEnabled base class method in Lightning Component?

Does Feeblemind produce an ongoing magical effect that can be dispelled?

Raising a bilingual kid. When should we introduce the majority language?

What’s with the clanks in Endgame?

Why isn't everyone flabbergasted about Bran's "gift"?

What is the best way to deal with NPC-NPC combat?

Implementing 3DES algorithm in Java: is my code secure?

Can you stand up from being prone using Skirmisher outside of your turn?

Is Diceware more secure than a long passphrase?

What is it called when you ride around on your front wheel?

How to not starve gigantic beasts

What to do with someone that cheated their way through university and a PhD program?

What is /etc/mtab in Linux?



How can I create an incremental build to derive output filenames from input filenames?



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Gradle plugin for custom languageCan gradle extensions handle lazy evaluation of a property?How can I clean a custom incremental build?Could not find method compile() for arguments GradleGradle plugin best practices for tasks that depend on extension objectsGradle plugin task orderingShared @Input properties on Gradle Plugin tasks, ideally nested configjava.lang.NullPointerException (no error message)Gradle Build Error: Execution failed for task ':app:prepareDebugDependencies'SonarQube for Gradle: Component can't be nullStart groovysh with gradle task



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I must write a plugin to compile files of a certain type not covered by an existing plugin.



My initial requirements are simply that if the input file is changed or if the output is missing, then the task will not be up-to-date. In other words, I want the core "working with files" paradigm to work for me.



My first attempt was to declare both inputs and outputs to see if the project would work as most would expect.



class TestPlugin implements Plugin<Project> 
void apply (Project project)
project.task('compile')
doFirst
inputs.files.eachWithIndex inFilename, idx ->
def inFile = project.file(inFilename)
def outFilename = outputs.files[idx]
def outFile = project.file(outFilename)
logger.info "converting $inFile to $outFile"
outFile.append "something"





apply plugin: TestPlugin
compile
inputs.file "test.in"
outputs.file "test.out"



And it does. At this point it does all I need except for one thing: I have to define outputs in correlation with inputs. But defining the outputs is complicated enough to warrant factoring that part of the code into the plugin's task.



My next attempt was to try to get the task to define its outputs but it fails because when the "populate outputs" code executes, inputs is empty and so no outputs are added.



class TestPlugin implements Plugin<Project> 
void apply (Project project)
project.task('compile')
inputs.files.each outputs.files.add(it.replaceFirst(~/.in$/, '.out'))
doFirst
inputs.files.eachWithIndex inFilename, idx ->
def inFile = project.file(inFilename)
def outFilename = outputs.files[idx]
def outFile = project.file(outFilename)
logger.info "converting $inFile to $outFile"
outFile.append "something"





apply plugin: TestPlugin
compile inputs.file "test.in"


The above fails with a "path may not be null..." error caused by indexing an empty outputs list (because inputs is empty at the time the task's outer block iterates over inputs.



I tried populating outputs in Project.afterEvaluate and Project.beforeEvaluate but neither worked. The beforeEvaluate closure never executed. The afterEvaluate closure executed, well, after the project was evaluated which means it executed after the task was set as either up-to-date or out-of-date and so it's not useful for what I need.



I also tried Project.configure but that didn't work either.



Then I discovered lazy configuration but since it's incubating I think I should avoid it. I'm assuming that the Java and C plugins don't use incubating features and that leaves me wondering how those plugins are accomplishing the equivalent of lazy configuration.



Then I found Gradle plugin for custom language but it doesn't have an answer. It does, however, have a comment leading me to look at a lot of gradle source code. Again, I don't think I should have to reinvent the wheel.



Lastly, if I have to push the decision to compile into doFirst and not bother with declaring outputs (and thereby abandon task up-to-datedness), then so be it. I just need to know and move on.



For more context, I'm migrating a build away from ant. The two udemy.com classes I took helped me a lot but didn't go far enough to lead me in a confident direction to solve the stated problem. I asked a similar question to one of the instructors and its community to no avail.










share|improve this question




























    1















    I must write a plugin to compile files of a certain type not covered by an existing plugin.



    My initial requirements are simply that if the input file is changed or if the output is missing, then the task will not be up-to-date. In other words, I want the core "working with files" paradigm to work for me.



    My first attempt was to declare both inputs and outputs to see if the project would work as most would expect.



    class TestPlugin implements Plugin<Project> 
    void apply (Project project)
    project.task('compile')
    doFirst
    inputs.files.eachWithIndex inFilename, idx ->
    def inFile = project.file(inFilename)
    def outFilename = outputs.files[idx]
    def outFile = project.file(outFilename)
    logger.info "converting $inFile to $outFile"
    outFile.append "something"





    apply plugin: TestPlugin
    compile
    inputs.file "test.in"
    outputs.file "test.out"



    And it does. At this point it does all I need except for one thing: I have to define outputs in correlation with inputs. But defining the outputs is complicated enough to warrant factoring that part of the code into the plugin's task.



    My next attempt was to try to get the task to define its outputs but it fails because when the "populate outputs" code executes, inputs is empty and so no outputs are added.



    class TestPlugin implements Plugin<Project> 
    void apply (Project project)
    project.task('compile')
    inputs.files.each outputs.files.add(it.replaceFirst(~/.in$/, '.out'))
    doFirst
    inputs.files.eachWithIndex inFilename, idx ->
    def inFile = project.file(inFilename)
    def outFilename = outputs.files[idx]
    def outFile = project.file(outFilename)
    logger.info "converting $inFile to $outFile"
    outFile.append "something"





    apply plugin: TestPlugin
    compile inputs.file "test.in"


    The above fails with a "path may not be null..." error caused by indexing an empty outputs list (because inputs is empty at the time the task's outer block iterates over inputs.



    I tried populating outputs in Project.afterEvaluate and Project.beforeEvaluate but neither worked. The beforeEvaluate closure never executed. The afterEvaluate closure executed, well, after the project was evaluated which means it executed after the task was set as either up-to-date or out-of-date and so it's not useful for what I need.



    I also tried Project.configure but that didn't work either.



    Then I discovered lazy configuration but since it's incubating I think I should avoid it. I'm assuming that the Java and C plugins don't use incubating features and that leaves me wondering how those plugins are accomplishing the equivalent of lazy configuration.



    Then I found Gradle plugin for custom language but it doesn't have an answer. It does, however, have a comment leading me to look at a lot of gradle source code. Again, I don't think I should have to reinvent the wheel.



    Lastly, if I have to push the decision to compile into doFirst and not bother with declaring outputs (and thereby abandon task up-to-datedness), then so be it. I just need to know and move on.



    For more context, I'm migrating a build away from ant. The two udemy.com classes I took helped me a lot but didn't go far enough to lead me in a confident direction to solve the stated problem. I asked a similar question to one of the instructors and its community to no avail.










    share|improve this question
























      1












      1








      1


      1






      I must write a plugin to compile files of a certain type not covered by an existing plugin.



      My initial requirements are simply that if the input file is changed or if the output is missing, then the task will not be up-to-date. In other words, I want the core "working with files" paradigm to work for me.



      My first attempt was to declare both inputs and outputs to see if the project would work as most would expect.



      class TestPlugin implements Plugin<Project> 
      void apply (Project project)
      project.task('compile')
      doFirst
      inputs.files.eachWithIndex inFilename, idx ->
      def inFile = project.file(inFilename)
      def outFilename = outputs.files[idx]
      def outFile = project.file(outFilename)
      logger.info "converting $inFile to $outFile"
      outFile.append "something"





      apply plugin: TestPlugin
      compile
      inputs.file "test.in"
      outputs.file "test.out"



      And it does. At this point it does all I need except for one thing: I have to define outputs in correlation with inputs. But defining the outputs is complicated enough to warrant factoring that part of the code into the plugin's task.



      My next attempt was to try to get the task to define its outputs but it fails because when the "populate outputs" code executes, inputs is empty and so no outputs are added.



      class TestPlugin implements Plugin<Project> 
      void apply (Project project)
      project.task('compile')
      inputs.files.each outputs.files.add(it.replaceFirst(~/.in$/, '.out'))
      doFirst
      inputs.files.eachWithIndex inFilename, idx ->
      def inFile = project.file(inFilename)
      def outFilename = outputs.files[idx]
      def outFile = project.file(outFilename)
      logger.info "converting $inFile to $outFile"
      outFile.append "something"





      apply plugin: TestPlugin
      compile inputs.file "test.in"


      The above fails with a "path may not be null..." error caused by indexing an empty outputs list (because inputs is empty at the time the task's outer block iterates over inputs.



      I tried populating outputs in Project.afterEvaluate and Project.beforeEvaluate but neither worked. The beforeEvaluate closure never executed. The afterEvaluate closure executed, well, after the project was evaluated which means it executed after the task was set as either up-to-date or out-of-date and so it's not useful for what I need.



      I also tried Project.configure but that didn't work either.



      Then I discovered lazy configuration but since it's incubating I think I should avoid it. I'm assuming that the Java and C plugins don't use incubating features and that leaves me wondering how those plugins are accomplishing the equivalent of lazy configuration.



      Then I found Gradle plugin for custom language but it doesn't have an answer. It does, however, have a comment leading me to look at a lot of gradle source code. Again, I don't think I should have to reinvent the wheel.



      Lastly, if I have to push the decision to compile into doFirst and not bother with declaring outputs (and thereby abandon task up-to-datedness), then so be it. I just need to know and move on.



      For more context, I'm migrating a build away from ant. The two udemy.com classes I took helped me a lot but didn't go far enough to lead me in a confident direction to solve the stated problem. I asked a similar question to one of the instructors and its community to no avail.










      share|improve this question














      I must write a plugin to compile files of a certain type not covered by an existing plugin.



      My initial requirements are simply that if the input file is changed or if the output is missing, then the task will not be up-to-date. In other words, I want the core "working with files" paradigm to work for me.



      My first attempt was to declare both inputs and outputs to see if the project would work as most would expect.



      class TestPlugin implements Plugin<Project> 
      void apply (Project project)
      project.task('compile')
      doFirst
      inputs.files.eachWithIndex inFilename, idx ->
      def inFile = project.file(inFilename)
      def outFilename = outputs.files[idx]
      def outFile = project.file(outFilename)
      logger.info "converting $inFile to $outFile"
      outFile.append "something"





      apply plugin: TestPlugin
      compile
      inputs.file "test.in"
      outputs.file "test.out"



      And it does. At this point it does all I need except for one thing: I have to define outputs in correlation with inputs. But defining the outputs is complicated enough to warrant factoring that part of the code into the plugin's task.



      My next attempt was to try to get the task to define its outputs but it fails because when the "populate outputs" code executes, inputs is empty and so no outputs are added.



      class TestPlugin implements Plugin<Project> 
      void apply (Project project)
      project.task('compile')
      inputs.files.each outputs.files.add(it.replaceFirst(~/.in$/, '.out'))
      doFirst
      inputs.files.eachWithIndex inFilename, idx ->
      def inFile = project.file(inFilename)
      def outFilename = outputs.files[idx]
      def outFile = project.file(outFilename)
      logger.info "converting $inFile to $outFile"
      outFile.append "something"





      apply plugin: TestPlugin
      compile inputs.file "test.in"


      The above fails with a "path may not be null..." error caused by indexing an empty outputs list (because inputs is empty at the time the task's outer block iterates over inputs.



      I tried populating outputs in Project.afterEvaluate and Project.beforeEvaluate but neither worked. The beforeEvaluate closure never executed. The afterEvaluate closure executed, well, after the project was evaluated which means it executed after the task was set as either up-to-date or out-of-date and so it's not useful for what I need.



      I also tried Project.configure but that didn't work either.



      Then I discovered lazy configuration but since it's incubating I think I should avoid it. I'm assuming that the Java and C plugins don't use incubating features and that leaves me wondering how those plugins are accomplishing the equivalent of lazy configuration.



      Then I found Gradle plugin for custom language but it doesn't have an answer. It does, however, have a comment leading me to look at a lot of gradle source code. Again, I don't think I should have to reinvent the wheel.



      Lastly, if I have to push the decision to compile into doFirst and not bother with declaring outputs (and thereby abandon task up-to-datedness), then so be it. I just need to know and move on.



      For more context, I'm migrating a build away from ant. The two udemy.com classes I took helped me a lot but didn't go far enough to lead me in a confident direction to solve the stated problem. I asked a similar question to one of the instructors and its community to no avail.







      gradle groovy






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 22 at 15:45









      jeff6times7jeff6times7

      1,54511224




      1,54511224






















          0






          active

          oldest

          votes












          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%2f55303283%2fhow-can-i-create-an-incremental-build-to-derive-output-filenames-from-input-file%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          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%2f55303283%2fhow-can-i-create-an-incremental-build-to-derive-output-filenames-from-input-file%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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript