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