FastAsyncWorldEdit/buildSrc/src/main/kotlin/PlatformConfig.kt

139 Zeilen
4.7 KiB
Kotlin

2019-08-26 06:45:03 +02:00
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.plugins.quality.CheckstyleExtension
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.api.tasks.testing.Test
import org.gradle.external.javadoc.CoreJavadocOptions
import org.gradle.external.javadoc.StandardJavadocDocletOptions
2019-08-26 06:45:03 +02:00
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.getByName
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.withType
fun Project.applyPlatformAndCoreConfiguration() {
applyCommonConfiguration()
apply(plugin = "java")
apply(plugin = "idea")
apply(plugin = "maven")
//apply(plugin = "checkstyle")
apply(plugin = "com.github.johnrengelman.shadow")
ext["internalVersion"] = "$version;${rootProject.ext["gitCommitHash"]}"
configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
// configure<CheckstyleExtension> {
// configFile = rootProject.file("config/checkstyle/checkstyle.xml")
// toolVersion = "7.6.1"
// }
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
dependencies {
"compileOnly"("org.jetbrains:annotations:19.0.0")
2019-08-26 06:45:03 +02:00
"testImplementation"("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}")
"testImplementation"("org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT}")
"testImplementation"("org.mockito:mockito-core:${Versions.MOCKITO}")
"testImplementation"("org.mockito:mockito-junit-jupiter:${Versions.MOCKITO}")
"testRuntime"("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT}")
}
// Java 8 turns on doclint which we fail
tasks.withType<Javadoc>().configureEach {
//delete("docs/javadoc")
//setDestinationDir(file("docs/javadoc"))
//title = "${project.name} ${project.version} API"
//(options as StandardJavadocDocletOptions).addStringOption("author", "true")
2019-08-26 06:45:03 +02:00
(options as CoreJavadocOptions).addStringOption("Xdoclint:none", "-quiet")
// subprojects.forEach { proj ->
// proj.tasks.withType<Javadoc>().forEach { javadocTask ->
// source += javadocTask.source
// classpath += javadocTask.classpath
// excludes += javadocTask.excludes
// includes += javadocTask.includes
// }
// }
2019-08-26 06:45:03 +02:00
}
tasks.register<Jar>("javadocJar") {
dependsOn("javadoc")
archiveClassifier.set("javadoc")
from(tasks.getByName<Javadoc>("javadoc").destinationDir)
}
tasks.named("assemble").configure {
dependsOn("javadocJar")
}
artifacts {
add("archives", tasks.named("jar"))
add("archives", tasks.named("javadocJar"))
}
if (name == "worldedit-core" || name == "worldedit-bukkit") {
tasks.register<Jar>("sourcesJar") {
dependsOn("classes")
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}
artifacts {
add("archives", tasks.named("sourcesJar"))
}
tasks.named("assemble").configure {
dependsOn("sourcesJar")
}
}
// tasks.named("check").configure {
// dependsOn("checkstyleMain", "checkstyleTest")
// }
}
fun Project.applyShadowConfiguration() {
tasks.named<ShadowJar>("shadowJar") {
// archiveClassifier.set("dist")
dependencies {
include(project(":worldedit-libs:core"))
include(project(":worldedit-libs:${project.name.replace("worldedit-", "")}"))
include(project(":worldedit-core"))
}
2019-09-14 01:54:39 +02:00
archiveFileName.set("FastAsyncWorldEdit-${project.version}.jar")
2019-08-26 06:45:03 +02:00
exclude("GradleStart**")
exclude(".cache")
exclude("LICENSE*")
exclude("META-INF/maven/**")
2019-08-26 06:45:03 +02:00
minimize()
}
}
2020-01-11 04:32:12 +01:00
private val CLASSPATH = listOf("truezip", "truevfs", "js")
.map { "$it.jar" }
.flatMap { listOf(it, "WorldEdit/$it") }
.joinToString(separator = " ")
fun Project.addJarManifest(includeClasspath: Boolean = false) {
tasks.named<Jar>("jar") {
val attributes = mutableMapOf(
"WorldEdit-Version" to project(":worldedit-core").version
)
if (includeClasspath) {
attributes["Class-Path"] = CLASSPATH
}
manifest.attributes(attributes)
}
}