From d0b0cad94c2ac86ffe871846f22e1a031413bb2c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Apr 2020 13:12:55 +0600 Subject: [PATCH] update type of exposed library --- postssystem.exposed/build.gradle | 54 +++++++++++++------ postssystem.exposed/maven.publish.gradle | 66 ++++++++++++------------ postssystem.exposed/publish.gradle | 38 ++++++++++---- 3 files changed, 96 insertions(+), 62 deletions(-) diff --git a/postssystem.exposed/build.gradle b/postssystem.exposed/build.gradle index 211815eb..cf7c2439 100644 --- a/postssystem.exposed/build.gradle +++ b/postssystem.exposed/build.gradle @@ -1,6 +1,3 @@ -project.version = "$core_version" -project.group = "com.insanusmokrassar" - buildscript { repositories { mavenLocal() @@ -15,9 +12,13 @@ buildscript { } } -apply plugin: 'java-library' -apply plugin: 'kotlinx-serialization' -apply plugin: 'kotlin' +plugins { + id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" + id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" +} + +project.version = "$core_version" +project.group = "com.insanusmokrassar" apply from: "publish.gradle" @@ -28,18 +29,37 @@ repositories { maven { url "https://kotlin.bintray.com/kotlinx" } } -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - api "org.jetbrains.exposed:exposed-core:$exposed_version" - api "com.soywiz.korlibs.klock:klock:$klockVersion" +kotlin { + jvm() + js() - if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { - api "com.insanusmokrassar:postssystem.core:$core_version" - } else { - implementation project(":postssystem.core") + sourceSets { + commonMain { + dependencies { + implementation kotlin('stdlib') + api "org.jetbrains.exposed:exposed-core:$exposed_version" + api "com.soywiz.korlibs.klock:klock:$klockVersion" + + if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { + api "com.insanusmokrassar:postssystem.core:$core_version" + } else { + implementation project(":postssystem.core") + } + } + } + commonTest { + dependencies { + implementation kotlin('test-common') + implementation kotlin('test-annotations-common') + } + } + + jvmTest { + dependencies { + implementation kotlin('test-junit') + implementation "org.xerial:sqlite-jdbc:$test_sqlite_version" + } + } } - - testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version" - testImplementation "org.junit.jupiter:junit-jupiter-api:$test_junit_version" } diff --git a/postssystem.exposed/maven.publish.gradle b/postssystem.exposed/maven.publish.gradle index 27afe5dd..fe831bd3 100644 --- a/postssystem.exposed/maven.publish.gradle +++ b/postssystem.exposed/maven.publish.gradle @@ -1,57 +1,55 @@ apply plugin: 'maven-publish' -task sourcesJar(type: Jar) { - from sourceSets.main.allSource - classifier = 'sources' -} - -task javadocJar(type: Jar) { - from javadoc +task javadocsJar(type: Jar) { classifier = 'javadoc' } +afterEvaluate { + project.publishing.publications.all { + // rename artifacts + groupId "${project.group}" + if (it.name.contains('kotlinMultiplatform')) { + artifactId = "${project.name}" + } else { + artifactId = "${project.name}-$name" + } + } +} + publishing { - publications { - maven(MavenPublication) { - from components.java - groupId "${project.group}" - artifactId "${project.name}" - version "${project.version}" + publications.all { + artifact javadocsJar - artifact sourcesJar - artifact javadocJar + pom.withXml { + asNode().children().last() + { + resolveStrategy = Closure.DELEGATE_FIRST - pom.withXml { - asNode().children().last() + { - resolveStrategy = Closure.DELEGATE_FIRST + description "Exposed realisation for PostsSystem Core" + name "PostsSystem Core Exposed realization" + url "https://git.insanusmokrassar.com/PostsSystem/Core/" - description "Exposed realisation for PostsSystem Core" - name "PostsSystem Core Exposed realization" - url "https://git.insanusmokrassar.com/PostsSystem/Core/" - - scm { - developerConnection "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git" - url "https://git.insanusmokrassar.com/PostsSystem/Core/.git" - } - - developers { + scm { + developerConnection "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git" + url "https://git.insanusmokrassar.com/PostsSystem/Core/.git" + } + developers { + developer { id "InsanusMokrassar" name "Ovsiannikov Aleksei" email "ovsyannikov.alexey95@gmail.com" } + + } - } - - licenses { - + licenses { + license { name "Apache Software License 2.0" url "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE" } - - } + } } } diff --git a/postssystem.exposed/publish.gradle b/postssystem.exposed/publish.gradle index 21930569..b8cf4528 100644 --- a/postssystem.exposed/publish.gradle +++ b/postssystem.exposed/publish.gradle @@ -2,22 +2,28 @@ apply plugin: 'com.jfrog.bintray' apply from: "maven.publish.gradle" -ext { - projectBintrayDir = "${project.group}/".replace(".", "/") + "${project.name}/${project.version}" -} - bintray { user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') - publications = ["maven"] filesSpec { - into "$projectBintrayDir" - from("build/libs") { - include "**/*.asc" - } - from("build/publications/maven") { - rename 'pom-default.xml(.*)', "${project.name}-${project.version}.pom\$1" + from "${buildDir}/publications/" + eachFile { + String directorySubname = it.getFile().parentFile.name + if (it.getName() == "module.json") { + if (directorySubname == "kotlinMultiplatform") { + it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module") + } else { + it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module") + } + } else { + if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") { + it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom") + } else { + it.exclude() + } + } } + into "${project.group}".replace(".", "/") } pkg { repo = "InsanusMokrassar" @@ -36,4 +42,14 @@ bintray { } } +bintrayUpload.doFirst { + publications = publishing.publications.collect { + if (it.name.contains('kotlinMultiplatform')) { + null + } else { + it.name + } + } - null +} + bintrayUpload.dependsOn publishToMavenLocal \ No newline at end of file