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