| @@ -1,145 +1,105 | |||
|
|
1 | 1 | plugins { |
|
|
2 |
id "org.implab.gradle-typescript" version "1.0 |
|
|
|
2 | id "org.implab.gradle-typescript" version "1.0.1-rc1" | |
|
|
3 | 3 | } |
|
|
4 | 4 | |
|
|
5 | 5 | // если версия явно не заданы вычисляем ее из тэга ревизии v.{num}*** |
|
|
6 | 6 | // результатом будет версия '{num}.{distance}' где distance - расстояние от |
|
|
7 | 7 | // текущей ревизии до ревизии с тэгом |
|
|
8 | 8 | def tagDistance = 0; |
|
|
9 | 9 | def isRelease = false; |
|
|
10 | 10 | |
|
|
11 | 11 | if (!version) { |
|
|
12 | 12 | |
|
|
13 | 13 | def rev = ["hg", "log", "-r", ".", "--template", "{latesttag('re:^v') % '{tag}-{distance}'}"].execute().text.trim(); |
|
|
14 | 14 | |
|
|
15 | 15 | def tagVersion; |
|
|
16 | 16 | |
|
|
17 | 17 | def match = (rev =~ /^v(\d+\.\d+\.\d+).*-(\d+)$/); |
|
|
18 | 18 | |
|
|
19 | 19 | if (match.size()) { |
|
|
20 | 20 | tagVersion = match[0][1]; |
|
|
21 | 21 | tagDistance = match[0][2].toInteger(); |
|
|
22 | 22 | } else { |
|
|
23 | 23 | throw new Exception("A version must be specied"); |
|
|
24 | 24 | } |
|
|
25 | 25 | |
|
|
26 | 26 | version = tagVersion; |
|
|
27 | 27 | |
|
|
28 | 28 | if (tagDistance > 0) |
|
|
29 | 29 | version++; |
|
|
30 | 30 | } else { |
|
|
31 | 31 | println "explicit version: $version"; |
|
|
32 | 32 | } |
|
|
33 | 33 | |
|
|
34 | 34 | if (hasProperty('versionSuffix') && versionSuffix) { |
|
|
35 | 35 | version += "-$versionSuffix" |
|
|
36 | 36 | } |
|
|
37 | 37 | |
|
|
38 | 38 | if(!npmName) |
|
|
39 | 39 | npmName = name; |
|
|
40 | 40 | |
|
|
41 | 41 | if (hasProperty('release')) { |
|
|
42 | 42 | isRelease = (release != 'false') |
|
|
43 | 43 | } else { |
|
|
44 | 44 | isRelease = (tagDistance == 0); |
|
|
45 | 45 | } |
|
|
46 | 46 | |
|
|
47 | 47 | if(!["amd", "commonjs", "system", "umd", "es6", "esnext"].contains(jsmodule)) |
|
|
48 | 48 | throw new Exception("Invalid jsmodule specified: $jsmodule"); |
|
|
49 | 49 | if(!["es3", "es5", "es6", "es2016", "es2017", "esnext"].contains(target)) |
|
|
50 | 50 | throw new Exception("Invalid target specified: $target") |
|
|
51 | 51 | |
|
|
52 | 52 | def targetLibs = [ |
|
|
53 | 53 | "es3" : ["es5", "es2015.promise", "es2015.symbol", "dom", "scripthost"], |
|
|
54 | 54 | "es5" : ["es5", "es2015.promise", "es2015.symbol", "dom", "scripthost"] |
|
|
55 | 55 | ]; |
|
|
56 | 56 | |
|
|
57 | 57 | ext { |
|
|
58 | 58 | packageName = "@$npmScope/$npmName" |
|
|
59 | 59 | } |
|
|
60 | 60 | |
|
|
61 | def srcDir = "$projectDir/src" | |
|
|
62 | def typingsDir = "$srcDir/typings" | |
|
|
63 | def distDir = "$buildDir/dist" | |
|
|
64 | def testDir = "$buildDir/test" | |
|
|
65 | 61 | def jstarget = target; |
|
|
66 | 62 | |
|
|
67 | 63 | sources { |
|
|
68 | 64 | |
|
|
69 | 65 | } |
|
|
70 | 66 | |
|
|
71 | 67 | typescript { |
|
|
72 | 68 | compilerOptions { |
|
|
73 | 69 | lib = targetLibs[target] ?: [target, "dom"] |
|
|
74 | 70 | target = jstarget |
|
|
75 | 71 | module = jsmodule |
|
|
76 | 72 | types = [] |
|
|
77 | 73 | } |
|
|
78 | 74 | tsLintCmd = "tslint" |
|
|
79 | 75 | esLintCmd = "eslint" |
|
|
80 | 76 | npmCmd = "npm" |
|
|
81 | 77 | } |
|
|
82 | 78 | |
|
|
83 | 79 | task printVersion { |
|
|
84 | 80 | doLast { |
|
|
85 | 81 | println "version: $version"; |
|
|
86 | 82 | println "isRelease: $isRelease, tagDistance: $tagDistance"; |
|
|
87 | 83 | println "packageName: $packageName"; |
|
|
88 | println "bundle: ${pack.outputs.files.join(',')}"; | |
|
|
89 | println "target: $target"; | |
|
|
84 | println "bundle: ${npmPack.outputs.files.join(',')}"; | |
|
|
85 | println "target: $jstarget"; | |
|
|
90 | 86 | println "module: $jsmodule"; |
|
|
91 | 87 | } |
|
|
92 | 88 | } |
|
|
93 | 89 | |
|
|
94 | 90 | task clean { |
|
|
95 | 91 | doLast { |
|
|
96 | 92 | delete buildDir |
|
|
97 | delete typingsDir | |
|
|
98 | } | |
|
|
99 | } | |
|
|
100 | ||
|
|
101 | task _initBuild { | |
|
|
102 | mustRunAfter clean | |
|
|
103 | ||
|
|
104 | def buildInfoFile = "$buildDir/platform"; | |
|
|
105 | inputs.property('target',target); | |
|
|
106 | inputs.property('jsmodule',jsmodule); | |
|
|
107 | outputs.file(buildInfoFile); | |
|
|
108 | ||
|
|
109 | doLast { | |
|
|
110 | delete buildDir | |
|
|
111 | mkdir buildDir | |
|
|
112 | ||
|
|
113 | def f = new File(buildInfoFile); | |
|
|
114 | f << "$target-$jsmodule"; | |
|
|
115 | 93 | } |
|
|
116 | 94 | } |
|
|
117 | 95 | |
|
|
118 | /* | |
|
|
119 | task _installLocalCjsDependency(dependsOn: [buildTestCjs, "_packageMeta"], type: Exec) { | |
|
|
120 | inputs.file("$distDir/package.json") | |
|
|
121 | outputs.upToDateWhen { | |
|
|
122 | new File("$testDir/$packageName").exists() | |
|
|
96 | npmPackMeta { | |
|
|
97 | meta { | |
|
|
98 | name = "@$npmScope/$npmName" | |
|
|
123 | 99 | } |
|
|
124 | ||
|
|
125 | workingDir testDir | |
|
|
126 | ||
|
|
127 | commandLine 'npm', 'install', '--no-save', '--force', distDir | |
|
|
128 | 100 | } |
|
|
129 | 101 | |
|
|
130 | task _test(dependsOn: [buildTest], type: Exec) { | |
|
|
131 | if (jsmodule == "amd") | |
|
|
132 | dependsOn buildTestAmd | |
|
|
133 | if (jsmodule == "commonjs") { | |
|
|
134 | dependsOn buildTestCjs | |
|
|
135 | dependsOn _installLocalCjsDependency | |
|
|
136 | } | |
|
|
137 | ||
|
|
138 | commandLine 'node', "$testDir/run-tests.js" | |
|
|
139 | } | |
|
|
140 | */ | |
|
|
141 | ||
|
|
142 | 102 | task markRelease(type: Exec) { |
|
|
143 | 103 | onlyIf { tagDistance > 1 } |
|
|
144 | 104 | commandLine "hg", "tag", "v$version"; |
|
|
145 | 105 | } No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now
