Skip to content

Commit

Permalink
Hopefully worked around Node plugin issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
lagergren committed Dec 20, 2023
1 parent 80f2b9d commit 2d6d268
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 22 deletions.
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

/**
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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=<password>>",
# placed in $GRADLE_USER_HOME/gradle.properties, or used a secret in an environment variable (for example
Expand Down
7 changes: 4 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 5 additions & 12 deletions platformUI/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
35 changes: 32 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand All @@ -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")
}
}
}
}

Expand Down

0 comments on commit 2d6d268

Please sign in to comment.