blob: ed8169adfc45f5a7849c46b5cf3bfaba46f57182 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URI
plugins {
kotlin("jvm") version "1.8.10"
id("org.jetbrains.dokka") version "1.8.10"
`maven-publish`
signing
}
group = "org.example"
version = "1.4-SNAPSHOT"
repositories {
mavenCentral()
jcenter()
}
val dokkaVersion: String by project
dependencies {
implementation(kotlin("stdlib"))
compileOnly("org.jetbrains.dokka:dokka-core:$dokkaVersion")
implementation("org.jetbrains.dokka:dokka-base:$dokkaVersion")
testImplementation(kotlin("test-junit"))
testImplementation("org.jetbrains.dokka:dokka-test-api:$dokkaVersion")
testImplementation("org.jetbrains.dokka:dokka-base-test-utils:$dokkaVersion")
}
val dokkaOutputDir = "$buildDir/dokka"
tasks {
withType<KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.JVM_1_8)
}
dokkaHtml {
outputDirectory.set(file(dokkaOutputDir))
}
}
val javadocJar by tasks.registering(Jar::class) {
dependsOn(tasks.dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaOutputDir)
}
java {
withSourcesJar()
}
publishing {
publications {
val dokkaTemplatePlugin by creating(MavenPublication::class) {
artifactId = project.name
from(components["java"])
artifact(javadocJar.get())
pom {
name.set("Dokka template plugin")
description.set("This is a plugin template for Dokka")
url.set("https://github.com/Kotlin/dokka-plugin-template/")
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("JetBrains")
name.set("JetBrains Team")
organization.set("JetBrains")
organizationUrl.set("http://www.jetbrains.com")
}
}
scm {
connection.set("scm:git:git://github.com/Kotlin/dokka-plugin-template.git")
url.set("https://github.com/Kotlin/dokka-plugin-template/tree/master")
}
}
}
signPublicationsIfKeyPresent(dokkaTemplatePlugin)
}
repositories {
maven {
url = URI("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("SONATYPE_USER")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}
}
fun Project.signPublicationsIfKeyPresent(publication: MavenPublication) {
val signingKeyId: String? = System.getenv("SIGN_KEY_ID")
val signingKey: String? = System.getenv("SIGN_KEY")
val signingKeyPassphrase: String? = System.getenv("SIGN_KEY_PASSPHRASE")
if (!signingKey.isNullOrBlank()) {
extensions.configure<SigningExtension>("signing") {
if (signingKeyId?.isNotBlank() == true) {
useInMemoryPgpKeys(signingKeyId, signingKey, signingKeyPassphrase)
} else {
useInMemoryPgpKeys(signingKey, signingKeyPassphrase)
}
sign(publication)
}
}
}
|