| @@ -1,5 +1,5 | |||
|
|
1 | 1 | plugins { |
|
|
2 |
id "org.implab.gradle-typescript" version "1.0.1-rc |
|
|
|
2 | id "org.implab.gradle-typescript" version "1.0.1-rc2" | |
|
|
3 | 3 | } |
|
|
4 | 4 | |
|
|
5 | 5 | // если версия явно не заданы вычисляем ее из тэга ревизии v.{num}*** |
| @@ -34,17 +34,10 if (hasProperty('versionSuffix') && vers | |||
|
|
34 | 34 | version += "-$versionSuffix" |
|
|
35 | 35 | } |
|
|
36 | 36 | |
|
|
37 | if(! jsmodule in ["amd", "commonjs", "system", "umd", "es6", "esnext"]) | |
|
|
38 | throw new Exception("Invalid jsmodule specified: $jsmodule"); | |
|
|
39 | if(! target in ["es3", "es5", "es6", "es2016", "es2017", "esnext"]) | |
|
|
40 | throw new Exception("Invalid target specified: $target") | |
|
|
41 | ||
|
|
42 | 37 | ext { |
|
|
43 | 38 | packageName = "@$npmScope/$npmName" |
|
|
44 | 39 | } |
|
|
45 | 40 | |
|
|
46 | def jstarget = target; | |
|
|
47 | ||
|
|
48 | 41 | sources { |
|
|
49 | 42 | amd { |
|
|
50 | 43 | typings { |
| @@ -77,16 +70,9 sources { | |||
|
|
77 | 70 | |
|
|
78 | 71 | typescript { |
|
|
79 | 72 | compilerOptions { |
|
|
80 | lib = [target, "dom", "scripthost"] | |
|
|
81 | if (jstarget in ["es5", "es3"]) | |
|
|
82 | lib += ["es2015.promise", "es2015.symbol", "es2015.iterable"] | |
|
|
83 | ||
|
|
84 | target = jstarget | |
|
|
85 | module = jsmodule | |
|
|
86 | 73 | types = [] |
|
|
87 | 74 | declaration = true |
|
|
88 | 75 | listFiles = true |
|
|
89 | ||
|
|
90 | 76 | } |
|
|
91 | 77 | tscCmd = "$projectDir/node_modules/.bin/tsc" |
|
|
92 | 78 | tsLintCmd = "$projectDir/node_modules/.bin/tslint" |
| @@ -94,13 +80,19 typescript { | |||
|
|
94 | 80 | npmCmd = "npm" |
|
|
95 | 81 | } |
|
|
96 | 82 | |
|
|
83 | task prepare { | |
|
|
84 | ||
|
|
85 | } | |
|
|
86 | ||
|
|
97 | 87 | task printVersion { |
|
|
88 | dependsOn prepare | |
|
|
89 | ||
|
|
98 | 90 | doLast { |
|
|
99 | println "version: $version"; | |
|
|
100 | println "tagDistance: $tagDistance"; | |
|
|
101 | println "packageName: $packageName"; | |
|
|
102 |
println "target: $ |
|
|
|
103 |
println "module: $ |
|
|
|
91 | println "version: ${-> version}"; | |
|
|
92 | println "tagDistance: ${-> tagDistance}"; | |
|
|
93 | println "packageName: ${-> packageName}"; | |
|
|
94 | println "target: ${-> typescript.compilerOptions.target}"; | |
|
|
95 | println "module: ${-> typescript.compilerOptions.module}"; | |
|
|
104 | 96 | } |
|
|
105 | 97 | } |
|
|
106 | 98 | |
| @@ -116,11 +108,12 npmPackMeta { | |||
|
|
116 | 108 | } |
|
|
117 | 109 | } |
|
|
118 | 110 | |
|
|
119 | compileTsAmd { | |
|
|
111 | configureTsCjs { | |
|
|
120 | 112 | dependsOn sources.main.output |
|
|
121 | 113 | } |
|
|
122 | 114 | |
|
|
123 | 115 | configureTsAmd { |
|
|
116 | dependsOn sources.main.output | |
|
|
124 | 117 | compilerOptions { |
|
|
125 | 118 | types += [ "requirejs", "dojo-typings" ] |
|
|
126 | 119 | } |
| @@ -131,12 +124,71 test { | |||
|
|
131 | 124 | commandLine "node", "tests/index.js" |
|
|
132 | 125 | } |
|
|
133 | 126 | |
|
|
134 | assembleTest { | |
|
|
135 | dependsOn sources.main.output | |
|
|
127 | task assembleTestAmd { | |
|
|
136 | 128 | dependsOn sources.amd.output |
|
|
137 | 129 | dependsOn sources.testAmd.output |
|
|
138 | ||
|
|
130 | ||
|
|
131 | doLast { | |
|
|
132 | assembleTest { | |
|
|
133 | from(sources.amd.output.compiledDir) | |
|
|
134 | from(sources.testAmd.output.compiledDir) | |
|
|
135 | } | |
|
|
136 | } | |
|
|
137 | } | |
|
|
138 | ||
|
|
139 | assembleTest { | |
|
|
140 | mustRunAfter assembleTestAmd | |
|
|
141 | dependsOn sources.main.output | |
|
|
139 | 142 | from(sources.main.output.compiledDir) |
|
|
140 | from(sources.amd.output.compiledDir) | |
|
|
141 | from(sources.testAmd.output.compiledDir) | |
|
|
143 | } | |
|
|
144 | ||
|
|
145 | ||
|
|
146 | ||
|
|
147 | task prepareTargetEs5 { | |
|
|
148 | doLast { | |
|
|
149 | typescript { | |
|
|
150 | compilerOptions { | |
|
|
151 | target = "es5" | |
|
|
152 | lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"] | |
|
|
153 | } | |
|
|
154 | } | |
|
|
155 | } | |
|
|
156 | } | |
|
|
157 | ||
|
|
158 | task prepareTargetEsNext { | |
|
|
159 | doLast { | |
|
|
160 | typescript { | |
|
|
161 | compilerOptions { | |
|
|
162 | target = "esnext" | |
|
|
163 | lib = ["esnext", "dom", "scripthost"] | |
|
|
164 | } | |
|
|
165 | } | |
|
|
166 | } | |
|
|
167 | } | |
|
|
168 | ||
|
|
169 | task prepareNode { | |
|
|
170 | dependsOn prepareTargetEsNext | |
|
|
171 | doLast { | |
|
|
172 | typescript { | |
|
|
173 | compilerOptions { | |
|
|
174 | target = "esnext" | |
|
|
175 | module = "commonjs" | |
|
|
176 | } | |
|
|
177 | } | |
|
|
178 | } | |
|
|
179 | } | |
|
|
180 | ||
|
|
181 | task prepareBrowser { | |
|
|
182 | dependsOn prepareTargetEs5 | |
|
|
183 | doLast { | |
|
|
184 | typescript { | |
|
|
185 | compilerOptions { | |
|
|
186 | module = "requirejs" | |
|
|
187 | } | |
|
|
188 | } | |
|
|
189 | } | |
|
|
190 | } | |
|
|
191 | ||
|
|
192 | prepare { | |
|
|
193 | mustRunAfter prepareNode, prepareBrowser | |
|
|
142 | 194 | } No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now
