gradle-node-plugin
gradle-node-plugin copied to clipboard
Use of Node V8 Canary
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)
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!
(dynamic versions will require a ComponentMetadataVersionLister
to work, but the rest is ok)
The problem ist that com.moowork.gradle.node.variant.VariantBuilder only accept a format of number.number.number
. All other result in a NumberFormatException.
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
}
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.
ComponentMetadataVersionLister
will never trigger unless you're trying to use a dynamic version (e.g. 10.+
).
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.
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.
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?
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).
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).