Roman Elizarov | 94fb2a3 | 2018-03-05 17:32:59 +0300 | [diff] [blame] | 1 | |
| 2 | apply plugin: 'com.moowork.node' |
| 3 | |
| 4 | node { |
| 5 | version = "$node_version" |
| 6 | npmVersion = "$npm_version" |
| 7 | download = true |
Roman Elizarov | f0fc770 | 2018-03-06 12:45:08 +0300 | [diff] [blame] | 8 | nodeModulesDir = file(buildDir) |
Roman Elizarov | 94fb2a3 | 2018-03-05 17:32:59 +0300 | [diff] [blame] | 9 | } |
Roman Elizarov | f0fc770 | 2018-03-06 12:45:08 +0300 | [diff] [blame] | 10 | |
| 11 | // Configures testing for JS modules |
| 12 | |
| 13 | task prepareNodePackage(type: Copy) { |
| 14 | from("npm") { |
| 15 | include 'package.json' |
Ilya Gorbunov | cc08426 | 2018-04-18 18:16:17 +0300 | [diff] [blame] | 16 | expand (project.properties + [kotlinDependency: ""]) |
Roman Elizarov | f0fc770 | 2018-03-06 12:45:08 +0300 | [diff] [blame] | 17 | } |
| 18 | from("npm") { |
| 19 | exclude 'package.json' |
| 20 | } |
| 21 | into "$node.nodeModulesDir" |
| 22 | } |
| 23 | |
| 24 | npmInstall.dependsOn prepareNodePackage |
| 25 | |
| 26 | task populateNodeModules(type: Copy, dependsOn: [compileKotlin2Js]) { |
| 27 | from compileKotlin2Js.destinationDir |
| 28 | into "$node.nodeModulesDir/node_modules" |
| 29 | |
| 30 | afterEvaluate { |
| 31 | configurations.testCompile.each { |
| 32 | if (it.absolutePath.endsWith(".jar")) { |
| 33 | from zipTree(it.absolutePath).matching { |
| 34 | include '*.js' |
| 35 | include '*.js.map' |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | npmInstall.dependsOn populateNodeModules |