This repository has been archived by the owner on Nov 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
build.gradle
131 lines (100 loc) · 2.78 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
plugins {
id("kotlin2js")
id "com.moowork.node" version "1.2.0"
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-js:$gradle.kotlinVersion")
}
def testDistribPath = "${project.buildDir}/test"
def distribPath = "${project.buildDir}/distrib"
def testNodeModulesPath = "${testDistribPath}/node_modules"
node {
download = true
version = '11.1.0'
}
task addTestPackageJson(type: Copy) {
from "${projectDir}/package.json"
into testDistribPath
}
task installTestNpmDependencies(type: NpmTask) {
dependsOn = [
nodeSetup,
addTestPackageJson,
]
args = ['install', '--prefix', testDistribPath]
}
compileKotlin2Js {
kotlinOptions {
outputFile = "${distribPath}/ts2kt.js"
sourceMap = true
metaInfo = false
freeCompilerArgs += ["-output-prefix", "${projectDir}/shebang.txt"]
moduleKind = 'commonjs'
}
}
task fetchBuildableDependencies(type: Copy) {
from "${distribPath}/ts2kt.js"
into testNodeModulesPath
}
task copyTestFiles(type: Copy) {
from "${projectDir}/test"
into testDistribPath
include "**/*.js"
}
task prepareTestDistrib {
dependsOn = [
copyTestFiles,
fetchBuildableDependencies,
installTestNpmDependencies,
]
}
task runTests(type: NodeTask) {
dependsOn = [prepareTestDistrib]
script = file("${testDistribPath}/node_modules/mocha/bin/mocha")
def reporter = project.findProperty('reporter') ?: 'mocha-simple-html-reporter'
args = [
"--reporter", reporter
]
if (reporter == 'mocha-simple-html-reporter') {
args += ["--reporter-options", "output=${project.buildDir}/report.html"]
}
def testsGrep = project.findProperty('testsGrep') ?: 'short:'
if (testsGrep != "ALL") {
args += ["--grep", testsGrep]
}
args += [
"${testDistribPath}/test_runner.js"
]
}
task prepareNpmPackage(type: Copy) {
from "package.json", "LICENSE", "npm.template/README.md"
into distribPath
}
task npmVersion(type: NpmTask) {
dependsOn = ['prepareNpmPackage']
def npmVersion = System.getProperty('kotlin.npmjs.ts2kt.version')
onlyIf {
npmVersion
}
args = ["version", '--prefix', distribPath, npmVersion]
}
task npmPublish(type: NpmTask) {
dependsOn = [npmVersion]
def token = System.getProperty("kotlin.npmjs.auth.token")
def registry = "http://registry.npmjs.org/:_authToken=${token}"
args = ["publish", distribPath, "--registry", "${registry}"]
}
task npmDeprecate(type: NpmTask) {
dependsOn = [npmVersion]
def token = System.getProperty("kotlin.npmjs.auth.token")
def registry = "http://registry.npmjs.org/:_authToken=${token}"
args = ["deprecate", "ts2kt", "ts2kt is deprecated, use dukat instead", "--registry", registry ]
}
fetchBuildableDependencies.dependsOn = [compileKotlin2Js]
test.dependsOn = [
runTests
]