node-gradle / gradle-node-plugin

Gradle plugin for integrating NodeJS in your build. :rocket:
Apache License 2.0
601 stars 117 forks source link

Retrieving Node binary location #213

Closed mleegwt closed 2 years ago

mleegwt commented 2 years ago

To allow reporting code to Sonar we used:

    def nodeExt = project.extensions.getByType(com.github.gradle.node.NodeExtension)
    def variantComputer = new com.github.gradle.node.variant.VariantComputer()
    def nodeDirProvider = variantComputer.computeNodeDir(nodeExt)
    def nodeBinary = variantComputer.computeNodeExec(nodeExt, variantComputer.computeNodeBinDir(nodeDirProvider)).get()

to determine the Node binary. Since version 3.2.0 of the plugin this no longer works (I think it stopped working due to 98f7bdc22c9fccdd818aca1e0f18f64ba4891b95).

I'm aware that the code snippet above is using the plugin internals. So I'm wondering whether there is a better way to retrieve the Node binary so we can correctly inform Sonar. Thanks in advance!

deepy commented 2 years ago

I currently got a high fever from the booster but I think if you just change to VariantComputer(PlatformHelper.INSTANCE) it should work

The current roadmap is pretty much merging the old PRs, fixing the old bugs, fixing some more critical bugs, opening up the internal classes, and then starting to look into the worker api / shared build services. Which I'm hoping will lead to a nicer way of passing the node binary to sonarqube

mleegwt commented 2 years ago

Works like a charm! Take care! Should this issue remain open for the 'nicer way'? Or is closing more appropriate.

deepy commented 2 years ago

I'll fix this in 3.2.1 by adding a 0-argument constructor which does this, it's going to be released before the week is over so we can leave this open until then

deepy commented 2 years ago

This was fixed in 3.2.1