|
1 | | -plugins { |
2 | | - `java-library` |
3 | | - `maven-publish` |
4 | | - signing |
5 | | -} |
| 1 | +import com.vanniktech.maven.publish.JavadocJar |
| 2 | +import com.vanniktech.maven.publish.KotlinJvm |
6 | 3 |
|
7 | | -java { |
8 | | - withSourcesJar() |
| 4 | +plugins { |
| 5 | + id("com.vanniktech.maven.publish") |
9 | 6 | } |
10 | 7 |
|
11 | | -// Configure remote Maven repositories for publishing, if any. |
12 | | -if (System.getenv("PUBLISHING_ENABLED") == "true") { |
13 | | - val isRelease = project.buildVersion.get().isRelease |
14 | | - val signingKey: String? = System.getenv("SIGNING_KEY") |
15 | | - val signingPassword: String? = System.getenv("SIGNING_PASSWORD") |
16 | | - val ossrhUsername: String? = System.getenv("OSSRH_USERNAME") |
17 | | - val ossrhPassword: String? = System.getenv("OSSRH_PASSWORD") |
18 | | - val ossrhRepoUrl: String = |
19 | | - if (isRelease) "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" |
20 | | - else "https://s01.oss.sonatype.org/content/repositories/snapshots/" |
21 | | - |
22 | | - check(ossrhUsername != null && ossrhPassword != null) { |
23 | | - "Publishing is enabled but credentials for remote repository were not given." |
24 | | - } |
| 8 | +mavenPublishing { |
25 | 9 |
|
26 | | - publishing.repositories.maven { |
27 | | - url = uri(ossrhRepoUrl) |
28 | | - credentials { username = ossrhUsername; password = ossrhPassword } |
29 | | - } |
30 | | - |
31 | | - if (isRelease) { |
32 | | - check(signingKey != null && signingPassword != null) { |
33 | | - "A release build with publishing enabled requires signing key credentials." |
34 | | - } |
35 | | - signing { |
36 | | - useInMemoryPgpKeys(signingKey, signingPassword) |
37 | | - sign(publishing.publications) |
38 | | - } |
| 10 | + if(System.getenv("PUBLISHING_ENABLED") == "true") { |
| 11 | + publishToMavenCentral(automaticRelease = false) |
| 12 | + signAllPublications() |
39 | 13 | } |
40 | | -} else { |
41 | | - publishing.repositories.mavenLocal() |
42 | | -} |
43 | 14 |
|
44 | | -// Declare the maven publication for the current build version. |
45 | | -publishing.publications.create<MavenPublication>(project.name) { |
46 | | - from(components["java"]) |
47 | | - artifact(tasks.named("javadocJar")) |
| 15 | + configure( |
| 16 | + KotlinJvm( |
| 17 | + sourcesJar = true, |
| 18 | + javadocJar = JavadocJar.Dokka("dokkaGeneratePublicationHtml"), |
| 19 | + ) |
| 20 | + ) |
48 | 21 |
|
49 | | - group = "io.github.jadarma.aockt" |
50 | | - artifactId = project.name |
51 | | - version = project.buildVersion.get().toString() |
| 22 | + coordinates( |
| 23 | + groupId = "io.github.jadarma.aockt", |
| 24 | + artifactId = project.name, |
| 25 | + version = buildVersion.get().toString(), |
| 26 | + ) |
52 | 27 |
|
53 | 28 | pom { |
54 | | - name.set("Advent of Code Kotlin") |
55 | | - description.set("Helper test libraries that make implementing Advent Of Code solutions a breeze.") |
56 | | - url.set("https://jadarma.github.io/advent-of-code-kotlin") |
| 29 | + name = "Advent of Code Kotlin" |
| 30 | + description = "A simple library that makes running and testing your Kotlin solutions to Advent of Code puzzles a breeze." |
| 31 | + url = "https://jadarma.github.io/advent-of-code-kotlin" |
| 32 | + inceptionYear = "2020" |
57 | 33 |
|
58 | 34 | scm { |
59 | | - connection.set("scm:git:git://github.com/Jadarma/advent-of-code-kotlin.git") |
60 | | - developerConnection.set("scm:git:ssh://github.com/Jadarma/advent-of-code-kotlin.git") |
61 | | - url.set("https://github.com/Jadarma/advent-of-code-kotlin") |
| 35 | + url = "https://github.com/Jadarma/advent-of-code-kotlin" |
| 36 | + connection = "scm:git:git://github.com/Jadarma/advent-of-code-kotlin.git" |
| 37 | + developerConnection = "scm:git:ssh://github.com/Jadarma/advent-of-code-kotlin.git" |
62 | 38 | } |
63 | 39 |
|
64 | | - licenses { |
65 | | - license { |
66 | | - name.set("MIT License") |
67 | | - url.set("https://opensource.org/license/mit") |
68 | | - inceptionYear.set("2020") |
| 40 | + developers { |
| 41 | + developer { |
| 42 | + id = "Jadarma" |
| 43 | + name = "Dan Cîmpianu" |
| 44 | + url = "https://github.com/Jadarma" |
| 45 | + |
69 | 46 | } |
70 | 47 | } |
71 | 48 |
|
72 | | - developers { |
73 | | - developer { |
74 | | - id.set("Jadarma") |
75 | | - name.set("Dan Cîmpianu") |
76 | | - |
| 49 | + licenses { |
| 50 | + license { |
| 51 | + name = "MIT License" |
| 52 | + url = "https://opensource.org/license/mit" |
77 | 53 | } |
78 | 54 | } |
79 | 55 | } |
|
0 commit comments