build.gradle
259 lines
| 5.2 KiB
| text/x-groovy
|
GroovyLexer
|
|
r87 | plugins { | |
|
|
r93 | id "org.implab.gradle-typescript" version "1.0.1-rc3" | |
|
|
r97 | id "org.implab.gradle-hg" | |
|
|
r95 | id "ivy-publish" | |
|
|
r87 | } | |
|
|
r61 | // если версия явно не заданы вычисляем ее из тэга ревизии v.{num}*** | |
| // результатом будет версия '{num}.{distance}' где distance - расстояние от | |||
| // текущей ревизии до ревизии с тэгом | |||
|
|
r68 | def tagDistance = 0; | |
|
|
r93 | ext { | |
| packageName = "@$npmScope/$name" | |||
|
|
r94 | lint = project.hasProperty('lint') ? lint : false | |
|
|
r93 | } | |
|
|
r95 | configurations { | |
| } | |||
|
|
r87 | sources { | |
|
|
r89 | amd { | |
|
|
r90 | typings { | |
| srcDir main.output.typingsDir | |||
| } | |||
|
|
r89 | } | |
| cjs { | |||
|
|
r90 | typings { | |
| srcDir main.output.typingsDir | |||
| } | |||
| } | |||
| testAmd { | |||
| typings { | |||
| srcDir main.output.typingsDir | |||
| srcDir amd.output.typingsDir | |||
| srcDir test.output.typingsDir | |||
| } | |||
| } | |||
| testCjs { | |||
| typings { | |||
| srcDir main.output.typingsDir | |||
| srcDir cjs.output.typingsDir | |||
| srcDir test.output.typingsDir | |||
| } | |||
|
|
r89 | } | |
|
|
r59 | } | |
|
|
r87 | typescript { | |
| compilerOptions { | |||
| types = [] | |||
|
|
r89 | declaration = true | |
|
|
r96 | sourceMap = true | |
|
|
r98 | sourceRoot = "_src" | |
|
|
r59 | } | |
|
|
r91 | tscCmd = "$projectDir/node_modules/.bin/tsc" | |
| tsLintCmd = "$projectDir/node_modules/.bin/tslint" | |||
| esLintCmd = "$projectDir/node_modules/.bin/eslint" | |||
|
|
r87 | npmCmd = "npm" | |
|
|
r59 | } | |
|
|
r47 | ||
|
|
r94 | tasks.matching{ it.name =~ /^configureTs/ }.configureEach { | |
| dependsOn "prepare" | |||
| } | |||
| tasks.matching{ it.name =~ /^lint/ }.configureEach { | |||
| onlyIf { lint } | |||
| } | |||
|
|
r92 | task prepare { | |
| } | |||
|
|
r47 | task printVersion { | |
|
|
r92 | dependsOn prepare | |
|
|
r48 | doLast { | |
|
|
r92 | println "version: ${-> version}"; | |
| println "packageName: ${-> packageName}"; | |||
| println "target: ${-> typescript.compilerOptions.target}"; | |||
| println "module: ${-> typescript.compilerOptions.module}"; | |||
|
|
r48 | } | |
|
|
r47 | } | |
|
|
r4 | task clean { | |
|
|
r94 | prepare.mustRunAfter it | |
|
|
r95 | ||
|
|
r4 | doLast { | |
| delete buildDir | |||
|
|
r59 | } | |
| } | |||
|
|
r88 | npmPackMeta { | |
| meta { | |||
|
|
r89 | name = packageName | |
|
|
r60 | } | |
| } | |||
|
|
r90 | ||
|
|
r92 | configureTsCjs { | |
|
|
r90 | dependsOn sources.main.output | |
|
|
r93 | compilerOptions { | |
| types += [ "node" ] | |||
| } | |||
|
|
r90 | } | |
| configureTsAmd { | |||
|
|
r92 | dependsOn sources.main.output | |
|
|
r90 | compilerOptions { | |
| types += [ "requirejs", "dojo-typings" ] | |||
| } | |||
| } | |||
|
|
r91 | test { | |
| workingDir layout.buildDirectory.dir("test"); | |||
| commandLine "node", "tests/index.js" | |||
| } | |||
|
|
r97 | assemble { | |
|
|
r98 | mustRunAfter sources.amd.output, | |
| sources.cjs.output | |||
|
|
r97 | from sources.amd.output.compiledDir | |
| from sources.cjs.output.compiledDir | |||
|
|
r93 | } | |
|
|
r97 | assembleTest { | |
|
|
r98 | mustRunAfter sources.amd.output, | |
| sources.cjs.output, | |||
| sources.testAmd.output, | |||
| sources.testCjs.output | |||
|
|
r97 | from sources.amd.output.compiledDir | |
| from sources.cjs.output.compiledDir | |||
| from sources.testAmd.output.compiledDir | |||
| from sources.testCjs.output.compiledDir | |||
|
|
r92 | } | |
|
|
r98 | task prepareLocalDebug { | |
| prepare.mustRunAfter it | |||
| doLast { | |||
| tasks.matching{ it.name =~ /^configureTs/ }.configureEach { | |||
| compilerOptions { | |||
| sourceRoot = "file://" + it.rootDir | |||
| } | |||
| } | |||
| } | |||
| } | |||
|
|
r97 | task prepareNode { | |
|
|
r93 | prepare.mustRunAfter it | |
|
|
r92 | ||
| doLast { | |||
| typescript { | |||
| compilerOptions { | |||
|
|
r97 | module = "commonjs" | |
|
|
r93 | target = "es2017" | |
| lib = ["es2017", "dom", "scripthost"] | |||
|
|
r92 | } | |
| } | |||
| } | |||
| } | |||
| task prepareBrowser { | |||
|
|
r93 | prepare.mustRunAfter it | |
|
|
r92 | doLast { | |
|
|
r93 | packageName = "@$npmScope/$project.name-amd" | |
|
|
r92 | typescript { | |
| compilerOptions { | |||
|
|
r93 | module = "amd" | |
|
|
r97 | target = "es5" | |
| lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"] | |||
|
|
r92 | } | |
| } | |||
| } | |||
| } | |||
|
|
r96 | task npmPackTypingsAmd(type: Copy) { | |
| dependsOn sources.main.output | |||
| dependsOn sources.amd.output | |||
| npmPack.mustRunAfter it | |||
| from sources.main.output.typingsDir | |||
| from sources.amd.output.typingsDir | |||
| into "${->buildDir}/npm/pack" | |||
| } | |||
| task npmPackSourcesAmd(type: Copy) { | |||
| from sources.main.ts | |||
| from sources.amd.ts | |||
| npmPack.mustRunAfter it | |||
|
|
r98 | into "${->buildDir}/npm/pack/_src" | |
|
|
r96 | } | |
|
|
r93 | task assembleBrowser { | |
|
|
r97 | dependsOn prepareBrowser, assemble, sources.amd.output | |
|
|
r93 | } | |
| task assembleNode { | |||
|
|
r97 | dependsOn prepareNode, assemble, sources.cjs.output | |
|
|
r93 | } | |
|
|
r98 | task assembleTestBrowser { | |
| dependsOn prepareBrowser, prepareLocalDebug, assembleTest, sources.amd.output, sources.testAmd.output | |||
| } | |||
|
|
r93 | task testBrowser { | |
|
|
r97 | dependsOn prepareBrowser, test, sources.amd.output, sources.testAmd.output | |
|
|
r93 | } | |
| task testNode { | |||
|
|
r97 | dependsOn prepareNode, test, sources.cjs.output, sources.testCjs.output | |
|
|
r95 | } | |
|
|
r96 | task npmPackBrowser { | |
| dependsOn assembleBrowser, npmPack, npmPackSourcesAmd, npmPackTypingsAmd | |||
| } | |||
|
|
r95 | task packJsTar(type: Tar) { | |
| dependsOn assemble; | |||
| archiveBaseName = provider { packageName } | |||
| destinationDirectory = buildDir | |||
| archiveClassifier = provider { typescript.compilerOptions.module } | |||
| compression = Compression.GZIP | |||
| from(assemble.outputs) | |||
| doLast { | |||
| println archiveName; | |||
| } | |||
| } | |||
|
|
r96 | task packTypingsTar(type: Tar) { | |
| } | |||
|
|
r95 | publishing { | |
| publications { | |||
| local(IvyPublication) { | |||
| artifact(packJsTar) { | |||
| type = "js" | |||
| } | |||
| } | |||
| } | |||
| repositories { | |||
| ivy { | |||
| url "ivy-repo" | |||
| } | |||
| } | |||
|
|
r90 | } |
