##// END OF EJS Templates
added tasks to pack typings and sources to npm packages
cin -
r96:d4b81cc5c00f ts-plugin
parent child
Show More
@@ -1,293 +1,323
1 plugins {
1 plugins {
2 id "org.implab.gradle-typescript" version "1.0.1-rc3"
2 id "org.implab.gradle-typescript" version "1.0.1-rc3"
3 id "ivy-publish"
3 id "ivy-publish"
4 }
4 }
5
5
6 // Ссли вСрсия явно Π½Π΅ Π·Π°Π΄Π°Π½Ρ‹ вычисляСм Π΅Π΅ ΠΈΠ· тэга Ρ€Π΅Π²ΠΈΠ·ΠΈΠΈ v.{num}***
6 // Ссли вСрсия явно Π½Π΅ Π·Π°Π΄Π°Π½Ρ‹ вычисляСм Π΅Π΅ ΠΈΠ· тэга Ρ€Π΅Π²ΠΈΠ·ΠΈΠΈ v.{num}***
7 // Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ΠΎΠΌ Π±ΡƒΠ΄Π΅Ρ‚ вСрсия '{num}.{distance}' Π³Π΄Π΅ distance - расстояниС ΠΎΡ‚
7 // Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ΠΎΠΌ Π±ΡƒΠ΄Π΅Ρ‚ вСрсия '{num}.{distance}' Π³Π΄Π΅ distance - расстояниС ΠΎΡ‚
8 // Ρ‚Π΅ΠΊΡƒΡ‰Π΅ΠΉ Ρ€Π΅Π²ΠΈΠ·ΠΈΠΈ Π΄ΠΎ Ρ€Π΅Π²ΠΈΠ·ΠΈΠΈ с тэгом
8 // Ρ‚Π΅ΠΊΡƒΡ‰Π΅ΠΉ Ρ€Π΅Π²ΠΈΠ·ΠΈΠΈ Π΄ΠΎ Ρ€Π΅Π²ΠΈΠ·ΠΈΠΈ с тэгом
9 def tagDistance = 0;
9 def tagDistance = 0;
10
10
11 ext {
11 ext {
12 packageName = "@$npmScope/$name"
12 packageName = "@$npmScope/$name"
13 lint = project.hasProperty('lint') ? lint : false
13 lint = project.hasProperty('lint') ? lint : false
14 }
14 }
15
15
16 if (!version) {
16 if (!version) {
17
17
18 def rev = ["hg", "log", "-r", ".", "--template", "{latesttag('re:^v') % '{tag}-{distance}'}"].execute().text.trim();
18 def rev = ["hg", "log", "-r", ".", "--template", "{latesttag('re:^v') % '{tag}-{distance}'}"].execute().text.trim();
19
19
20 def tagVersion;
20 def tagVersion;
21
21
22 def match = (rev =~ /^v(\d+\.\d+\.\d+).*-(\d+)$/);
22 def match = (rev =~ /^v(\d+\.\d+\.\d+).*-(\d+)$/);
23
23
24 if (match.size()) {
24 if (match.size()) {
25 tagVersion = match[0][1];
25 tagVersion = match[0][1];
26 tagDistance = match[0][2].toInteger();
26 tagDistance = match[0][2].toInteger();
27 } else {
27 } else {
28 throw new Exception("A version must be specied");
28 throw new Exception("A version must be specied");
29 }
29 }
30
30
31 version = tagVersion;
31 version = tagVersion;
32
32
33 if (tagDistance > 0)
33 if (tagDistance > 0)
34 version++;
34 version++;
35 } else {
35 } else {
36 println "explicit version: $version";
36 println "explicit version: $version";
37 }
37 }
38
38
39 if (hasProperty('versionSuffix') && versionSuffix) {
39 if (hasProperty('versionSuffix') && versionSuffix) {
40 version += "-$versionSuffix"
40 version += "-$versionSuffix"
41 }
41 }
42
42
43 configurations {
43 configurations {
44
44
45 }
45 }
46
46
47 sources {
47 sources {
48 amd {
48 amd {
49 typings {
49 typings {
50 srcDir main.output.typingsDir
50 srcDir main.output.typingsDir
51 }
51 }
52 }
52 }
53
53
54 cjs {
54 cjs {
55 typings {
55 typings {
56 srcDir main.output.typingsDir
56 srcDir main.output.typingsDir
57 }
57 }
58 }
58 }
59
59
60 testAmd {
60 testAmd {
61 typings {
61 typings {
62 srcDir main.output.typingsDir
62 srcDir main.output.typingsDir
63 srcDir amd.output.typingsDir
63 srcDir amd.output.typingsDir
64 srcDir test.output.typingsDir
64 srcDir test.output.typingsDir
65 }
65 }
66 }
66 }
67
67
68 testCjs {
68 testCjs {
69 typings {
69 typings {
70 srcDir main.output.typingsDir
70 srcDir main.output.typingsDir
71 srcDir cjs.output.typingsDir
71 srcDir cjs.output.typingsDir
72 srcDir test.output.typingsDir
72 srcDir test.output.typingsDir
73 }
73 }
74 }
74 }
75 }
75 }
76
76
77 typescript {
77 typescript {
78 compilerOptions {
78 compilerOptions {
79 types = []
79 types = []
80 declaration = true
80 declaration = true
81 sourceMap = true
82 sourceRoot = "."
81 }
83 }
82 tscCmd = "$projectDir/node_modules/.bin/tsc"
84 tscCmd = "$projectDir/node_modules/.bin/tsc"
83 tsLintCmd = "$projectDir/node_modules/.bin/tslint"
85 tsLintCmd = "$projectDir/node_modules/.bin/tslint"
84 esLintCmd = "$projectDir/node_modules/.bin/eslint"
86 esLintCmd = "$projectDir/node_modules/.bin/eslint"
85 npmCmd = "npm"
87 npmCmd = "npm"
86 }
88 }
87
89
88 tasks.matching{ it.name =~ /^configureTs/ }.configureEach {
90 tasks.matching{ it.name =~ /^configureTs/ }.configureEach {
89 dependsOn "prepare"
91 dependsOn "prepare"
90 }
92 }
91
93
92 tasks.matching{ it.name =~ /^lint/ }.configureEach {
94 tasks.matching{ it.name =~ /^lint/ }.configureEach {
93 onlyIf { lint }
95 onlyIf { lint }
94 }
96 }
95
97
96 task prepare {
98 task prepare {
97
99
98 }
100 }
99
101
100 task printVersion {
102 task printVersion {
101 dependsOn prepare
103 dependsOn prepare
102
104
103 doLast {
105 doLast {
104 println "version: ${-> version}";
106 println "version: ${-> version}";
105 println "tagDistance: ${-> tagDistance}";
107 println "tagDistance: ${-> tagDistance}";
106 println "packageName: ${-> packageName}";
108 println "packageName: ${-> packageName}";
107 println "target: ${-> typescript.compilerOptions.target}";
109 println "target: ${-> typescript.compilerOptions.target}";
108 println "module: ${-> typescript.compilerOptions.module}";
110 println "module: ${-> typescript.compilerOptions.module}";
109 }
111 }
110 }
112 }
111
113
112 task clean {
114 task clean {
113 prepare.mustRunAfter it
115 prepare.mustRunAfter it
114
116
115 doLast {
117 doLast {
116 delete buildDir
118 delete buildDir
117 }
119 }
118 }
120 }
119
121
120 npmPackMeta {
122 npmPackMeta {
121 meta {
123 meta {
122 name = packageName
124 name = packageName
123 }
125 }
124 }
126 }
125
127
126 configureTsCjs {
128 configureTsCjs {
127 dependsOn sources.main.output
129 dependsOn sources.main.output
128 compilerOptions {
130 compilerOptions {
129 types += [ "node" ]
131 types += [ "node" ]
130 }
132 }
131 }
133 }
132
134
133 configureTsAmd {
135 configureTsAmd {
134 dependsOn sources.main.output
136 dependsOn sources.main.output
135 compilerOptions {
137 compilerOptions {
136 types += [ "requirejs", "dojo-typings" ]
138 types += [ "requirejs", "dojo-typings" ]
137 }
139 }
138 }
140 }
139
141
140 test {
142 test {
141 workingDir layout.buildDirectory.dir("test");
143 workingDir layout.buildDirectory.dir("test");
142 commandLine "node", "tests/index.js"
144 commandLine "node", "tests/index.js"
143 }
145 }
144
146
145 task assembleAmd {
147 task assembleAmd {
146 dependsOn sources.amd.output
148 dependsOn sources.amd.output
147 assemble.mustRunAfter it
149 assemble.mustRunAfter it
148
150
149 doLast {
151 doLast {
150 assemble {
152 assemble {
151 from(sources.amd.output.compiledDir)
153 from(sources.amd.output.compiledDir)
152 }
154 }
153 }
155 }
154 }
156 }
155
157
156 task assembleCjs {
158 task assembleCjs {
157 dependsOn sources.cjs.output
159 dependsOn sources.cjs.output
158 assemble.mustRunAfter it
160 assemble.mustRunAfter it
159
161
160 doLast {
162 doLast {
161 assemble {
163 assemble {
162 from(sources.cjs.output.compiledDir)
164 from(sources.cjs.output.compiledDir)
163 }
165 }
164 }
166 }
165 }
167 }
166
168
167 task assembleTestAmd {
169 task assembleTestAmd {
168 dependsOn sources.amd.output
170 dependsOn sources.amd.output
169 dependsOn sources.testAmd.output
171 dependsOn sources.testAmd.output
170 assembleTest.mustRunAfter it
172 assembleTest.mustRunAfter it
171
173
172 doLast {
174 doLast {
173 assembleTest {
175 assembleTest {
174 from(sources.amd.output.compiledDir)
176 from(sources.amd.output.compiledDir)
175 from(sources.testAmd.output.compiledDir)
177 from(sources.testAmd.output.compiledDir)
176 }
178 }
177 }
179 }
178 }
180 }
179
181
180 task assembleTestCjs {
182 task assembleTestCjs {
181 dependsOn sources.cjs.output
183 dependsOn sources.cjs.output
182 dependsOn sources.testCjs.output
184 dependsOn sources.testCjs.output
183 assembleTest.mustRunAfter it
185 assembleTest.mustRunAfter it
184
186
185 doLast {
187 doLast {
186 assembleTest {
188 assembleTest {
187 from(sources.cjs.output.compiledDir)
189 from(sources.cjs.output.compiledDir)
188 from(sources.testCjs.output.compiledDir)
190 from(sources.testCjs.output.compiledDir)
189 }
191 }
190 }
192 }
191 }
193 }
192
194
193 task prepareTargetEs5 {
195 task prepareTargetEs5 {
194 prepare.mustRunAfter it
196 prepare.mustRunAfter it
195
197
196 doLast {
198 doLast {
197 typescript {
199 typescript {
198 compilerOptions {
200 compilerOptions {
199 target = "es5"
201 target = "es5"
200 lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"]
202 lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"]
201 }
203 }
202 }
204 }
203 }
205 }
204 }
206 }
205
207
206 task prepareTargetEsNext {
208 task prepareTargetEsNext {
207 prepare.mustRunAfter it
209 prepare.mustRunAfter it
208
210
209 doLast {
211 doLast {
210 typescript {
212 typescript {
211 compilerOptions {
213 compilerOptions {
212 target = "es2017"
214 target = "es2017"
213 lib = ["es2017", "dom", "scripthost"]
215 lib = ["es2017", "dom", "scripthost"]
214 }
216 }
215 }
217 }
216 }
218 }
217 }
219 }
218
220
219 task prepareNode {
221 task prepareNode {
220 dependsOn prepareTargetEsNext
222 dependsOn prepareTargetEsNext
221 prepare.mustRunAfter it
223 prepare.mustRunAfter it
222
224
223 doLast {
225 doLast {
224 typescript {
226 typescript {
225 compilerOptions {
227 compilerOptions {
226 module = "commonjs"
228 module = "commonjs"
227 }
229 }
228 }
230 }
229 }
231 }
230 }
232 }
231
233
232 task prepareBrowser {
234 task prepareBrowser {
233 dependsOn prepareTargetEs5
235 dependsOn prepareTargetEs5
234 prepare.mustRunAfter it
236 prepare.mustRunAfter it
235
237
236 doLast {
238 doLast {
237 packageName = "@$npmScope/$project.name-amd"
239 packageName = "@$npmScope/$project.name-amd"
238
240
239 typescript {
241 typescript {
240 compilerOptions {
242 compilerOptions {
241 module = "amd"
243 module = "amd"
242 }
244 }
243 }
245 }
244 }
246 }
245 }
247 }
246
248
249 task npmPackTypingsAmd(type: Copy) {
250 dependsOn sources.main.output
251 dependsOn sources.amd.output
252 npmPack.mustRunAfter it
253
254 from sources.main.output.typingsDir
255 from sources.amd.output.typingsDir
256
257 into "${->buildDir}/npm/pack"
258 }
259
260 task npmPackSourcesAmd(type: Copy) {
261 from sources.main.ts
262 from sources.amd.ts
263
264 npmPack.mustRunAfter it
265
266 into "${->buildDir}/npm/pack"
267 }
268
247 task assembleBrowser {
269 task assembleBrowser {
248 dependsOn prepareBrowser, assembleAmd, assemble
270 dependsOn prepareBrowser, assembleAmd, assemble
249 }
271 }
250
272
251 task assembleNode {
273 task assembleNode {
252 dependsOn prepareNode, assembleCjs, assemble
274 dependsOn prepareNode, assembleCjs, assemble
253 }
275 }
254
276
255 task testBrowser {
277 task testBrowser {
256 dependsOn prepareBrowser, assembleTestAmd, test
278 dependsOn prepareBrowser, assembleTestAmd, test
257 }
279 }
258
280
259 task testNode {
281 task testNode {
260 dependsOn prepareNode, assembleTestCjs, test
282 dependsOn prepareNode, assembleTestCjs, test
261 }
283 }
262
284
285 task npmPackBrowser {
286 dependsOn assembleBrowser, npmPack, npmPackSourcesAmd, npmPackTypingsAmd
287 }
288
289
263 task packJsTar(type: Tar) {
290 task packJsTar(type: Tar) {
264 dependsOn assemble;
291 dependsOn assemble;
265
292
266 archiveBaseName = provider { packageName }
293 archiveBaseName = provider { packageName }
267
294
268 destinationDirectory = buildDir
295 destinationDirectory = buildDir
269 archiveClassifier = provider { typescript.compilerOptions.module }
296 archiveClassifier = provider { typescript.compilerOptions.module }
270 compression = Compression.GZIP
297 compression = Compression.GZIP
271
298
272 from(assemble.outputs)
299 from(assemble.outputs)
273
300
274 doLast {
301 doLast {
275 println archiveName;
302 println archiveName;
276 }
303 }
277 }
304 }
278
305
306 task packTypingsTar(type: Tar) {
307 }
308
279 publishing {
309 publishing {
280 publications {
310 publications {
281 local(IvyPublication) {
311 local(IvyPublication) {
282 artifact(packJsTar) {
312 artifact(packJsTar) {
283 type = "js"
313 type = "js"
284 }
314 }
285 }
315 }
286 }
316 }
287
317
288 repositories {
318 repositories {
289 ivy {
319 ivy {
290 url "ivy-repo"
320 url "ivy-repo"
291 }
321 }
292 }
322 }
293 } No newline at end of file
323 }
General Comments 0
You need to be logged in to leave comments. Login now