| @@ -1,244 +1,234 | |||
|
|
1 | 1 | plugins { |
|
|
2 |
id "org.implab.gradle-typescript" version "1. |
|
|
|
2 | id "org.implab.gradle-typescript" version "1.3.0" | |
|
|
3 | 3 | id "org.implab.gradle-hg" |
|
|
4 | 4 | id "ivy-publish" |
|
|
5 | 5 | } |
|
|
6 | 6 | |
|
|
7 | 7 | if (!symbols in ['local', 'pack', 'none']) |
|
|
8 | 8 | throw new Exception("The symbols property value is invalid: $symbols"); |
|
|
9 | 9 | |
|
|
10 | 10 | if (!flavour in ['browser', 'node']) |
|
|
11 | 11 | throw new Exception("The flavour property value is invalid: $flavour"); |
|
|
12 | 12 | |
|
|
13 | 13 | ext { |
|
|
14 | 14 | packageName = flavour == 'browser' ? "@$npmScope/$name-amd" : "@$npmScope/$name" |
|
|
15 | 15 | lint = project.hasProperty('lint') ? project.lint ?: true : false |
|
|
16 | 16 | } |
|
|
17 | 17 | |
|
|
18 | 18 | sources { |
|
|
19 | 19 | amd { |
|
|
20 | 20 | typings { |
|
|
21 | 21 | srcDir main.output.typingsDir |
|
|
22 | 22 | } |
|
|
23 | 23 | } |
|
|
24 | 24 | |
|
|
25 | 25 | cjs { |
|
|
26 | 26 | typings { |
|
|
27 | 27 | srcDir main.output.typingsDir |
|
|
28 | 28 | } |
|
|
29 | 29 | } |
|
|
30 | 30 | |
|
|
31 | 31 | testAmd { |
|
|
32 | 32 | typings { |
|
|
33 | 33 | srcDir main.output.typingsDir |
|
|
34 | 34 | srcDir amd.output.typingsDir |
|
|
35 | 35 | srcDir test.output.typingsDir |
|
|
36 | 36 | } |
|
|
37 | 37 | } |
|
|
38 | 38 | |
|
|
39 | 39 | testCjs { |
|
|
40 | 40 | typings { |
|
|
41 | 41 | srcDir main.output.typingsDir |
|
|
42 | 42 | srcDir cjs.output.typingsDir |
|
|
43 | 43 | srcDir test.output.typingsDir |
|
|
44 | 44 | } |
|
|
45 | 45 | } |
|
|
46 | 46 | } |
|
|
47 | 47 | |
|
|
48 | 48 | typescript { |
|
|
49 | 49 | compilerOptions { |
|
|
50 | 50 | types = [] |
|
|
51 | 51 | declaration = true |
|
|
52 | 52 | |
|
|
53 | 53 | if(symbols != 'none') { |
|
|
54 | 54 | sourceMap = true |
|
|
55 | 55 | sourceRoot = "_src" |
|
|
56 | 56 | } |
|
|
57 | 57 | |
|
|
58 | 58 | if (flavour == 'node') { |
|
|
59 | 59 | module = "commonjs" |
|
|
60 | 60 | target = "es2017" |
|
|
61 | 61 | lib = ["es2017", "dom", "scripthost"] |
|
|
62 | 62 | } else if (flavour == 'browser') { |
|
|
63 | 63 | module = "amd" |
|
|
64 | 64 | target = "es5" |
|
|
65 | 65 | lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable" ] |
|
|
66 | 66 | } |
|
|
67 | 67 | } |
|
|
68 | 68 | tscCmd = "$projectDir/node_modules/.bin/tsc" |
|
|
69 | 69 | tsLintCmd = "$projectDir/node_modules/.bin/tslint" |
|
|
70 | 70 | esLintCmd = "$projectDir/node_modules/.bin/eslint" |
|
|
71 | 71 | } |
|
|
72 | 72 | |
|
|
73 | npm { | |
|
|
74 | npmCmd = "npm" | |
|
|
75 | } | |
|
|
76 | ||
|
|
77 | 73 | tasks.matching{ it.name =~ /^lint/ }.configureEach { |
|
|
78 | 74 | onlyIf { lint } |
|
|
79 | 75 | } |
|
|
80 | 76 | |
|
|
81 | 77 | if (symbols == 'local') { |
|
|
82 | 78 | tasks.matching{ it.name =~ /^configureTs/ }.configureEach { |
|
|
83 | 79 | compilerOptions { |
|
|
84 | 80 | sourceRoot = "file://" + it.rootDir |
|
|
85 | 81 | } |
|
|
86 | 82 | } |
|
|
87 | 83 | } |
|
|
88 | 84 | |
|
|
89 | 85 | task printVersion { |
|
|
90 | 86 | doLast { |
|
|
91 | 87 | println "packageName: $packageName"; |
|
|
92 | 88 | println "version: $version"; |
|
|
93 | 89 | println "flavour: $flavour"; |
|
|
94 | 90 | println "target: $typescript.compilerOptions.target"; |
|
|
95 | 91 | println "module: $typescript.compilerOptions.module"; |
|
|
96 | 92 | println "lint: $lint"; |
|
|
97 | 93 | println "symbols: $symbols"; |
|
|
98 | 94 | } |
|
|
99 | 95 | } |
|
|
100 | 96 | |
|
|
101 | task clean { | |
|
|
102 | doLast { | |
|
|
103 | delete buildDir | |
|
|
104 | } | |
|
|
105 | } | |
|
|
106 | ||
|
|
107 | 97 | npmPackMeta { |
|
|
108 | 98 | meta { |
|
|
109 | 99 | name = packageName |
|
|
110 | 100 | } |
|
|
111 | 101 | } |
|
|
112 | 102 | |
|
|
113 | 103 | configureTsCjs { |
|
|
114 | 104 | dependsOn sources.main.output |
|
|
115 | 105 | compilerOptions { |
|
|
116 | 106 | types += [ "node" ] |
|
|
117 | 107 | } |
|
|
118 | 108 | } |
|
|
119 | 109 | |
|
|
120 | 110 | configureTsAmd { |
|
|
121 | 111 | dependsOn sources.main.output |
|
|
122 | 112 | compilerOptions { |
|
|
123 | 113 | types += [ "requirejs", "dojo-typings" ] |
|
|
124 | 114 | } |
|
|
125 | 115 | } |
|
|
126 | 116 | |
|
|
127 | 117 | test { |
|
|
128 | 118 | workingDir layout.buildDirectory.dir("test"); |
|
|
129 | 119 | commandLine "node", "tests/index.js" |
|
|
130 | 120 | } |
|
|
131 | 121 | |
|
|
132 | 122 | assemble { |
|
|
133 | 123 | if (flavour == 'browser') { |
|
|
134 | 124 | dependsOn sources.amd.output |
|
|
135 | 125 | from sources.amd.output.compiledDir |
|
|
136 | 126 | from sources.amd.resources |
|
|
137 | 127 | } |
|
|
138 | 128 | if (flavour == 'node') { |
|
|
139 | 129 | dependsOn sources.cjs.output |
|
|
140 | 130 | from sources.cjs.output.compiledDir |
|
|
141 | 131 | from sources.cjs.resources |
|
|
142 | 132 | } |
|
|
143 | 133 | } |
|
|
144 | 134 | |
|
|
145 | 135 | assembleTest { |
|
|
146 | 136 | if (flavour == 'browser') { |
|
|
147 | 137 | dependsOn sources.amd.output, sources.testAmd.output |
|
|
148 | 138 | |
|
|
149 | 139 | from sources.amd.output.compiledDir |
|
|
150 | 140 | from sources.testAmd.output.compiledDir |
|
|
151 | 141 | from sources.amd.resources |
|
|
152 | 142 | from sources.testAmd.resources |
|
|
153 | 143 | } |
|
|
154 | 144 | if (flavour == 'node') { |
|
|
155 | 145 | dependsOn sources.cjs.output, sources.testCjs.output |
|
|
156 | 146 | |
|
|
157 | 147 | from sources.cjs.output.compiledDir |
|
|
158 | 148 | from sources.testCjs.output.compiledDir |
|
|
159 | 149 | from sources.cjs.resources |
|
|
160 | 150 | from sources.testCjs.resources |
|
|
161 | 151 | } |
|
|
162 | 152 | } |
|
|
163 | 153 | |
|
|
164 | 154 | typings { |
|
|
165 | 155 | if (flavour == 'browser') { |
|
|
166 | 156 | dependsOn sources.amd.output |
|
|
167 | 157 | from sources.amd.output.typingsDir |
|
|
168 | 158 | } |
|
|
169 | 159 | if (flavour == 'node') { |
|
|
170 | 160 | dependsOn sources.cjs.output |
|
|
171 | 161 | from sources.cjs.output.typingsDir |
|
|
172 | 162 | } |
|
|
173 | 163 | } |
|
|
174 | 164 | |
|
|
175 | 165 | task npmPackTypings(type: Copy) { |
|
|
176 | 166 | npmPackContents.dependsOn it |
|
|
177 | 167 | dependsOn sources.main.output |
|
|
178 | 168 | |
|
|
179 | 169 | from sources.main.output.typingsDir |
|
|
180 | 170 | |
|
|
181 | 171 | if (flavour == 'browser') { |
|
|
182 | 172 | dependsOn sources.amd.output |
|
|
183 | 173 | from sources.amd.output.typingsDir |
|
|
184 | 174 | } |
|
|
185 | 175 | if (flavour == 'node') { |
|
|
186 | 176 | dependsOn sources.cjs.output |
|
|
187 | 177 | from sources.cjs.output.typingsDir |
|
|
188 | 178 | } |
|
|
189 | 179 | |
|
|
190 | 180 | into npm.packageDir |
|
|
191 | 181 | } |
|
|
192 | 182 | |
|
|
193 | 183 | task npmPackSources(type: Copy) { |
|
|
194 | 184 | from sources.main.ts |
|
|
195 | 185 | if (symbols == 'pack') { |
|
|
196 | 186 | npmPackContents.dependsOn npmPackSources |
|
|
197 | 187 | } |
|
|
198 | 188 | |
|
|
199 | 189 | if (flavour == 'browser') { |
|
|
200 | 190 | from sources.amd.ts |
|
|
201 | 191 | } |
|
|
202 | 192 | if (flavour == 'node') { |
|
|
203 | 193 | from sources.cjs.ts |
|
|
204 | 194 | } |
|
|
205 | 195 | |
|
|
206 | 196 | into npm.packageDir.dir("_src") |
|
|
207 | 197 | } |
|
|
208 | 198 | |
|
|
209 | 199 | |
|
|
210 | 200 | |
|
|
211 | 201 | task packJsTar(type: Tar) { |
|
|
212 | 202 | dependsOn assemble; |
|
|
213 | 203 | |
|
|
214 | 204 | archiveBaseName = provider { packageName } |
|
|
215 | 205 | |
|
|
216 | 206 | destinationDirectory = buildDir |
|
|
217 | 207 | archiveClassifier = provider { typescript.compilerOptions.module } |
|
|
218 | 208 | compression = Compression.GZIP |
|
|
219 | 209 | |
|
|
220 | 210 | from(assemble.outputs) |
|
|
221 | 211 | |
|
|
222 | 212 | doLast { |
|
|
223 | 213 | println archiveName; |
|
|
224 | 214 | } |
|
|
225 | 215 | } |
|
|
226 | 216 | |
|
|
227 | 217 | task packTypingsTar(type: Tar) { |
|
|
228 | 218 | } |
|
|
229 | 219 | |
|
|
230 | 220 | publishing { |
|
|
231 | 221 | publications { |
|
|
232 | 222 | local(IvyPublication) { |
|
|
233 | 223 | artifact(packJsTar) { |
|
|
234 | 224 | type = "js" |
|
|
235 | 225 | } |
|
|
236 | 226 | } |
|
|
237 | 227 | } |
|
|
238 | 228 | |
|
|
239 | 229 | repositories { |
|
|
240 | 230 | ivy { |
|
|
241 | 231 | url "ivy-repo" |
|
|
242 | 232 | } |
|
|
243 | 233 | } |
|
|
244 | 234 | } No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now
