1- import com.novoda.gradle.release.PublishExtension
2- import org.jetbrains.dokka.gradle.DokkaTask
31import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
4-
5- buildscript {
6- repositories {
7- mavenCentral()
8- jcenter()
9- }
10-
11- dependencies {
12- classpath(" com.novoda:bintray-release:0.9.1" )
13- }
14- }
2+ import java.lang.System.getenv
153
164plugins {
17- kotlin(" jvm" ) version " 1.3.61"
18-
5+ kotlin(" jvm" ) version " 1.4.31"
196 `maven- publish`
20- id( " org.jetbrains.dokka " ) version " 0.9.17 "
21- id(" io.gitlab.arturbosch.detekt" ).version(" 1.1.1 " )
7+ signing
8+ id(" io.gitlab.arturbosch.detekt" ).version(" 1.16.0 " )
229}
2310
24- apply (plugin = " com.novoda.bintray-release" )
25-
2611group = " br.com.guiabolso"
27- version = " 0.5.0 "
12+ version = getenv( " RELEASE_VERSION " ) ? : " local "
2813
2914repositories {
30- mavenCentral()
3115 jcenter()
16+ mavenCentral()
17+ }
18+
19+ repositories {
20+ mavenCentral()
3221}
3322
3423dependencies {
3524 // Kotlin
36- implementation(kotlin(" stdlib-jdk8" ))
3725 implementation(kotlin(" reflect" ))
3826
39-
4027 // KotlinTest
4128 testImplementation(" io.kotlintest:kotlintest-runner-junit5:3.4.2" )
4229}
@@ -49,65 +36,82 @@ tasks.withType<Test> {
4936 useJUnitPlatform()
5037}
5138
52- val sourcesJar by tasks.registering(Jar ::class ) {
53- classifier = " sources"
54- from(sourceSets.getByName(" main" ).allSource)
39+ java {
40+ toolchain {
41+ languageVersion.set(JavaLanguageVersion .of(8 ))
42+ }
5543}
5644
57- val javadocJar by tasks.registering(Jar ::class ) {
58- val javadoc = tasks[" dokka" ] as DokkaTask
59- javadoc.outputFormat = " javadoc"
60- javadoc.outputDirectory = " $buildDir /javadoc"
61- dependsOn(javadoc)
62- classifier = " javadoc"
63- from(javadoc.outputDirectory)
45+ val sourcesJar by tasks.registering(Jar ::class ) {
46+ archiveClassifier.set(" sources" )
47+ from(sourceSets.getByName(" main" ).allSource)
6448}
6549
66- detekt {
67- toolVersion = " 1.1.1"
68- input = files(" src/main/kotlin" , " src/test/kotlin" )
50+ val javadoc = tasks.named(" javadoc" )
51+ val javadocsJar by tasks.creating(Jar ::class ) {
52+ group = JavaBasePlugin .DOCUMENTATION_GROUP
53+ description = " Assembles java doc to jar"
54+ archiveClassifier.set(" javadoc" )
55+ from(javadoc)
6956}
7057
7158publishing {
59+
60+ repositories {
61+ maven {
62+ url = uri(" https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" )
63+ credentials {
64+ username = getenv(" OSSRH_USERNAME" )
65+ password = getenv(" OSSRH_PASSWORD" )
66+ }
67+ }
68+ }
69+
7270 publications {
73-
71+
7472 register(" maven" , MavenPublication ::class ) {
7573 from(components[" java" ])
7674 artifact(sourcesJar.get())
77- artifact(javadocJar.get() )
78-
75+ artifact(javadocsJar )
76+
7977 pom {
8078 name.set(" Fixed-Length-File-Handler" )
8179 description.set(" Fixed-Length-File-Handler" )
8280 url.set(" https://github.com/GuiaBolso/fixed-length-file-handler" )
83-
84-
81+
82+
8583 scm {
8684 connection.set(" scm:git:https://github.com/GuiaBolso/fixed-length-file-handler/" )
8785 developerConnection.set(" scm:git:https://github.com/GuiaBolso/" )
8886 url.set(" https://github.com/GuiaBolso/fixed-length-file-handler" )
8987 }
90-
88+
9189 licenses {
9290 license {
9391 name.set(" The Apache 2.0 License" )
9492 url.set(" https://opensource.org/licenses/Apache-2.0" )
9593 }
9694 }
95+
96+ developers {
97+ developer {
98+ id.set(" Guiabolso" )
99+ name.set(" Guiabolso" )
100+ }
101+ }
97102 }
98103 }
99104 }
100105}
101106
102- configure<PublishExtension > {
103- artifactId = " fixed-length-file-handler"
104- autoPublish = true
105- desc = " Fixed Length File Handler"
106- groupId = " br.com.guiabolso"
107- userOrg = " gb-opensource"
108- setLicences(" APACHE-2.0" )
109- publishVersion = version.toString()
110- uploadName = " Fixed-Length-File-Handler"
111- website = " https://github.com/GuiaBolso/fixed-length-file-handler"
112- setPublications(" maven" )
113- }
107+ signing {
108+ val signingKey: String? by project
109+ val signingPassword: String? by project
110+
111+ useGpgCmd()
112+ if (signingKey != null && signingPassword != null ) {
113+ useInMemoryPgpKeys(signingKey, signingPassword)
114+ }
115+
116+ sign((extensions.getByName(" publishing" ) as PublishingExtension ).publications)
117+ }
0 commit comments