From 3dc153093e6eecbaba79934a370b66cf6b9c9969 Mon Sep 17 00:00:00 2001 From: Marcus Lagergren <1062473+lagergren@users.noreply.github.com> Date: Wed, 20 Dec 2023 18:39:51 +0100 Subject: [PATCH] Hopefully worked around Node plugin issue. --- build.gradle.kts | 5 +++-- gradle.properties | 2 -- gradle/libs.versions.toml | 7 ++++--- platformUI/build.gradle.kts | 17 +++++------------ settings.gradle.kts | 35 ++++++++++++++++++++++++++++++++--- 5 files changed, 44 insertions(+), 22 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 5e37a54..5f79ae1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,7 @@ */ plugins { alias(libs.plugins.xtc) - alias(libs.plugins.tasktree) // for debugging purposes, for example: + alias(libs.plugins.tasktree) // for debugging purposes. } /** @@ -51,11 +51,12 @@ xtcRun { } } +/* val runXtc by tasks.existing { // Add a dependency on the build to ensure that any subcomponents that have "build" tasks, but may not have them // due to being proper Gradle lifecycle projects, are built. I am 99% sure we can just remove this. dependsOn(tasks.build) -} +}*/ val run by tasks.registering { group = "application" diff --git a/gradle.properties b/gradle.properties index 6811c1a..0694e6d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,6 @@ group=platform.xqiz.it version=0.1.0 -xtcVersion=0.4.44 - # NOTE: This property would not live inside your repository for a production case, but # should be passed through a Gradle command line property "-Porg.xtclang.platform.password=>", # placed in $GRADLE_USER_HOME/gradle.properties, or used a secret in an environment variable (for example diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 319171d..1832d4f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,14 +11,15 @@ # [versions] -node = "7.0.1" -npm = "10.2.0" +gradle-node = "7.0.1" +node = "20.10.0" +npm = "10.2.5" yarn = "1.22.21" xdk = "0.4.44" tasktree = "2.1.1" [plugins] -node = { id = "com.github.node-gradle.node", version.ref = "node" } +node = { id = "com.github.node-gradle.node", version.ref = "gradle-node" } xtc = { id = "org.xtclang.xtc-plugin", version.ref = "xdk" } # taskTree is a helper that we can use to view task dependencies diff --git a/platformUI/build.gradle.kts b/platformUI/build.gradle.kts index b07f820..7816a72 100644 --- a/platformUI/build.gradle.kts +++ b/platformUI/build.gradle.kts @@ -17,22 +17,15 @@ import com.github.gradle.node.yarn.task.YarnTask node { + // Retrieve tested versions of Node, Npm and Yarn from the version catalog (see gradle/libs.versions.toml) version = libs.versions.node.get() npmVersion = libs.versions.npm.get() yarnVersion = libs.versions.yarn.get() - // TODO: Typically you would set download=true here to ensure that we download and use - // exactly the versions of the tools above. These would go into the .gradle cache - // directory of this subproject, and not anywhere else in the system. However, - // the node plugin will add a hidden repository to the current project if the - // download flag is enabled, and to keep things strict and simple, and also conform - // to modern Gradle best practice, we want to define repositories in one place only, - // the rootProject settings.gradle.kts file. That file currently contains a - // "repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)" entry, to ensure - // that we have full control over all the repositories required for the build, and - // that we won't have to add an identical repositories block to every build.gradle.kts - // file in every subproject. - //download = true + // Download any Node, Npm and Yarn versions that aren't available locally, and use them from within the build. + download = true + // See settings.gradle.kts; workaround to make the Node plugin work, while still allowing repository declarations outside of settings.gradle.kts. + distBaseUrl = null } plugins { diff --git a/settings.gradle.kts b/settings.gradle.kts index b68823a..400555f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -6,14 +6,17 @@ rootProject.name = "platform" */ pluginManagement { repositories { - // This "val" declaration will go away, as soon as we have a functional artifact workflow running. + /** + * orgXtcLangRepoPlugins() is syntactic sugar for the XTC org GitHub Maven repository: + * TODO: The "val" declaration will go away, as soon as we have a functional artifact workflow running. + */ val orgXtcLangRepoPlugins: () -> MavenArtifactRepository by settings orgXtcLangRepoPlugins() gradlePluginPortal() } plugins { val xtcVersion: String by settings - id("org.xtclang.xtc-plugin") //version(xtcVersion) + id("org.xtclang.xtc-plugin") id("com.github.node-gradle.node") } } @@ -23,9 +26,35 @@ pluginManagement { dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { - // This "val" declaration will go away, as soon as we have a functional artifact workflow running. + /** + * orgXtcLangRepo() is syntactic sugar for the XTC org GitHub Maven repository: + * TODO: The "val" declaration will go away, as soon as we have a functional artifact workflow running. + */ val orgXtcLangRepo: () -> MavenArtifactRepository by settings orgXtcLangRepo() + + /** + * This Node configuration is needed only to prevent the Node plugin from + * adding hard coded repositories to the project where a Node configuration + * with download = true is supplied. I used the workaround suggested in + * the Gradle Node plugin FAQ + * + * @see https://github.com/node-gradle/gradle-node-plugin/blob/main/docs/faq.md#is-this-plugin-compatible-with-centralized-repositories-declaration + */ + ivy { + name = "NodeJS" + setUrl("https://nodejs.org/dist/") + patternLayout { + artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]") + ivy("v[revision]/ivy.xml") + } + metadataSources { + artifact() + } + content { + includeModule("org.nodejs", "node") + } + } } }