2020-09-20 22:42:13 +02:00
|
|
|
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
|
2021-04-10 16:52:46 +02:00
|
|
|
import org.cadixdev.gradle.licenser.LicenseExtension
|
|
|
|
import org.cadixdev.gradle.licenser.Licenser
|
2020-09-20 22:42:13 +02:00
|
|
|
|
|
|
|
plugins {
|
|
|
|
java
|
|
|
|
`java-library`
|
|
|
|
`maven-publish`
|
2021-05-12 03:00:34 +02:00
|
|
|
id("com.github.johnrengelman.shadow") version "7.0.0"
|
2021-06-18 01:22:24 +02:00
|
|
|
id("org.cadixdev.licenser") version "0.6.1"
|
2020-10-08 13:27:23 +02:00
|
|
|
id("org.ajoberstar.grgit") version "4.1.0"
|
2020-09-20 22:42:13 +02:00
|
|
|
|
|
|
|
eclipse
|
|
|
|
idea
|
|
|
|
}
|
|
|
|
|
2021-06-23 11:50:24 +02:00
|
|
|
var ver by extra("6.0.2")
|
2020-09-20 22:42:13 +02:00
|
|
|
var versuffix by extra("-SNAPSHOT")
|
|
|
|
val versionsuffix: String? by project
|
|
|
|
if (versionsuffix != null) {
|
|
|
|
versuffix = "-$versionsuffix"
|
|
|
|
}
|
|
|
|
version = ver + versuffix
|
|
|
|
|
|
|
|
allprojects {
|
|
|
|
group = "com.plotsquared"
|
|
|
|
version = rootProject.version
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
|
|
|
|
maven {
|
|
|
|
name = "Sonatype OSS"
|
|
|
|
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
|
|
|
|
}
|
|
|
|
|
|
|
|
maven {
|
|
|
|
name = "Jitpack"
|
|
|
|
url = uri("https://jitpack.io")
|
|
|
|
}
|
|
|
|
|
2021-06-08 19:36:45 +02:00
|
|
|
maven {
|
|
|
|
name = "IntellectualSites Releases Repository"
|
|
|
|
url = uri("https://mvn.intellectualsites.com/content/repositories/releases")
|
|
|
|
}
|
|
|
|
|
2020-09-20 22:42:13 +02:00
|
|
|
maven {
|
2020-12-19 17:00:13 +01:00
|
|
|
name = "IntellectualSites Snapshots Repository"
|
2020-09-20 22:42:13 +02:00
|
|
|
url = uri("https://mvn.intellectualsites.com/content/repositories/snapshots")
|
|
|
|
}
|
|
|
|
|
|
|
|
maven {
|
|
|
|
name = "EngineHub Repository"
|
|
|
|
url = uri("https://maven.enginehub.org/repo/")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
subprojects {
|
|
|
|
apply {
|
|
|
|
plugin<JavaPlugin>()
|
|
|
|
plugin<JavaLibraryPlugin>()
|
|
|
|
plugin<MavenPublishPlugin>()
|
|
|
|
plugin<ShadowPlugin>()
|
|
|
|
plugin<Licenser>()
|
|
|
|
|
|
|
|
plugin<EclipsePlugin>()
|
|
|
|
plugin<IdeaPlugin>()
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks {
|
2020-10-08 11:49:05 +02:00
|
|
|
// This is to create the target dir under the root project with all jars.
|
|
|
|
val assembleTargetDir = create<Copy>("assembleTargetDirectory") {
|
|
|
|
destinationDir = rootDir.resolve("target")
|
|
|
|
into(destinationDir)
|
|
|
|
from(withType<Jar>())
|
|
|
|
}
|
|
|
|
named("build") {
|
|
|
|
dependsOn(assembleTargetDir)
|
2020-09-20 22:42:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-02 23:26:27 +02:00
|
|
|
val javadocDir = rootDir.resolve("docs").resolve("javadoc").resolve(project.name)
|
2020-09-20 22:42:13 +02:00
|
|
|
allprojects {
|
2020-10-08 01:22:19 +02:00
|
|
|
dependencies {
|
|
|
|
// Tests
|
2021-04-04 13:30:09 +02:00
|
|
|
testImplementation("junit:junit:4.13.2")
|
2020-10-08 01:22:19 +02:00
|
|
|
}
|
|
|
|
|
2021-04-30 09:50:22 +02:00
|
|
|
plugins.withId("java") {
|
|
|
|
the<JavaPluginExtension>().toolchain {
|
2021-05-14 01:04:09 +02:00
|
|
|
languageVersion.set(JavaLanguageVersion.of(16))
|
|
|
|
vendor.set(JvmVendorSpec.ADOPTOPENJDK)
|
2021-04-30 09:50:22 +02:00
|
|
|
}
|
2020-09-20 22:42:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
configure<LicenseExtension> {
|
2021-05-17 09:31:33 +02:00
|
|
|
header(rootProject.file("HEADER.txt"))
|
2020-09-20 22:42:13 +02:00
|
|
|
include("**/*.java")
|
2021-05-14 13:36:18 +02:00
|
|
|
newLine.set(false)
|
2020-09-20 22:42:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
java {
|
|
|
|
withSourcesJar()
|
|
|
|
withJavadocJar()
|
|
|
|
}
|
|
|
|
|
2020-10-08 12:07:18 +02:00
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
create<MavenPublication>("maven") {
|
|
|
|
// This includes not only the original jar (i.e. not shadowJar),
|
|
|
|
// but also sources & javadocs due to the above java block.
|
|
|
|
from(components["java"])
|
|
|
|
|
|
|
|
pom {
|
|
|
|
licenses {
|
|
|
|
license {
|
|
|
|
name.set("GNU General Public License, Version 3.0")
|
|
|
|
url.set("https://www.gnu.org/licenses/gpl-3.0.html")
|
|
|
|
distribution.set("repo")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
developers {
|
|
|
|
developer {
|
2020-12-16 13:23:14 +01:00
|
|
|
id.set("Sauilitired")
|
2020-10-08 12:07:18 +02:00
|
|
|
name.set("Alexander Söderberg")
|
|
|
|
}
|
2020-10-08 21:25:09 +02:00
|
|
|
developer {
|
2021-04-30 09:50:22 +02:00
|
|
|
id.set("NotMyFault")
|
2020-10-08 21:25:09 +02:00
|
|
|
name.set("NotMyFault")
|
|
|
|
}
|
2020-12-05 19:50:41 +01:00
|
|
|
developer {
|
|
|
|
id.set("SirYwell")
|
|
|
|
name.set("Hannes Greule")
|
|
|
|
}
|
2020-12-14 19:09:09 +01:00
|
|
|
developer {
|
|
|
|
id.set("dordsor21")
|
|
|
|
name.set("dordsor21")
|
|
|
|
}
|
2020-10-08 12:07:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
scm {
|
|
|
|
url.set("https://github.com/IntellectualSites/PlotSquared")
|
|
|
|
connection.set("scm:https://IntellectualSites@github.com/IntellectualSites/PlotSquared.git")
|
|
|
|
developerConnection.set("scm:git://github.com/IntellectualSites/PlotSquared.git")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenLocal() // Install to own local repository
|
|
|
|
|
|
|
|
// Accept String? to not err if they're not present.
|
|
|
|
// Check that they both exist before adding the repo, such that
|
|
|
|
// `credentials` doesn't err if one is null.
|
|
|
|
// It's not pretty, but this way it can compile.
|
|
|
|
val nexusUsername: String? by project
|
|
|
|
val nexusPassword: String? by project
|
|
|
|
if (nexusUsername != null && nexusPassword != null) {
|
|
|
|
maven {
|
|
|
|
val repositoryUrl = "https://mvn.intellectualsites.com/content/repositories/releases/"
|
|
|
|
val snapshotRepositoryUrl = "https://mvn.intellectualsites.com/content/repositories/snapshots/"
|
|
|
|
url = uri(
|
2021-01-09 22:28:41 +01:00
|
|
|
if (version.toString().endsWith("-SNAPSHOT")) snapshotRepositoryUrl
|
|
|
|
else repositoryUrl
|
2020-10-08 12:07:18 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
credentials {
|
|
|
|
username = nexusUsername
|
|
|
|
password = nexusPassword
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
logger.warn("No nexus repository is added; nexusUsername or nexusPassword is null.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-20 22:42:13 +02:00
|
|
|
tasks {
|
2020-10-08 11:49:05 +02:00
|
|
|
named<Delete>("clean") {
|
|
|
|
doFirst {
|
2020-10-08 13:27:23 +02:00
|
|
|
rootDir.resolve("target").deleteRecursively()
|
|
|
|
javadocDir.deleteRecursively()
|
2020-10-08 11:49:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-20 22:42:13 +02:00
|
|
|
compileJava {
|
|
|
|
options.compilerArgs.addAll(arrayOf("-Xmaxerrs", "1000"))
|
|
|
|
options.compilerArgs.add("-Xlint:all")
|
|
|
|
for (disabledLint in arrayOf("processing", "path", "fallthrough", "serial"))
|
|
|
|
options.compilerArgs.add("-Xlint:$disabledLint")
|
|
|
|
options.isDeprecation = true
|
|
|
|
options.encoding = "UTF-8"
|
|
|
|
}
|
|
|
|
|
|
|
|
javadoc {
|
|
|
|
val opt = options as StandardJavadocDocletOptions
|
|
|
|
opt.addStringOption("Xdoclint:none", "-quiet")
|
|
|
|
opt.tags(
|
2021-01-09 22:28:41 +01:00
|
|
|
"apiNote:a:API Note:",
|
|
|
|
"implSpec:a:Implementation Requirements:",
|
|
|
|
"implNote:a:Implementation Note:"
|
2020-09-20 22:42:13 +02:00
|
|
|
)
|
2020-10-08 11:49:05 +02:00
|
|
|
opt.destinationDirectory = javadocDir
|
2020-09-20 22:42:13 +02:00
|
|
|
}
|
|
|
|
|
2020-12-14 19:09:09 +01:00
|
|
|
jar {
|
|
|
|
this.archiveClassifier.set("jar")
|
|
|
|
}
|
|
|
|
|
2020-09-20 22:42:13 +02:00
|
|
|
shadowJar {
|
|
|
|
this.archiveClassifier.set(null as String?)
|
|
|
|
this.archiveFileName.set("${project.name}-${project.version}.${this.archiveExtension.getOrElse("jar")}")
|
|
|
|
this.destinationDirectory.set(rootProject.tasks.shadowJar.get().destinationDirectory.get())
|
|
|
|
}
|
|
|
|
|
|
|
|
named("build") {
|
|
|
|
dependsOn(named("shadowJar"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-02 23:26:27 +02:00
|
|
|
|
|
|
|
tasks {
|
|
|
|
val aggregatedJavadocs = create<Javadoc>("aggregatedJavadocs") {
|
|
|
|
title = "${project.name} ${project.version} API"
|
|
|
|
setDestinationDir(javadocDir)
|
|
|
|
options.destinationDirectory = javadocDir
|
|
|
|
|
|
|
|
doFirst {
|
|
|
|
javadocDir.deleteRecursively()
|
|
|
|
}
|
|
|
|
}.also {
|
|
|
|
it.group = "Documentation"
|
|
|
|
it.description = "Generate javadocs from all child projects as if it was a single project"
|
|
|
|
}
|
|
|
|
|
|
|
|
subprojects.forEach { subProject ->
|
|
|
|
subProject.afterEvaluate {
|
|
|
|
subProject.tasks.withType<Javadoc>().forEach { task ->
|
|
|
|
aggregatedJavadocs.source += task.source
|
|
|
|
aggregatedJavadocs.classpath += task.classpath
|
|
|
|
aggregatedJavadocs.excludes += task.excludes
|
|
|
|
aggregatedJavadocs.includes += task.includes
|
|
|
|
|
|
|
|
val rootOptions = aggregatedJavadocs.options as StandardJavadocDocletOptions
|
|
|
|
val subOptions = task.options as StandardJavadocDocletOptions
|
|
|
|
rootOptions.links(*subOptions.links.orEmpty().minus(rootOptions.links.orEmpty()).toTypedArray())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
build {
|
|
|
|
dependsOn(aggregatedJavadocs)
|
|
|
|
}
|
|
|
|
}
|