| @@ -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 | 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 | |
| @@ -13,33 +14,6 ext { | |||
|
|
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 | } |
| @@ -104,7 +78,6 task printVersion { | |||
|
|
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}"; |
| @@ -144,73 +117,25 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 | } |
| @@ -218,21 +143,7 task prepareTargetEsNext { | |||
|
|
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 { |
| @@ -241,6 +152,8 task prepareBrowser { | |||
|
|
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 | } |
| @@ -267,19 +180,19 task npmPackSourcesAmd(type: Copy) { | |||
|
|
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 { |
General Comments 0
You need to be logged in to leave comments.
Login now
