From def3ca28c58e8121c72e31c99ea8c672e4eb4bf6 Mon Sep 17 00:00:00 2001 From: Joshua Gleitze Date: Mon, 27 Jan 2020 11:28:28 +0200 Subject: [PATCH] Migrate to com.github.node-gradle.node plugin --- build.gradle | 15 +++++---------- gradle/package-lock.json | 6 +++--- samples/js/jasmine/build.gradle | 20 ++++++-------------- samples/js/mocha/build.gradle | 20 ++++++-------------- 4 files changed, 20 insertions(+), 41 deletions(-) diff --git a/build.gradle b/build.gradle index 5371621cb..75b2413cd 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ buildscript { // project setup tutteli_plugins_version = '0.32.2' - node_plugin_version = '1.3.1' + node_plugin_version = '2.2.0' // gh-pages.gradle docProjects = subprojects.findAll { @@ -113,7 +113,7 @@ buildscript { classpath "ch.tutteli:tutteli-gradle-project-utils:$tutteli_plugins_version" classpath "ch.tutteli:tutteli-gradle-publish:$tutteli_plugins_version" classpath "ch.tutteli:tutteli-gradle-spek:$tutteli_plugins_version" - classpath "com.moowork.gradle:gradle-node-plugin:$node_plugin_version" + classpath "com.github.node-gradle:gradle-node-plugin:$node_plugin_version" } } @@ -412,7 +412,7 @@ List projectNamesToProject(String[] names) { def createJsTestTask(String... subprojectNames) { configure(projectNamesToProject(subprojectNames)) { - apply plugin: 'com.moowork.node' + apply plugin: 'com.github.node-gradle.node' compileTestKotlin2Js.configure { kotlinOptions.moduleKind = "commonjs" @@ -441,13 +441,8 @@ def createJsTestTask(String... subprojectNames) { nodeModulesDir = nodeModulesParentDir } - task installMocha(type: NpmTask) { - args = ['install', 'mocha', '--prefer-offline'] - } - - task prepareMocha(dependsOn: [compileTestKotlin2Js, populateNodeModules, installMocha]) - task runMocha(type: NodeTask, dependsOn: [prepareMocha, test]) { - script = file("$nodeModulesParentDir/node_modules/mocha/bin/mocha") + task runMocha(type: NpxTask, dependsOn: [compileTestKotlin2Js, populateNodeModules, test]) { + command = "mocha" args = [compileTestKotlin2Js.outputFile] } check.dependsOn runMocha diff --git a/gradle/package-lock.json b/gradle/package-lock.json index 92f9cd1db..d50014913 100644 --- a/gradle/package-lock.json +++ b/gradle/package-lock.json @@ -122,9 +122,9 @@ }, "dependencies": { "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", "dev": true, "requires": { "fs.realpath": "^1.0.0", diff --git a/samples/js/jasmine/build.gradle b/samples/js/jasmine/build.gradle index 87f76ecae..d18f3d406 100644 --- a/samples/js/jasmine/build.gradle +++ b/samples/js/jasmine/build.gradle @@ -8,13 +8,13 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.moowork.gradle:gradle-node-plugin:1.2.0' + classpath 'com.github.node-gradle:gradle-node-plugin:2.2.0' classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71' } } apply plugin: 'kotlin2js' -apply plugin: 'com.moowork.node' +apply plugin: 'com.github.node-gradle.node' repositories { jcenter() @@ -70,14 +70,6 @@ node { nodeModulesDir = nodeModulesParentDir } -task installJasmine(type: NpmTask) { - // note, without the '--prefer-offline' it works only if you are online, - // with '--prefer-offline' it works also offline if you have already as well in case you have already downloaded jasmine once - args = ['install', 'jasmine', '--prefer-offline'] -} - -task prepareJasmine(dependsOn: [compileTestKotlin2Js, populateNodeModules, installJasmine]) - //either you use this task or create a testSetup.kt in your src/test with the following content // // // adopt to the api you use @@ -94,8 +86,8 @@ task establishDependencyToAtrium(dependsOn: [compileTestKotlin2Js]) { srcFile.write(newContent, 'UTF-8') } } -task runJasmine(type: NodeTask, group: 'Verification', dependsOn: [prepareJasmine, test, establishDependencyToAtrium]) { - script = file("$nodeModulesParentDir/node_modules/jasmine/bin/jasmine") +task runJasmine(type: NpxTask, group: 'Verification', dependsOn: [populateNodeModules, test, establishDependencyToAtrium]) { + command = "jasmine" args = [compileTestKotlin2Js.outputFile] } check.dependsOn runJasmine @@ -154,8 +146,8 @@ task establishDependencyFromCurrentToAtrium(dependsOn: [compileTestKotlin2Js]) { srcFile.write(newContent, 'UTF-8') } } -task runJasmineForCurrent(type: NodeTask, group: 'Verification', dependsOn: [compileCurrentKotlin2Js, populateCurrentNodeModules, installJasmine, establishDependencyFromCurrentToAtrium]) { - script = file("$nodeModulesParentDir/node_modules/jasmine/bin/jasmine") +task runJasmineForCurrent(type: NpxTask, group: 'Verification', dependsOn: [compileCurrentKotlin2Js, populateCurrentNodeModules, establishDependencyFromCurrentToAtrium]) { + command = "jasmine" args = [compileCurrentKotlin2Js.outputFile] } diff --git a/samples/js/mocha/build.gradle b/samples/js/mocha/build.gradle index 0699c5163..4830e5b7d 100644 --- a/samples/js/mocha/build.gradle +++ b/samples/js/mocha/build.gradle @@ -8,13 +8,13 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.moowork.gradle:gradle-node-plugin:1.2.0' + classpath 'com.github.node-gradle:gradle-node-plugin:2.2.0' classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71' } } apply plugin: 'kotlin2js' -apply plugin: 'com.moowork.node' +apply plugin: 'com.github.node-gradle.node' repositories { jcenter() @@ -70,14 +70,6 @@ node { nodeModulesDir = nodeModulesParentDir } -task installMocha(type: NpmTask) { - // note, without the '--prefer-offline' it works only if you are online, - // with '--prefer-offline' it works also offline if you have already as well in case you have already downloaded mocha once - args = ['install', 'mocha', '--prefer-offline'] -} - -task prepareMocha(dependsOn: [compileTestKotlin2Js, populateNodeModules, installMocha]) - //either you use this task or create a testSetup.kt in your src/test with the following content // // // adopt to the api you use @@ -94,8 +86,8 @@ task establishDependencyToAtrium(dependsOn: [compileTestKotlin2Js]) { srcFile.write(newContent, 'UTF-8') } } -task runMocha(type: NodeTask, group: 'Verification', dependsOn: [prepareMocha, test, establishDependencyToAtrium]) { - script = file("$nodeModulesParentDir/node_modules/mocha/bin/mocha") +task runMocha(type: NpxTask, group: 'Verification', dependsOn: [compileTestKotlin2Js, populateNodeModules, test, establishDependencyToAtrium]) { + command = "mocha" args = [compileTestKotlin2Js.outputFile] } check.dependsOn runMocha @@ -154,8 +146,8 @@ task establishDependencyFromCurrentToAtrium(dependsOn: [compileTestKotlin2Js]) { srcFile.write(newContent, 'UTF-8') } } -task runMochaForCurrent(type: NodeTask, group: 'Verification', dependsOn: [compileCurrentKotlin2Js, populateCurrentNodeModules, installMocha, establishDependencyFromCurrentToAtrium]) { - script = file("$nodeModulesParentDir/node_modules/mocha/bin/mocha") +task runMochaForCurrent(type: NpxTask, group: 'Verification', dependsOn: [compileCurrentKotlin2Js, populateCurrentNodeModules, establishDependencyFromCurrentToAtrium]) { + command = "mocha" args = [compileCurrentKotlin2Js.outputFile] }