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