##// END OF EJS Templates
org.implab.gradle-typescript -> 1.1.1
cin -
r101:73578135a36a ts-plugin
parent child
Show More
@@ -1,244 +1,244
1 1 plugins {
2 id "org.implab.gradle-typescript" version "1.1.0"
2 id "org.implab.gradle-typescript" version "1.1.1"
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 73 npm {
74 74 npmCmd = "npm"
75 75 }
76 76
77 77 tasks.matching{ it.name =~ /^lint/ }.configureEach {
78 78 onlyIf { lint }
79 79 }
80 80
81 81 if (symbols == 'local') {
82 82 tasks.matching{ it.name =~ /^configureTs/ }.configureEach {
83 83 compilerOptions {
84 84 sourceRoot = "file://" + it.rootDir
85 85 }
86 86 }
87 87 }
88 88
89 89 task printVersion {
90 90 doLast {
91 91 println "packageName: $packageName";
92 92 println "version: $version";
93 93 println "flavour: $flavour";
94 94 println "target: $typescript.compilerOptions.target";
95 95 println "module: $typescript.compilerOptions.module";
96 96 println "lint: $lint";
97 97 println "symbols: $symbols";
98 98 }
99 99 }
100 100
101 101 task clean {
102 102 doLast {
103 103 delete buildDir
104 104 }
105 105 }
106 106
107 107 npmPackMeta {
108 108 meta {
109 109 name = packageName
110 110 }
111 111 }
112 112
113 113 configureTsCjs {
114 114 dependsOn sources.main.output
115 115 compilerOptions {
116 116 types += [ "node" ]
117 117 }
118 118 }
119 119
120 120 configureTsAmd {
121 121 dependsOn sources.main.output
122 122 compilerOptions {
123 123 types += [ "requirejs", "dojo-typings" ]
124 124 }
125 125 }
126 126
127 127 test {
128 128 workingDir layout.buildDirectory.dir("test");
129 129 commandLine "node", "tests/index.js"
130 130 }
131 131
132 132 assemble {
133 133 if (flavour == 'browser') {
134 134 dependsOn sources.amd.output
135 135 from sources.amd.output.compiledDir
136 136 from sources.amd.resources
137 137 }
138 138 if (flavour == 'node') {
139 139 dependsOn sources.cjs.output
140 140 from sources.cjs.output.compiledDir
141 141 from sources.cjs.resources
142 142 }
143 143 }
144 144
145 145 assembleTest {
146 146 if (flavour == 'browser') {
147 147 dependsOn sources.amd.output, sources.testAmd.output
148 148
149 149 from sources.amd.output.compiledDir
150 150 from sources.testAmd.output.compiledDir
151 151 from sources.amd.resources
152 152 from sources.testAmd.resources
153 153 }
154 154 if (flavour == 'node') {
155 155 dependsOn sources.cjs.output, sources.testCjs.output
156 156
157 157 from sources.cjs.output.compiledDir
158 158 from sources.testCjs.output.compiledDir
159 159 from sources.cjs.resources
160 160 from sources.testCjs.resources
161 161 }
162 162 }
163 163
164 164 typings {
165 165 if (flavour == 'browser') {
166 166 dependsOn sources.amd.output
167 167 from sources.amd.output.typingsDir
168 168 }
169 169 if (flavour == 'node') {
170 170 dependsOn sources.cjs.output
171 171 from sources.cjs.output.typingsDir
172 172 }
173 173 }
174 174
175 175 task npmPackTypings(type: Copy) {
176 176 npmPackContents.dependsOn it
177 177 dependsOn sources.main.output
178 178
179 179 from sources.main.output.typingsDir
180 180
181 181 if (flavour == 'browser') {
182 182 dependsOn sources.amd.output
183 183 from sources.amd.output.typingsDir
184 184 }
185 185 if (flavour == 'node') {
186 186 dependsOn sources.cjs.output
187 187 from sources.cjs.output.typingsDir
188 188 }
189 189
190 190 into npm.packageDir
191 191 }
192 192
193 193 task npmPackSources(type: Copy) {
194 194 from sources.main.ts
195 195 if (symbols == 'pack') {
196 196 npmPackContents.dependsOn npmPackSources
197 }
197 }
198 198
199 199 if (flavour == 'browser') {
200 200 from sources.amd.ts
201 201 }
202 202 if (flavour == 'node') {
203 203 from sources.cjs.ts
204 204 }
205 205
206 206 into npm.packageDir.dir("_src")
207 207 }
208 208
209 209
210 210
211 211 task packJsTar(type: Tar) {
212 212 dependsOn assemble;
213 213
214 214 archiveBaseName = provider { packageName }
215 215
216 216 destinationDirectory = buildDir
217 217 archiveClassifier = provider { typescript.compilerOptions.module }
218 218 compression = Compression.GZIP
219 219
220 220 from(assemble.outputs)
221 221
222 222 doLast {
223 223 println archiveName;
224 224 }
225 225 }
226 226
227 227 task packTypingsTar(type: Tar) {
228 228 }
229 229
230 230 publishing {
231 231 publications {
232 232 local(IvyPublication) {
233 233 artifact(packJsTar) {
234 234 type = "js"
235 235 }
236 236 }
237 237 }
238 238
239 239 repositories {
240 240 ivy {
241 241 url "ivy-repo"
242 242 }
243 243 }
244 244 } No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now