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

Use of Node V8 Canary

Open Horcrux7 opened this issue 4 years ago • 11 comments

Is it possible to use the node version with V8 canary and how can I do it?

The problem that I see is that repository pattern is different: https://nodejs.org/download/v8-canary/

I try the follow settings:

distBaseUrl = 'https://nodejs.org/download/v8-canary/'
version = '15.0.0-v8-canary20200424f04d3357b9'

But this result in the follow exception:

java.lang.NumberFormatException: For input string: "0-v8-canary20200424f04d3357b9"
	at com.moowork.gradle.node.variant.VariantBuilder.hasWindowsZip(VariantBuilder.groovy:136)
	at com.moowork.gradle.node.variant.VariantBuilder.build(VariantBuilder.groovy:56)
	at com.moowork.gradle.node.variant.VariantBuilder$build.call(Unknown Source)
	at com.moowork.gradle.node.NodePlugin$_apply_closure1.doCall(NodePlugin.groovy:43)

Horcrux7 avatar Apr 24 '20 16:04 Horcrux7

Changing the repository URL is indeed not enough. You have to use a custom repository (not just the URL but the whole configuration).

I don't know very well this part but here is an example provided by @deepy (extracted from here) of custom repository usage:

repositories.ivy {
    setUrl('https://nodejs.org/dist/latest-v10.x/')
    patternLayout {
        artifact("[artifact](-v[revision]-[classifier]).[ext]")
    }
    metadataSources {
        artifact()
    }
    setComponentVersionsLister(SpecificListener)
}

node {
    distBaseUrl = null
    version = '10.+'
}

Setting distBaseUrl to null makes the plugin not to declare the default repository. You have to adjust the pattern to match the V8 canary file names.

Hope it will help you!

bsautel avatar Apr 26 '20 15:04 bsautel

(dynamic versions will require a ComponentMetadataVersionLister to work, but the rest is ok)

deepy avatar Apr 29 '20 15:04 deepy

The problem ist that com.moowork.gradle.node.variant.VariantBuilder only accept a format of number.number.number. All other result in a NumberFormatException.

Horcrux7 avatar Apr 30 '20 20:04 Horcrux7

The ComponentMetadataVersionLister will never invoke in my Gradle script. To hack around the problem with the wrong validation of version I inject the version directly in the pattern. A very ugly hack.

repositories{
    ivy {
        url = 'https://nodejs.org/download/v8-canary/'
        def revision = '15.0.0-v8-canary20200424f04d3357b9'
        patternLayout {
            //artifact("v[revision]/[artifact]-v[revision]-[classifier].[ext]")
            artifact("v${revision}/[artifact]-v${revision}-[classifier].[ext]")
        }
    }
}
node {
    distBaseUrl = null
    version = '15.0.0'
    download = true
}

Horcrux7 avatar Apr 30 '20 20:04 Horcrux7

Ok, I see what you mean. It's not very elegant, that's clear, but does it work as expected now?

I don't know enough how repository works to explain why the componentVersionsLister is never called.

bsautel avatar May 01 '20 06:05 bsautel

ComponentMetadataVersionLister will never trigger unless you're trying to use a dynamic version (e.g. 10.+).

deepy avatar May 01 '20 09:05 deepy

but does it work as expected now?

Yes and No. I can do some progress now. But it is not a solution for the long time. I think about to remove the plugin completely and to download the node version with Gradle stuff directly. I will decide it later.

unless you're trying to use a dynamic version (e.g. 10.+).

And this is not possible with the VariantBuilder of the latest version. This make it clear why it is never call.

Thanks for all your suggestions.

Horcrux7 avatar May 01 '20 14:05 Horcrux7

Could you give us the error you get with the VariantBuilder?

In the future version, we rewrote completely the code to Kotlin and the VariantBuilder no longer exists. Maybe this limitation no longer exists or can be removed quite easily.

bsautel avatar May 01 '20 17:05 bsautel

Could you give us the error you get with the VariantBuilder?

Caused by: java.lang.NumberFormatException: For input string: "+"
	at com.moowork.gradle.node.variant.VariantBuilder.hasWindowsZip(VariantBuilder.groovy:135)
	at com.moowork.gradle.node.variant.VariantBuilder.build(VariantBuilder.groovy:56)
	at com.moowork.gradle.node.variant.VariantBuilder$build.call(Unknown Source)
	at com.moowork.gradle.node.NodePlugin$_apply_closure1.doCall(NodePlugin.groovy:43)

In the future version, we rewrote completely the code to Kotlin and the VariantBuilder no longer exists.

When do you want release it?

Horcrux7 avatar May 01 '20 19:05 Horcrux7

Ok, you will also get this error with the new version because this code still exists. But it is only here to support very old versions of Node.js that are no longer supported. I would be in favor to drop their support, this would enable us to simply remove the need to parse the version. I created #100 for this.

Most of the work of the future version has been done. As we broke many things regarding backward compatibility (Kotlin rewrite and more), we want to ensure we won't have to do other breaking changes in the near future (if it is the case, we would like to do it before its release).

bsautel avatar May 02 '20 07:05 bsautel

I just come to fix #100. So in the next version you will be able to do it without having this error in the VariantBuilder (we no longer parse the version number).

bsautel avatar May 05 '20 08:05 bsautel