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