##// END OF EJS Templates
working on build.gradle
cin -
r92:a4a8e6f7b095 ts-plugin
parent child
Show More
@@ -1,142 +1,194
1 1 plugins {
2 id "org.implab.gradle-typescript" version "1.0.1-rc1"
2 id "org.implab.gradle-typescript" version "1.0.1-rc2"
3 3 }
4 4
5 5 // если версия явно не заданы вычисляем ее из тэга ревизии v.{num}***
6 6 // результатом будет версия '{num}.{distance}' где distance - расстояние от
7 7 // текущей ревизии до ревизии с тэгом
8 8 def tagDistance = 0;
9 9
10 10 if (!version) {
11 11
12 12 def rev = ["hg", "log", "-r", ".", "--template", "{latesttag('re:^v') % '{tag}-{distance}'}"].execute().text.trim();
13 13
14 14 def tagVersion;
15 15
16 16 def match = (rev =~ /^v(\d+\.\d+\.\d+).*-(\d+)$/);
17 17
18 18 if (match.size()) {
19 19 tagVersion = match[0][1];
20 20 tagDistance = match[0][2].toInteger();
21 21 } else {
22 22 throw new Exception("A version must be specied");
23 23 }
24 24
25 25 version = tagVersion;
26 26
27 27 if (tagDistance > 0)
28 28 version++;
29 29 } else {
30 30 println "explicit version: $version";
31 31 }
32 32
33 33 if (hasProperty('versionSuffix') && versionSuffix) {
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 {
51 44 srcDir main.output.typingsDir
52 45 }
53 46 }
54 47
55 48 cjs {
56 49 typings {
57 50 srcDir main.output.typingsDir
58 51 }
59 52 }
60 53
61 54 testAmd {
62 55 typings {
63 56 srcDir main.output.typingsDir
64 57 srcDir amd.output.typingsDir
65 58 srcDir test.output.typingsDir
66 59 }
67 60 }
68 61
69 62 testCjs {
70 63 typings {
71 64 srcDir main.output.typingsDir
72 65 srcDir cjs.output.typingsDir
73 66 srcDir test.output.typingsDir
74 67 }
75 68 }
76 69 }
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"
93 79 esLintCmd = "$projectDir/node_modules/.bin/eslint"
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: $jstarget";
103 println "module: $jsmodule";
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
107 99 task clean {
108 100 doLast {
109 101 delete buildDir
110 102 }
111 103 }
112 104
113 105 npmPackMeta {
114 106 meta {
115 107 name = packageName
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 }
127 120 }
128 121
129 122 test {
130 123 workingDir layout.buildDirectory.dir("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
139 from(sources.main.output.compiledDir)
131 doLast {
132 assembleTest {
140 133 from(sources.amd.output.compiledDir)
141 134 from(sources.testAmd.output.compiledDir)
135 }
136 }
137 }
138
139 assembleTest {
140 mustRunAfter assembleTestAmd
141 dependsOn sources.main.output
142 from(sources.main.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
@@ -1,9 +1,7
1 1 version=
2 2 author=Implab team
3 jsmodule=amd
4 target=es5
5 3 description=Dependency injection, logging, simple and fast text template engine
6 4 license=BSD-2-Clause
7 5 repository=https://bitbucket.org/implab/implabjs-core
8 6 npmScope=implab
9 7 npmName=core-amd No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now