Skip to content

Commit 79d666a

Browse files
committed
Migrate to kotlinx.team.node from mooworks
1 parent 941c423 commit 79d666a

File tree

11 files changed

+46
-77
lines changed

11 files changed

+46
-77
lines changed

README.md

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,15 @@ If you are using it for Kotlin Multiplatform, enable metadata in `settings.gradl
2020
enableFeaturePreview('GRADLE_METADATA')
2121
```
2222

23-
In `build.gradle` apply plugin:
24-
25-
```groovy
26-
plugins {
27-
id 'org.jetbrains.gradle.benchmarks.plugin' version '0.1.7'
28-
}
29-
```
30-
3123
For Kotlin/JS code, add Node plugin as well:
3224

3325
```groovy
3426
plugins {
35-
id 'com.moowork.node' version '1.2.0'
27+
id 'kotlinx.team.node'
3628
}
3729
3830
node {
3931
version = "$node_version"
40-
npmVersion = "$npm_version"
41-
download = true
42-
nodeModulesDir = file(buildDir)
43-
}
44-
45-
// Workaround the problem with Node downloading
46-
repositories.whenObjectAdded {
47-
if (it instanceof IvyArtifactRepository) {
48-
metadataSources {
49-
artifact()
50-
}
51-
}
5232
}
5333
```
5434

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ buildscript {
22
repositories {
33
jcenter()
44
gradlePluginPortal()
5-
//maven { url "../kotlin-libraries-infra/build/maven" }
5+
// maven { url "../kotlin-libraries-infra/build/maven" }
66
maven { url "https://dl.bintray.com/orangy/maven" }
77
}
88

99
dependencies {
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
classpath "kotlinx.team:kotlinx.team.infra:0.1.0-dev-25"
11+
classpath "kotlinx.team:kotlinx.team.infra:0.1.0-dev-26"
1212
}
1313
}
1414

examples/build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ subprojects {
88
url = "$rootProject.buildDir/maven"
99
}
1010

11+
mavenLocal()
1112
mavenCentral()
12-
maven { url 'https://dl.bintray.com/orangy/maven' }
13+
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
14+
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
15+
maven { url "https://dl.bintray.com/orangy/maven" }
16+
// maven { url "$rootProject.projectDir/../kotlin-libraries-infra/build/maven" }
1317
}
1418
}

examples/kotlin-kts/build.gradle.kts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ plugins {
1111
id("org.jetbrains.gradle.benchmarks.plugin") version "0.1.7"
1212
}
1313

14-
repositories {
15-
mavenCentral()
16-
maven { setUrl("https://dl.bintray.com/kotlin/kotlin-eap") }
17-
maven { setUrl("https://dl.bintray.com/kotlin/kotlin-dev") }
18-
}
19-
2014
sourceSets.all {
2115
java.srcDir("$name/src")
2216
resources.srcDir("$name/resources")

examples/kotlin-multiplatform/build.gradle

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,30 @@
11
import org.jetbrains.kotlin.konan.target.HostManager
22

3+
buildscript {
4+
repositories {
5+
// maven { url "$rootProject.projectDir/../kotlin-libraries-infra/build/maven" }
6+
}
7+
}
8+
39
plugins {
410
id 'org.jetbrains.kotlin.multiplatform'
511
id 'org.jetbrains.kotlin.plugin.allopen' version "1.3.20"
6-
id 'com.moowork.node' version '1.2.0'
712
id 'org.jetbrains.gradle.benchmarks.plugin' version "0.1.7"
8-
}
9-
10-
node {
11-
version = "$node_version"
12-
npmVersion = "$npm_version"
13-
download = true
14-
15-
workDir = new File(rootProject.projectDir, ".gradle/nodejs")
16-
npmWorkDir = new File(rootProject.projectDir, ".gradle/npm")
17-
nodeModulesDir = file(buildDir)
18-
}
19-
20-
// Workaround the problem with Node downloading
21-
repositories.all {
22-
if (it instanceof IvyArtifactRepository) {
23-
metadataSources {
24-
artifact()
25-
}
26-
}
13+
id 'kotlinx.team.node'
2714
}
2815

2916
project.ext.hostManager = new HostManager()
3017
apply from: rootProject.file("gradle/utility.gradle")
3118

19+
node {
20+
version = '10.15.1'
21+
}
22+
3223
// how to apply plugin to a specific source set?
3324
allOpen {
3425
annotation("org.openjdk.jmh.annotations.State")
3526
}
3627

37-
repositories {
38-
mavenLocal()
39-
mavenCentral()
40-
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
41-
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
42-
}
43-
4428
kotlin {
4529
jvm {
4630
compilations.all {

examples/kotlin/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ sourceSets {
1717
benchmarks
1818
}
1919

20-
2120
// Propagate dependencies from main sourceSet
2221
// You can add "+ sourceSets.test.output" to include test output as well
2322
dependencies {

plugin/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
maven { url "https://dl.bintray.com/orangy/maven" }
77
}
88
dependencies {
9-
classpath "kotlinx.team:kotlinx.team.infra:0.1.0-dev-23"
9+
classpath "kotlinx.team:kotlinx.team.infra:0.1.0-dev-26"
1010
}
1111

1212
}
@@ -39,6 +39,8 @@ repositories {
3939
gradlePluginPortal()
4040
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
4141
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
42+
// maven { url "../../kotlin-libraries-infra/build/maven" }
43+
maven { url "https://dl.bintray.com/orangy/maven" }
4244
}
4345

4446
gradlePlugin {
@@ -75,8 +77,9 @@ dependencies {
7577
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-compiler'
7678
}
7779

80+
compileOnly "kotlinx.team:kotlinx.team.infra:0.1.0-dev-26"
81+
7882
compileOnly group: 'org.jetbrains.kotlin.multiplatform', name: 'org.jetbrains.kotlin.multiplatform.gradle.plugin', version: kotlin_version
79-
compileOnly group: 'com.moowork.node', name: 'com.moowork.node.gradle.plugin', version: '1.2.0'
8083
compileOnly "org.openjdk.jmh:jmh-generator-bytecode:$jmhVersion" // used in worker
8184

8285
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"

plugin/main/src/org/jetbrains/gradle/benchmarks/BenchmarksPlugin.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.jetbrains.gradle.benchmarks
22

3+
import kotlinx.team.infra.node.*
34
import org.gradle.api.*
45
import org.gradle.util.*
56
import org.jetbrains.kotlin.gradle.plugin.*
@@ -28,6 +29,11 @@ class BenchmarksPlugin : Plugin<Project> {
2829
}
2930

3031
override fun apply(project: Project) = project.run {
32+
if (!plugins.hasPlugin(NodePlugin::class.java)) {
33+
logger.info("Enabling node plugin in $this")
34+
pluginManager.apply(NodePlugin::class.java)
35+
}
36+
3137
if (GradleVersion.current() < GradleVersion.version("4.10")) {
3238
logger.error("JetBrains Gradle Benchmarks plugin requires Gradle version 4.10 or higher")
3339
return // TODO: Do we need to fail build at this point or just ignore benchmarks?

plugin/main/src/org/jetbrains/gradle/benchmarks/JsNodeTasks.kt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
package org.jetbrains.gradle.benchmarks
22

3-
import com.moowork.gradle.node.*
4-
import com.moowork.gradle.node.npm.*
5-
import com.moowork.gradle.node.task.*
3+
import kotlinx.team.infra.node.*
64
import org.gradle.api.*
75
import org.gradle.api.tasks.*
86
import org.jetbrains.kotlin.gradle.plugin.mpp.*
97

108
fun Project.createJsBenchmarkInstallTask() {
11-
val node = project.extensions.getByType(NodeExtension::class.java)
12-
task<NpmTask>("npmInstallBenchmarkJs") {
9+
task<NpmInstallTask>("npmInstallBenchmarkJs") {
1310
group = "node"
1411
description = "Install benchmark.js to local node_modules"
15-
setArgs(listOf("install", "--prefer-offline", "benchmark", "-s"))
16-
setWorkingDir(node.nodeModulesDir) // For some reason configured node_modules dir is not picked up
12+
packages.add("benchmark")
13+
dependsOn(NodeSetupTask.NAME)
1714
}
1815
}
1916

20-
2117
fun Project.createJsBenchmarkExecTask(
2218
config: BenchmarkConfiguration,
2319
compilation: KotlinJsCompilation
2420
) {
25-
val node = project.extensions.getByType(NodeExtension::class.java)
26-
val nodeModulesDir = node.nodeModulesDir.resolve("node_modules")
21+
val node = NodeExtension[this]
22+
val nodeModulesDir = node.node_modules
2723
task<NodeTask>(
2824
"${config.name}${BenchmarksPlugin.BENCHMARK_EXEC_SUFFIX}",
2925
depends = BenchmarksPlugin.RUN_BENCHMARKS_TASKNAME
@@ -35,13 +31,13 @@ fun Project.createJsBenchmarkExecTask(
3531
val reportsDir = benchmarkReportsDir(config)
3632
val reportFile = reportsDir.resolve("${config.name}.json")
3733

38-
setScript(nodeModulesDir.resolve(compilation.compileKotlinTask.outputFile.name))
39-
addArgs(reportFile.toString(), config.iterations(), config.iterationTime()) // TODO: configure!
40-
setWorkingDir(nodeModulesDir)
34+
script = nodeModulesDir.resolve(compilation.compileKotlinTask.outputFile.name).absolutePath
35+
arguments(reportFile.toString(), config.iterations().toString(), config.iterationTime().toString()) // TODO: configure!
36+
//setWorkingDir(nodeModulesDir)
4137
dependsOn("${config.name}${BenchmarksPlugin.BENCHMARK_DEPENDENCIES_SUFFIX}")
4238
doFirst {
4339
val ideaActive = (extensions.extraProperties.get("idea.internal.test") as? String)?.toBoolean() ?: false
44-
addArgs(if (ideaActive) "xml" else "text")
40+
arguments(if (ideaActive) "xml" else "text")
4541
reportsDir.mkdirs()
4642
logger.lifecycle("Running benchmarks for ${config.name}")
4743
logger.info(" I:${config.iterations()} T:${config.iterationTime()}")
@@ -54,7 +50,7 @@ fun Project.createJsBenchmarkDependenciesTask(
5450
compilation: KotlinJsCompilation
5551
) {
5652
val node = project.extensions.getByType(NodeExtension::class.java)
57-
val nodeModulesDir = node.nodeModulesDir.resolve("node_modules")
53+
val nodeModulesDir = node.node_modules
5854
val deployTask = task<Copy>("${config.name}${BenchmarksPlugin.BENCHMARK_DEPENDENCIES_SUFFIX}") {
5955
group = BenchmarksPlugin.BENCHMARKS_TASK_GROUP
6056
description = "Copy dependencies of benchmark for '${config.name}'"

runtime/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ repositories {
1919
mavenCentral()
2020
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
2121
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
22+
maven { url "https://dl.bintray.com/orangy/maven" }
2223
}
2324

2425
kotlin {

settings.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ includeBuild("plugin") {
1818
}
1919
}
2020

21+
include "runtime"
22+
23+
include "examples"
24+
include "examples:kotlin-multiplatform"
2125
include "examples:java"
2226
include "examples:kotlin"
23-
include "examples:kotlin-multiplatform"
2427
include "examples:kotlin-kts"
25-
include "runtime"

0 commit comments

Comments
 (0)