Skip to content

Commit

Permalink
[Wasm] Init downloadBaseUrl with set instead of convention
Browse files Browse the repository at this point in the history
^KT-72872 fixed
^KT-72874 fixed
  • Loading branch information
ilgonmic authored and qodana-bot committed Nov 19, 2024
1 parent 9809230 commit ab6bdbb
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,18 @@ class NodeJsGradlePluginIT : KGPBaseTest() {
}
}
}

@DisplayName("Node.js setup test with downloadBaseUrl = null")
@GradleTest
@TestMetadata("subprojects-nodejs-setup")
fun testSetupWithoutDownloadBaseUrl(gradleVersion: GradleVersion) {
project(
"nodejs-setup-with-user-repositories",
gradleVersion,
// we can remove this line, when the min version of Gradle be at least 8.1
dependencyManagement = DependencyManagement.DisabledDependencyManagement
) {
build(":kotlinNodeJsSetup")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
plugins {
id("org.jetbrains.kotlin.multiplatform")
}

kotlin {
js {
nodejs()
}
}

plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsPlugin> {
the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsEnvSpec>().downloadBaseUrl.set(null as String?)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import org.gradle.api.artifacts.repositories.IvyArtifactRepository
import java.net.URI

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenLocal()
mavenCentral()

ivy {
name = "Distributions at https://nodejs.org/dist"
url = URI("https://nodejs.org/dist")

patternLayout {
artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]")
}
metadataSources { artifact() }
content { includeModule("org.nodejs", "node") }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ open class NodeJsPlugin : Plugin<Project> {
)
)
download.convention(objects.providerWithLazyConvention { nodeJsConstructor().download })
downloadBaseUrl.convention(objects.providerWithLazyConvention { nodeJsConstructor().downloadBaseUrl })
// set instead of convention because it is possible to have null value
downloadBaseUrl.set(objects.providerWithLazyConvention { nodeJsConstructor().downloadBaseUrl })
version.convention(objects.providerWithLazyConvention { nodeJsConstructor().version })
command.convention(objects.providerWithLazyConvention { nodeJsConstructor().command })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,52 +50,52 @@ open class NodeJsRootExtension(
}

@Deprecated(
"Use installationDir from NodeJsExtension (not NodeJsRootExtension) instead." +
"Use installationDir from NodeJsEnvSpec (not NodeJsRootExtension) instead." +
"You can find this extension after applying NodeJsPlugin. This will be removed in 2.2"
)
var installationDir: File = gradleHome.resolve("nodejs")

@Deprecated(
"Use download from NodeJsExtension (not NodeJsRootExtension) instead" +
"Use download from NodeJsEnvSpec (not NodeJsRootExtension) instead" +
"You can find this extension after applying NodeJsPlugin. This will be removed in 2.2"
)
var download = true

@Suppress("DEPRECATION")
@Deprecated(
"Use downloadBaseUrl from NodeJsExtension (not NodeJsRootExtension) instead" +
"Use downloadBaseUrl from NodeJsEnvSpec (not NodeJsRootExtension) instead" +
"You can find this extension after applying NodeJsPlugin. This will be removed in 2.2"
)
var nodeDownloadBaseUrl by ::downloadBaseUrl

@Deprecated(
"Use downloadBaseUrl from NodeJsExtension (not NodeJsRootExtension) instead" +
"Use downloadBaseUrl from NodeJsEnvSpec (not NodeJsRootExtension) instead" +
"You can find this extension after applying NodeJsPlugin. This will be removed in 2.2"
)
var downloadBaseUrl: String? = "https://nodejs.org/dist"

@Suppress("DEPRECATION")
@Deprecated(
"Use version from NodeJsExtension (not NodeJsRootExtension) instead" +
"Use version from NodeJsEnvSpec (not NodeJsRootExtension) instead" +
"You can find this extension after applying NodeJsPlugin. This will be removed in 2.2"
)
var nodeVersion by ::version

@Deprecated(
"Use downloadBaseUrl from NodeJsExtension (not NodeJsRootExtension) instead" +
"Use downloadBaseUrl from NodeJsEnvSpec (not NodeJsRootExtension) instead" +
"You can find this extension after applying NodeJsPlugin. This will be removed in 2.2"
)
var version = "22.0.0"

@Deprecated(
"Use command from NodeJsExtension (not NodeJsRootExtension) instead" +
"Use command from NodeJsEnvSpec (not NodeJsRootExtension) instead" +
"You can find this extension after applying NodeJsPlugin. This will be removed in 2.2"
)
var command = "node"

@Suppress("DEPRECATION")
@Deprecated(
"Use command from NodeJsExtension (not NodeJsRootExtension) instead" +
"Use command from NodeJsEnvSpec (not NodeJsRootExtension) instead" +
"You can find this extension after applying NodeJsPlugin. This will be removed in 2.2"
)
var nodeCommand by ::command
Expand Down Expand Up @@ -133,15 +133,15 @@ open class NodeJsRootExtension(
get() = project.tasks.withType(KotlinNpmCachesSetup::class.java).named(KotlinNpmCachesSetup.NAME)

@Deprecated(
"Use nodeJsSetupTaskProvider from NodeJsExtension (not NodeJsRootExtension) instead" +
"Use nodeJsSetupTaskProvider from NodeJsEnvSpec (not NodeJsRootExtension) instead" +
"You can find this extension after applying NodeJsPlugin"
)
val nodeJsSetupTaskProvider: TaskProvider<out NodeJsSetupTask>
get() = with(nodeJs()) {
project.nodeJsSetupTaskProvider
}

@Deprecated("Use NodeJsExtension instead. This will be removed in 2.2")
@Deprecated("Use NodeJsEnvSpec instead. This will be removed in 2.2")
fun requireConfigured(): NodeJsEnv {
return nodeJs().produceEnv(project.providers).get()
}
Expand Down

0 comments on commit ab6bdbb

Please sign in to comment.