gradle-node-plugin icon indicating copy to clipboard operation
gradle-node-plugin copied to clipboard

Last yarn task overrides all older yarn tasks

Open monarchwadia opened this issue 7 years ago • 5 comments

task ("CommonUiYarn", type:YarnTask) { ... }
task ("NavYarn", type:YarnTask) { ... }
task ("OmYarn", type:YarnTask) { ... }

It seems that "OmYarn" here is overriding "CommonUiYarn" as well as "NavYarn", such that if I run "CommonUiYarn" or "NavYarn", then instead they always runs as if they were running "OmYarn". (The name that is being printed during the build is the name of the task being run, i.e. CommonUiYarn will output :CommonUiYarn in the terminal during the build, but the behaviour is that of OmYarn.

However, if I define OmYarn at the beginning of the file, such that the new order is:

task ("OmYarn", type:YarnTask) { ... }
task ("CommonUiYarn", type:YarnTask) { ... }
task ("NavYarn", type:YarnTask) { ... }

Then no matter what task I choose, it always runs as if I was running the NavYarn task.

=======================

Original code:

task ("CommonUiYarn", type:YarnTask) {
    node {
        inputs.files(fileTree(CommonUi['src']))
        nodeModulesDir = file(CommonUi['src'])
    }
    args = ['install']
}

task ("NavYarn", type:YarnTask) {
    node {
        inputs.files(fileTree(Nav['src']))
        nodeModulesDir = file(Nav['src'])
    }
    args = ['install']
}

task ("OmYarn", type:YarnTask) {
    node {
        inputs.files(fileTree(Om['src']))
        nodeModulesDir = file(Om['src'])
    }
    args = ['install']
}

I have checked the path definitions, they are all different.

monarchwadia avatar May 12 '17 17:05 monarchwadia

Thanks for reporting this. The node-extension namespace is just evaluated once so you cannot change it in that way. I will need to make some modifications to allow this.

Marking this as a bug, but it's not a trivial task right now. But will see how I could do it without too much code.

srs avatar May 25 '17 22:05 srs

Thanks. I had to use the vanilla Exec task as a workaround. Would love to use this plugin again in a future project, if this issue is solved.

monarchwadia avatar Jun 16 '17 19:06 monarchwadia

What do you need to override? Is it just nodeModulesDir?

srs avatar Jun 16 '17 22:06 srs

I'm hitting this roadblock just now. are there any news or workarounds for this? Thanks

martin19 avatar Oct 06 '21 12:10 martin19

#315 is a good issue to read, but you can do this in the fork with execOverrides

deepy avatar Oct 06 '21 14:10 deepy