From 0633db88891c046ab1638cc84288af7414506a15 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 27 Dec 2018 11:40:53 +0800 Subject: [PATCH 1/3] add publishing --- build.gradle | 16 ++++++------ gradle.properties | 2 ++ maven.publish.gradle | 58 ++++++++++++++++++++++++++++++++++++++++++++ publish.gradle | 24 ++++++++++++++++++ 4 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 maven.publish.gradle create mode 100644 publish.gradle diff --git a/build.gradle b/build.gradle index f48dc7f1f8..3ca197c8df 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,5 @@ -apply plugin: 'java' -apply plugin: "application" -apply plugin: 'kotlin' -apply plugin: 'kotlinx-serialization' +project.version = "0.8" +project.group = "com.github.insanusmokrassar" buildscript { repositories { @@ -13,9 +11,16 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" } } +apply plugin: 'java-library' +apply plugin: 'kotlin' +apply plugin: 'kotlinx-serialization' + +apply from: "publish.gradle" + repositories { mavenLocal() jcenter() @@ -35,6 +40,3 @@ dependencies { // Use JUnit test framework testImplementation 'junit:junit:4.12' } - -mainClassName = "com.github.insanusmokrassar.TelegramBotAPI.IndexKt" - diff --git a/gradle.properties b/gradle.properties index 196d42ab4d..dc6da056e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,3 +4,5 @@ kotlin_coroutines_version=1.1.0 kotlin_serialisation_runtime_version=0.9.1 joda_time_version=2.10.1 ktor_version=1.0.1 + +gradle_bintray_plugin_version=1.8.4 diff --git a/maven.publish.gradle b/maven.publish.gradle new file mode 100644 index 0000000000..93b7e35552 --- /dev/null +++ b/maven.publish.gradle @@ -0,0 +1,58 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +def pomConfig = { + licenses { + license { + name "The Apache Software License, Version 2.0" + url "http://www.apache.org/licenses/LICENSE-2.0.txt" + distribution "repo" + } + } + developers { + developer { + name "Ovsiannikov Aleksei" + email "ovsyannikov.alexey95@gmail.com" + } + } + + scm { + url "https://github.com/InsanusMokrassar/${project.name}" + } +} + +task sourcesJar(type: Jar) { + from sourceSets.main.allSource + classifier = 'sources' +} + +task javadocJar(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +publishing { + publications { + maven(MavenPublication) { + from components.java + groupId "${project.group}" + artifactId "${project.name}" + version "${project.version}" + + artifact sourcesJar + artifact javadocJar + + pom.withXml { + def root = asNode() + root.appendNode('description', 'It is one more project which wish to be useful and full Telegram Bots API bridge for Kotlin') + root.appendNode('name', 'Telegram Bot API') + root.children().last() + pomConfig + } + } + } +} + +signing { + useGpgCmd() + sign publishing.publications.maven +} diff --git a/publish.gradle b/publish.gradle new file mode 100644 index 0000000000..7bd10a5543 --- /dev/null +++ b/publish.gradle @@ -0,0 +1,24 @@ +apply plugin: 'com.jfrog.bintray' + +bintray { + user = System.getenv('BINTRAY_USER') + key = System.getenv('BINTRAY_KEY') + pkg { + repo = 'StandardRepository' + name = "${project.name}" + vcsUrl = "https://github.com/InsanusMokrassar/${project.name}" + licenses = ['Apache-2.0'] + version { + name = "${project.version}" + released = new Date() + vcsTag = name + gpg { + sign = true + passphrase = System.getenv('SIGN_PASSPHRASE') + } + } + publications = ["maven"] + } +} + +apply from: "maven.publish.gradle" From 754cdd6b2ea985ca1ed45447eb6047a992a0f59a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 28 Dec 2018 09:39:59 +0800 Subject: [PATCH 2/3] rewrite to use built-in signing --- publish.gradle | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/publish.gradle b/publish.gradle index 7bd10a5543..d49c480bb2 100644 --- a/publish.gradle +++ b/publish.gradle @@ -1,8 +1,22 @@ apply plugin: 'com.jfrog.bintray' +ext { + projectBintrayDir = "${project.group}/".replace(".", "/") + "${project.name}/${project.version}" +} + bintray { user = System.getenv('BINTRAY_USER') 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" + } + } pkg { repo = 'StandardRepository' name = "${project.name}" @@ -12,12 +26,7 @@ bintray { name = "${project.version}" released = new Date() vcsTag = name - gpg { - sign = true - passphrase = System.getenv('SIGN_PASSPHRASE') - } } - publications = ["maven"] } } From ff32a98f40210ba1d27e7185aa740e3e549573ed Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 28 Dec 2018 10:40:24 +0800 Subject: [PATCH 3/3] add opportunity to use properties of project in user and key of bintray publication --- publish.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/publish.gradle b/publish.gradle index d49c480bb2..6e8de12578 100644 --- a/publish.gradle +++ b/publish.gradle @@ -5,8 +5,8 @@ ext { } bintray { - user = System.getenv('BINTRAY_USER') - key = System.getenv('BINTRAY_KEY') + 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"