-
Notifications
You must be signed in to change notification settings - Fork 257
/
pklJavaLibrary.gradle.kts
73 lines (59 loc) · 1.96 KB
/
pklJavaLibrary.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
@file:Suppress("HttpUrlsUsage")
import org.gradle.accessors.dm.LibrariesForLibs
plugins {
`java-library`
id("pklKotlinTest")
id("com.diffplug.spotless")
}
// make sources Jar available to other subprojects
val sourcesJarConfiguration = configurations.register("sourcesJar")
// Version Catalog library symbols.
val libs = the<LibrariesForLibs>()
java {
withSourcesJar() // creates `sourcesJar` task
withJavadocJar()
toolchain {
languageVersion.set(jvmToolchainVersion)
vendor.set(jvmToolchainVendor)
}
}
tasks.withType<JavaExec>().configureEach {
javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
}
artifacts {
// make sources Jar available to other subprojects
add("sourcesJar", tasks["sourcesJar"])
}
spotless {
java {
googleJavaFormat(libs.versions.googleJavaFormat.get())
targetExclude("**/generated/**", "**/build/**")
licenseHeaderFile(rootProject.file("buildSrc/src/main/resources/license-header.star-block.txt"))
}
}
tasks.compileKotlin {
enabled = false
}
tasks.jar {
manifest {
attributes += mapOf("Automatic-Module-Name" to "org.${project.name.replace("-", ".")}")
}
}
tasks.javadoc {
classpath = sourceSets.main.get().output + sourceSets.main.get().compileClasspath
source = sourceSets.main.get().allJava
title = "${project.name} ${project.version} API"
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
}
val workAroundKotlinGradlePluginBug by tasks.registering {
doLast {
// Works around this problem, which sporadically appears and disappears in different subprojects:
// A problem was found with the configuration of task ':pkl-executor:compileJava' (type 'JavaCompile').
// > Directory '[...]/pkl/pkl-executor/build/classes/kotlin/main'
// specified for property 'compileKotlinOutputClasses' does not exist.
layout.buildDirectory.dir("classes/kotlin/main").get().asFile.mkdirs()
}
}
tasks.compileJava {
dependsOn(workAroundKotlinGradlePluginBug)
}