Hello All, I have a project that I’m working on b...
# multiplatform
a
Hello All, I have a project that I’m working on behind a corporate firewall, so I only have access to our Artifactory instance. This project targets nodejs(), and our build machines already have node and yarn installed. I tried the following to prevent the build from trying to download/install node/yarn, but it doesn’t seem to have any effect:
Copy code
rootProject.plugins.withType(NodeJsRootPlugin::class) {
    var nodeJsRootExt = rootProject.the<NodeJsRootExtension>()
    nodeJsRootExt.download = false
    nodeJsRootExt.nodeVersion = "16.15.4"
}

rootProject.plugins.withType(YarnPlugin::class) {
    var gsmlYarnRootExt = rootProject.the<YarnRootExtension>()
    gsmlYarnRootExt.download = false
    gsmlYarnRootExt.version = "1.22.11"
}
For some reason, the build “sees” the assigned version numbers, but it ignores the download = false. Also, I’m using plugin version 1.5.20, and the YarnRootExtension class clearly has “download” as a field, but IntelliJ says otherwise and when I Cmd+Click to go to the definition of the class, the property is not there, which means to me that gradle is not pulling in the latest for some reason. Do any of you have any insight to this? Thanks!
t
cc @Ilya Goncharov [JB]
🙏 1
a
@Ilya Goncharov [JB] do you have any insights that you can share? Thanks!
i
Hi, disabling of downloading will be on 1.6. Unfortunately it was not inplemented in earlier versions. Disabling of downloading of NodeJS should work. You can publish Yarn binaries in your private Artifactory and then set
downloadBaseUrl
in Yarn extension
a
Thanks.
Hi @Ilya Goncharov [JB], Disabling nodejs download is still not working despite setting the download flag to false. Any suggestions? Thanks!
i
Do you mean, that yarn is downloaded or nodejs is downloaded too?
a
NodeJs is downloaded
And because the URL format is hardcoded, it fails even more miserably, especially because we can't access nodejs.org and have to go against our artifactory which doesn't have the packages in the same format.
I have the following in my build.gradle.kts for debugging....
Copy code
project.rootProject.plugins.withType(NodeJsRootPlugin::class) {
    project.extensions.configure(NodeJsRootExtension::class) {
        this.download = false
        this.nodeVersion = "16.9.0"
    }
}

tasks.whenTaskAdded {
    val unwantedTasks = listOf(
        "kotlinNodeJsSetup",
        "kotlinYarnSetup"
    )

    println("Adding task ${this.name}...")

    if(unwantedTasks.contains(this.name)) {
        println("Disabling ${this.name}...")
        this.enabled = false

        project.extensions.configure(NodeJsRootExtension::class) {
            println("Extension download is set to ${this.download}...")
            println("Extension installationDir is set to ${this.installationDir}...")
            println("Extension nodeDownloadBaseUrl is set to ${this.nodeDownloadBaseUrl}...")
            println("Extension nodeVersion is set to ${this.nodeVersion}...")
            println("Extension nodeCommand is set to ${this.nodeCommand}...")

            this.download = false
            println("       Set download to ${this.download}...")
        }
    }
}
When I run it, I get the following output...
Copy code
> Configure project :
Adding task jsProcessResources...
Adding task jsMainClasses...
Adding task jsTestProcessResources...
Adding task jsTestClasses...
Adding task compileKotlinJs...
Adding task jsSourcesJar...
Adding task compileTestKotlinJs...
Adding task jsJar...
Adding task allTests...
Adding task jsTest...
Adding task kotlinNodeJsSetup...
Disabling kotlinNodeJsSetup...
Extension download is set to true...
Extension installationDir is set to /Users/lopealf/.gradle/nodejs...
Extension nodeDownloadBaseUrl is set to <https://nodejs.org/dist>...
Extension nodeVersion is set to 14.17.0...
Extension nodeCommand is set to node...
       Set download to false...
Adding task kotlinNpmInstall...
Adding task kotlinNpmCachesSetup...
Adding task packageJsonUmbrella...
Adding task kotlinYarnSetup...
Disabling kotlinYarnSetup...
Extension download is set to false...
Extension installationDir is set to /Users/lopealf/.gradle/nodejs...
Extension nodeDownloadBaseUrl is set to <https://nodejs.org/dist>...
Extension nodeVersion is set to 14.17.0...
Extension nodeCommand is set to node...
       Set download to false...
Adding task rootPackageJson...
Adding task yarnKotlinClean...
Adding task nodeKotlinClean...
Adding task compileTestProductionExecutableKotlinJs...
Adding task jsTestTestProductionExecutableCompileSync...
Adding task compileTestDevelopmentExecutableKotlinJs...
Adding task jsTestTestDevelopmentExecutableCompileSync...
Adding task jsPackageJson...
Adding task jsPublicPackageJson...
Adding task jsGenerateExternalsIntegrated...
Adding task jsGenerateExternals...
Adding task jsTestPackageJson...
Adding task jsTestPublicPackageJson...
Adding task jsNodeTest...
Adding task cleanAllTests...
Adding task compileProductionExecutableKotlinJs...
Adding task jsProductionExecutableCompileSync...
Adding task jsNodeProductionRun...
Adding task jsRun...
Adding task compileDevelopmentExecutableKotlinJs...
Adding task jsDevelopmentExecutableCompileSync...
Adding task jsNodeDevelopmentRun...
Adding task jsNodeRun...
Adding task cleanDist...
Adding task stageForNpm...
Adding task publish...
Adding task pack...
NPM Repository [local] is invalid. Skipping...
Adding task assembleJsNpmPublication...
Adding task packJsNpmPublication...
Adding task publishJsNpmPublicationToManulife...
Adding task metadataCommonMainClasses...
Adding task compileCommonMainKotlinMetadata...
Adding task transformCommonMainDependenciesMetadata...
Adding task transformMainDependenciesMetadata...

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':kotlinNodeJsSetup'.
> Could not resolve all files for configuration ':detachedConfiguration1'.
   > Could not resolve org.nodejs:node:16.9.0.
     Required by:
         project :
      > Could not resolve org.nodejs:node:16.9.0.
         > Could not get resource '<https://nodejs.org/dist/v16.9.0/node-v16.9.0-darwin-x64.tar.gz>'.
            > Could not HEAD '<https://nodejs.org/dist/v16.9.0/node-v16.9.0-darwin-x64.tar.gz>'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: <https://docs.gradle.org/7.2/userguide/build_environment.html#gradle_system_properties>
                  > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Now, I'm behind a corporate firewall and our Artifactory's path to node (if any) is not in the same format as what the plugin is set.