generated from Kotlin/dokka-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
123 lines (105 loc) · 3.62 KB
/
build.gradle.kts
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
117
118
119
120
121
122
123
import org.gradle.api.plugins.internal.DefaultAdhocSoftwareComponent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URI
plugins {
kotlin("jvm") version "1.9.10"
id("org.jetbrains.dokka") version "1.9.10"
`maven-publish`
signing
}
group = "com.glureau"
version = "0.6.0"
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")
implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.3")
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> {
kotlinOptions.jvmTarget = "1.8"
}
dokkaHtml {
outputDirectory.set(file(dokkaOutputDir))
}
}
val javadocJar by tasks.registering(Jar::class) {
dependsOn(tasks.dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaOutputDir)
}
java {
withSourcesJar()
}
/**
* As we've multiple js files and they are loaded asynchronously by Dokka,
* we can't change the execution order. As we need to change the mermaid initialize parameters,
* we need to merge those js files automatically.
*/
task("mergeJs") {
val dir = rootDir.path + "/src/main/js"
File(rootDir.path + "/src/main/resources/dokka/dokka-mermaid.js").writeText(
File(dir + "/mermaid.min.js").readText() + "\n" +
File(dir + "/extras.js").readText()
)
}
publishing {
publications {
val htmlMermaidDokkaPlugin by creating(MavenPublication::class) {
artifactId = project.name
from(components["java"])
artifact(javadocJar.get())
pom {
name.set("Mermaid Html Dokka plugin")
description.set("Plugin to support Mermaid.js graphs from HTML renderer")
url.set("https://github.com/glureau/dokka-mermaid")
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("glureau")
name.set("Grégory Lureau")
}
}
scm {
connection.set("scm:git:git://github.com/glureau/dokka-mermaid.git")
url.set("https://github.com/glureau/dokka-mermaid/tree/master")
}
}
}
signPublicationsIfKeyPresent(htmlMermaidDokkaPlugin)
}
repositories {
maven {
url = URI("https://s01.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 signingKey: String? = System.getenv("SIGN_KEY")
val signingKeyPassphrase: String? = System.getenv("SIGN_KEY_PASSPHRASE")
if (!signingKey.isNullOrBlank()) {
extensions.configure<SigningExtension>("signing") {
useInMemoryPgpKeys(signingKey, signingKeyPassphrase)
sign(publication)
}
}
}