-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
155 lines (137 loc) · 4.66 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
@file:Suppress("UnstableApiUsage")
import io.gitlab.arturbosch.detekt.Detekt
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.jvm.tasks.Jar
plugins {
`maven-publish`
signing
`java-gradle-plugin`
alias(libs.plugins.dokka)
alias(libs.plugins.gitSemVer)
alias(libs.plugins.gradlePluginPublish)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.qa)
alias(libs.plugins.multiJvmTesting)
alias(libs.plugins.publishOnCentral)
alias(libs.plugins.taskTree)
}
group = "org.protelis"
repositories {
mavenCentral()
gradlePluginPortal()
}
gitSemVer {
maxVersionLength.set(20)
buildMetadataSeparator.set("-")
}
multiJvm {
jvmVersionForCompilation.set(8)
maximumSupportedJvmVersion.set(latestJavaSupportedByGradle)
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
testByDefaultWith(latestJavaSupportedByGradle)
}
}
dependencies {
implementation(gradleApi())
implementation(gradleKotlinDsl())
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))
implementation(kotlin("gradle-plugin"))
implementation(libs.kotlin.compiler)
implementation(libs.bundles.dokka)
testImplementation(gradleTestKit())
testImplementation(libs.bundles.kotlin.testing)
}
val copyKotlinVersion by tasks.registering {
val inputFile = file("gradle/libs.versions.toml")
inputs.file(inputFile)
val outputFile =
project.layout.buildDirectory.map {
it.asFile.resolve("resources/main/protelisdoc/kotlinversion")
}
outputs.file(outputFile)
doLast {
val kotlinVersion = Regex("""kotlin\s*=\s*"(\d+(\.\d+)+)"""")
val version =
inputFile.useLines { lines ->
lines
.mapNotNull {
kotlinVersion.matchEntire(it)?.groupValues?.get(1)
}.first()
}
outputFile.get().parentFile.mkdirs()
outputFile.get().writeText(version)
}
}
tasks.compileKotlin.configure { finalizedBy(copyKotlinVersion) }
tasks.withType<Detekt>().configureEach { dependsOn(copyKotlinVersion) }
tasks.withType<PluginUnderTestMetadata>().configureEach { dependsOn(copyKotlinVersion) }
tasks.withType<Test>().configureEach { dependsOn(copyKotlinVersion) }
tasks.withType<Jar>().configureEach { dependsOn(copyKotlinVersion) }
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
showStandardStreams = true
showCauses = true
showStackTraces = true
events(
*org.gradle.api.tasks.testing.logging.TestLogEvent
.values(),
)
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}
tasks.withType<Copy> {
duplicatesStrategy = DuplicatesStrategy.WARN
}
if (System.getenv("CI") == true.toString()) {
signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
}
}
val websiteUrl = "https://github.com/Protelis/Protelis-KDoc-generator"
publishOnCentral {
repoOwner = "Protelis"
projectDescription.set("A translator from documented Protelis code to compiling Kotlin interfaces")
projectLongName.set("ProtelisDoc generator")
projectUrl.set(websiteUrl)
scmConnection.set("git:[email protected]:Protelis/ProtelisDoc.git")
repository("https://maven.pkg.github.com/Protelis/${rootProject.name}".lowercase(), name = "github") {
user.set("danysk")
password.set(System.getenv("GITHUB_TOKEN"))
}
}
publishing {
publications {
withType<MavenPublication> {
pom {
developers {
developer {
name.set("Danilo Pianini")
email.set("[email protected]")
url.set("http://www.danilopianini.org/")
}
developer {
name.set("Roberto Casadei")
email.set("[email protected]")
}
}
}
}
}
}
gradlePlugin {
plugins {
website.set(websiteUrl)
vcsUrl.set("https://github.com/Protelis/ProtelisDoc.git")
create("ProtelisDoc") {
id = "org.protelis.protelisdoc"
displayName = "Protelis Documentation Engine"
description = "A plugin that translates Protelis modules to Kotlin code, then generates the function documentation via Dokka"
implementationClass = "it.unibo.protelis2kotlin.Protelis2KotlinDocPlugin"
tags.set(listOf("protelis", "documentation", "api", "dokka", "javadoc", "aggregate computing"))
}
}
}