diff options
Diffstat (limited to 'build.gradle')
-rw-r--r-- | build.gradle | 118 |
1 files changed, 85 insertions, 33 deletions
diff --git a/build.gradle b/build.gradle index fc703e2f..b374249a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,7 @@ buildscript { ext.kotlin_version = '1.2.20' + ext.production = (findProperty('prod') ?: 'false') == 'true' + ext.npmdeps = new File("npm.dependencies").getText() repositories { jcenter() @@ -14,13 +16,18 @@ buildscript { } } -group = 'pl.treksoft' -version = '0.0.1-SNAPSHOT' +plugins { + id "maven-publish" + id "com.jfrog.bintray" version "1.7.3" +} apply plugin: 'kotlin2js' apply plugin: 'org.jetbrains.kotlin.frontend' apply plugin: "io.gitlab.arturbosch.detekt" +group = 'pl.treksoft' +version = '0.0.1' + repositories { jcenter() maven { url = 'https://dl.bintray.com/gbaldeck/kotlin' } @@ -31,36 +38,17 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version" // for now only compile configuration is supported compile "com.github.snabbdom:snabbdom-kotlin:0.1.1" - compile "pl.treksoft:navigo-kotlin:0.0.1" - compile "pl.treksoft:jquery-kotlin:0.0.2" - compile "pl.treksoft:kotlin-observable-js:0.0.2" + compile "pl.treksoft:navigo-kotlin:0.0.2" + compile "pl.treksoft:jquery-kotlin:0.0.3" + compile "pl.treksoft:kotlin-observable-js:0.0.3" } kotlinFrontend { npm { - dependency "jquery" - dependency "bootstrap" - dependency "css-loader" - dependency "style-loader" - dependency "less" - dependency "less-loader" - dependency "imports-loader" - dependency "bootstrap-webpack" - dependency "font-awesome" - dependency("font-awesome-webpack", "0.0.5-beta.2") - dependency "file-loader" - dependency "url-loader" - dependency("awesome-bootstrap-checkbox", "0.3.7") - dependency "bootstrap-select" - dependency "ajax-bootstrap-select" - dependency "trix" - dependency "fecha" - dependency "bootstrap-datetime-picker" - dependency "bootstrap-touchspin" - dependency("snabbdom", "0.6.9") - dependency "snabbdom-virtualize" - dependency "navigo" - dependency "jquery-resizable-dom" + npmdeps.eachLine { line -> + def (name, version) = line.tokenize(" ") + dependency(name, version) + } devDependency("karma") } @@ -69,12 +57,26 @@ kotlinFrontend { contentPath = file('src/main/web') } - define "PRODUCTION", false + define "PRODUCTION", production + +} + +task cleanLibs(type: Delete) { + delete 'build/js', 'build/libs' +} +if (project.gradle.startParameter.taskNames.contains("jar")){ + compileKotlin2Js.dependsOn 'cleanLibs' } jar { duplicatesStrategy = DuplicatesStrategy.EXCLUDE + excludes = [ "package.json" ] +} + +task sourcesJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource } detekt { @@ -89,23 +91,73 @@ detekt { compileKotlin2Js { kotlinOptions.metaInfo = true kotlinOptions.outputFile = "$project.buildDir.path/js/${project.name}.js" - kotlinOptions.sourceMap = true + kotlinOptions.sourceMap = !production kotlinOptions.moduleKind = 'commonjs' } compileTestKotlin2Js { kotlinOptions.metaInfo = true kotlinOptions.outputFile = "$project.buildDir.path/js-tests/${project.name}-tests.js" - kotlinOptions.sourceMap = true + kotlinOptions.sourceMap = !production kotlinOptions.moduleKind = 'commonjs' } task copyResources(type: Copy) { - from "src/main/assets" + from "src/main/resources" into file(buildDir.path + "/js") } +task copyResourcesForTests(type: Copy) { + from "src/main/resources" + into file(buildDir.path + "/js-tests/") +} + afterEvaluate { tasks.getByName("webpack-bundle") { dependsOn(copyResources) } - tasks.getByName("webpack-run") { dependsOn(copyResources) } + tasks.getByName("webpack-run") { dependsOn(copyResources, copyResourcesForTests) } +} + +publishing { + publications { + maven(MavenPublication) { + from components.java + pom.withXml { + asNode().dependencies.'*'.findAll() { + it.artifactId.text() == 'kotlin-test-js' + }.each() { + it.scope*.value = 'test' + } + } + } + } +} + +model { + tasks.generatePomFileForMavenPublication { + destination = file("$buildDir/libs/${project.name}-${version}.pom") + } +} + +bintray { + user = findProperty('buser') + key = findProperty('bkey') + pkg { + repo = 'kotlin' + name = "${project.name}" + licenses = ['MIT'] + vcsUrl = "https://github.com/rjaros/${project.name}.git" + version { + name = "${project.version}" + desc = 'Object oriented Web UI framework for Kotlin.' + released = new Date() + } + } + filesSpec { + from "${project.buildDir}/libs/" + into "pl/treksoft/${project.name}/${project.version}" + } +} + +bintrayUpload { + dependsOn "generatePomFileForMavenPublication" } |