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