##// END OF EJS Templates
added optional lint parameter, -Plint=true to enable all lint tasks
cin -
r94:f8676ff23eda ts-plugin
parent child
Show More
@@ -1,246 +1,256
1 1 plugins {
2 2 id "org.implab.gradle-typescript" version "1.0.1-rc3"
3 3 }
4 4
5 5 // если версия явно не заданы вычисляем ее из тэга ревизии v.{num}***
6 6 // результатом будет версия '{num}.{distance}' где distance - расстояние от
7 7 // текущей ревизии до ревизии с тэгом
8 8 def tagDistance = 0;
9 9
10 10 ext {
11 11 packageName = "@$npmScope/$name"
12 lint = project.hasProperty('lint') ? lint : false
12 13 }
13 14
14 15 if (!version) {
15 16
16 17 def rev = ["hg", "log", "-r", ".", "--template", "{latesttag('re:^v') % '{tag}-{distance}'}"].execute().text.trim();
17 18
18 19 def tagVersion;
19 20
20 21 def match = (rev =~ /^v(\d+\.\d+\.\d+).*-(\d+)$/);
21 22
22 23 if (match.size()) {
23 24 tagVersion = match[0][1];
24 25 tagDistance = match[0][2].toInteger();
25 26 } else {
26 27 throw new Exception("A version must be specied");
27 28 }
28 29
29 30 version = tagVersion;
30 31
31 32 if (tagDistance > 0)
32 33 version++;
33 34 } else {
34 35 println "explicit version: $version";
35 36 }
36 37
37 38 if (hasProperty('versionSuffix') && versionSuffix) {
38 39 version += "-$versionSuffix"
39 40 }
40 41
41 42 sources {
42 43 amd {
43 44 typings {
44 45 srcDir main.output.typingsDir
45 46 }
46 47 }
47 48
48 49 cjs {
49 50 typings {
50 51 srcDir main.output.typingsDir
51 52 }
52 53 }
53 54
54 55 testAmd {
55 56 typings {
56 57 srcDir main.output.typingsDir
57 58 srcDir amd.output.typingsDir
58 59 srcDir test.output.typingsDir
59 60 }
60 61 }
61 62
62 63 testCjs {
63 64 typings {
64 65 srcDir main.output.typingsDir
65 66 srcDir cjs.output.typingsDir
66 67 srcDir test.output.typingsDir
67 68 }
68 69 }
69 70 }
70 71
71 72 typescript {
72 73 compilerOptions {
73 74 types = []
74 75 declaration = true
75 listFiles = true
76 76 }
77 77 tscCmd = "$projectDir/node_modules/.bin/tsc"
78 78 tsLintCmd = "$projectDir/node_modules/.bin/tslint"
79 79 esLintCmd = "$projectDir/node_modules/.bin/eslint"
80 80 npmCmd = "npm"
81 81 }
82 82
83 tasks.matching{ it.name =~ /^configureTs/ }.configureEach {
84 dependsOn "prepare"
85 }
86
87 tasks.matching{ it.name =~ /^lint/ }.configureEach {
88 onlyIf { lint }
89 }
90
83 91 task prepare {
84 92
85 93 }
86 94
87 95 task printVersion {
88 96 dependsOn prepare
89 97
90 98 doLast {
91 99 println "version: ${-> version}";
92 100 println "tagDistance: ${-> tagDistance}";
93 101 println "packageName: ${-> packageName}";
94 102 println "target: ${-> typescript.compilerOptions.target}";
95 103 println "module: ${-> typescript.compilerOptions.module}";
96 104 }
97 105 }
98 106
99 107 task clean {
108 prepare.mustRunAfter it
109
100 110 doLast {
101 111 delete buildDir
102 112 }
103 113 }
104 114
105 115 npmPackMeta {
106 116 meta {
107 117 name = packageName
108 118 }
109 119 }
110 120
111 121 configureTsCjs {
112 122 dependsOn sources.main.output
113 123 compilerOptions {
114 124 types += [ "node" ]
115 125 }
116 126 }
117 127
118 128 configureTsAmd {
119 129 dependsOn sources.main.output
120 130 compilerOptions {
121 131 types += [ "requirejs", "dojo-typings" ]
122 132 }
123 133 }
124 134
125 135 test {
126 136 workingDir layout.buildDirectory.dir("test");
127 137 commandLine "node", "tests/index.js"
128 138 }
129 139
130 140 task assembleAmd {
131 141 dependsOn sources.amd.output
132 142 assemble.mustRunAfter it
133 143
134 144 doLast {
135 145 assemble {
136 146 from(sources.amd.output.compiledDir)
137 147 }
138 148 }
139 149 }
140 150
141 151 task assembleCjs {
142 152 dependsOn sources.cjs.output
143 153 assemble.mustRunAfter it
144 154
145 155 doLast {
146 156 assemble {
147 157 from(sources.cjs.output.compiledDir)
148 158 }
149 159 }
150 160 }
151 161
152 162 task assembleTestAmd {
153 163 dependsOn sources.amd.output
154 164 dependsOn sources.testAmd.output
155 165 assembleTest.mustRunAfter it
156 166
157 167 doLast {
158 168 assembleTest {
159 169 from(sources.amd.output.compiledDir)
160 170 from(sources.testAmd.output.compiledDir)
161 171 }
162 172 }
163 173 }
164 174
165 175 task assembleTestCjs {
166 176 dependsOn sources.cjs.output
167 177 dependsOn sources.testCjs.output
168 178 assembleTest.mustRunAfter it
169 179
170 180 doLast {
171 181 assembleTest {
172 182 from(sources.cjs.output.compiledDir)
173 183 from(sources.testCjs.output.compiledDir)
174 184 }
175 185 }
176 186 }
177 187
178 188 task prepareTargetEs5 {
179 189 prepare.mustRunAfter it
180 190
181 191 doLast {
182 192 typescript {
183 193 compilerOptions {
184 194 target = "es5"
185 195 lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"]
186 196 }
187 197 }
188 198 }
189 199 }
190 200
191 201 task prepareTargetEsNext {
192 202 prepare.mustRunAfter it
193 203
194 204 doLast {
195 205 typescript {
196 206 compilerOptions {
197 207 target = "es2017"
198 208 lib = ["es2017", "dom", "scripthost"]
199 209 }
200 210 }
201 211 }
202 212 }
203 213
204 214 task prepareNode {
205 215 dependsOn prepareTargetEsNext
206 216 prepare.mustRunAfter it
207 217
208 218 doLast {
209 219 typescript {
210 220 compilerOptions {
211 221 module = "commonjs"
212 222 }
213 223 }
214 224 }
215 225 }
216 226
217 227 task prepareBrowser {
218 228 dependsOn prepareTargetEs5
219 229 prepare.mustRunAfter it
220 230
221 231 doLast {
222 232 packageName = "@$npmScope/$project.name-amd"
223 233
224 234 typescript {
225 235 compilerOptions {
226 236 module = "amd"
227 237 }
228 238 }
229 239 }
230 240 }
231 241
232 242 task assembleBrowser {
233 243 dependsOn prepareBrowser, assembleAmd, assemble
234 244 }
235 245
236 246 task assembleNode {
237 247 dependsOn prepareNode, assembleCjs, assemble
238 248 }
239 249
240 250 task testBrowser {
241 251 dependsOn prepareBrowser, assembleTestAmd, test
242 252 }
243 253
244 254 task testNode {
245 255 dependsOn prepareNode, assembleTestCjs, test
246 256 } No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now