From f4e4433b1655c5de8a6c9ce74ce7e32b4289786b Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 17 Mar 2023 18:25:47 +0000 Subject: [PATCH] Feature/gradle kts (#934) Co-authored-by: darbyjack --- build.gradle | 131 ----------------------- build.gradle.kts | 124 +++++++++++++++++++++ gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 1 - settings.gradle.kts | 1 + 5 files changed, 126 insertions(+), 133 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 346d81b..0000000 --- a/build.gradle +++ /dev/null @@ -1,131 +0,0 @@ -import org.apache.tools.ant.filters.ReplaceTokens - -plugins { - id "java" - id "maven-publish" - id "org.cadixdev.licenser" version "0.6.1" - id "com.github.johnrengelman.shadow" version "7.1.0" -} - -group "me.clip" -version "2.11.3-DEV-${System.getProperty("BUILD_NUMBER")}" - -description "An awesome placeholder provider!" - -repositories { - maven({ url = "https://oss.sonatype.org/content/repositories/snapshots/" }) - - mavenCentral() - mavenLocal() - - maven({ url = "https://repo.codemc.org/repository/maven-public/" }) - maven({ url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }) -} - -dependencies { - implementation "org.bstats:bstats-bukkit:3.0.0" - implementation "net.kyori:adventure-platform-bukkit:4.3.0" - - compileOnly "org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT" - compileOnly "org.jetbrains:annotations:23.0.0" - - testImplementation "org.openjdk.jmh:jmh-core:1.32" - testImplementation "org.openjdk.jmh:jmh-generator-annprocess:1.32" - - testImplementation "org.junit.jupiter:junit-jupiter-engine:5.8.2" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.8.1" -} - -processResources { - filter ReplaceTokens, tokens: [name: rootProject.name, version: project.version.toString(), description: project.description] -} - -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - - withJavadocJar() - withSourcesJar() -} - -tasks.withType(JavaCompile) { - options.encoding = "UTF-8" -} - -tasks.withType(Javadoc) { - failOnError false - options.addStringOption('Xdoclint:none', '-quiet') - options.addStringOption('encoding', 'UTF-8') - options.addStringOption('charSet', 'UTF-8') -} - -shadowJar { - archiveClassifier.set("") - - relocate "org.bstats", "me.clip.placeholderapi.metrics" - relocate "net.kyori", "me.clip.placeholderapi.libs.kyori" -} - -license { - include '**/*.java' - - matching('**/*.java') { - header = file('config/headers/main.txt') - } - - ext { - year = 2021 - } -} - -test { - useJUnitPlatform() -} - -configurations { - testImplementation { - extendsFrom(compileOnly) - } -} - -publishing { - repositories { - maven { - if (version.contains("-DEV")) { - url = uri("https://repo.extendedclip.com/content/repositories/dev/") - } else { - url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/") - } - - credentials { - username = System.getenv("JENKINS_USER") - password = System.getenv("JENKINS_PASS") - } - } - } - - publications { - mavenJava(MavenPublication) { - artifactId = "placeholderapi" - - from components.java - - pom.withXml { - - // some are having issues with bstats so we might need to add that to the pom as well - - asNode().appendNode("packaging", "jar") - asNode().remove(asNode().get("dependencies")) - - def dependenciesNode = asNode().appendNode("dependencies") - // jetbrains annotations - def jetbrainsAnnotations = dependenciesNode.appendNode("dependency") - jetbrainsAnnotations.appendNode("groupId", "org.jetbrains") - jetbrainsAnnotations.appendNode("artifactId", "annotations") - jetbrainsAnnotations.appendNode("version", "19.0.0") - } - } - } -} - -publish.dependsOn clean, test, jar diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..30380db --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,124 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +plugins { + `java-library` + `maven-publish` + id("com.github.hierynomus.license") version "0.16.1" + id("com.github.johnrengelman.shadow") version "8.1.0" +} + +group = "me.clip" +version = "2.11.3-DEV-${System.getProperty("BUILD_NUMBER")}" + +description = "An awesome placeholder provider!" + +repositories { + maven("https://oss.sonatype.org/content/repositories/snapshots/") + + mavenCentral() + mavenLocal() + + maven("https://repo.codemc.org/repository/maven-public/") + maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") +} + +dependencies { + implementation("org.bstats:bstats-bukkit:3.0.1") + implementation("net.kyori:adventure-platform-bukkit:4.3.0") + + compileOnly("org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT") + compileOnlyApi("org.jetbrains:annotations:23.0.0") + + testImplementation("org.openjdk.jmh:jmh-core:1.32") + testImplementation("org.openjdk.jmh:jmh-generator-annprocess:1.32") + + testImplementation("org.junit.jupiter:junit-jupiter-engine:5.8.2") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1") +} + + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + + withJavadocJar() + withSourcesJar() +} + +license { + header = rootProject.file("config/headers/main.txt") + + include("**/*.java") + mapping("java", "JAVADOC_STYLE") + + encoding = "UTF-8" + + ext { + set("year", 2021) + } +} + +val javaComponent: SoftwareComponent = components["java"] + +tasks { + processResources { + eachFile { expand("version" to project.version) } + } + + withType { + options.encoding = "UTF-8" + } + + withType { + isFailOnError = false + + with(options as StandardJavadocDocletOptions) { + addStringOption("Xdoclint:none", "-quiet") + addStringOption("encoding", "UTF-8") + addStringOption("charSet", "UTF-8") + } + } + + withType { + archiveClassifier.set("") + + relocate("org.bstats", "me.clip.placeholderapi.metrics") + relocate("net.kyori", "me.clip.placeholderapi.libs.kyori") + } + + test { + useJUnitPlatform() + } + + publishing { + publications { + create("maven") { + artifactId = "placeholderapi" + from(javaComponent) + } + } + + repositories { + maven { + if ("-DEV" in version.toString()) { + url = uri("https://repo.extendedclip.com/content/repositories/dev/") + } else { + url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/") + } + + credentials { + username = System.getenv("JENKINS_USER") + password = System.getenv("JENKINS_PASS") + } + } + } + } + + publish.get().setDependsOn(listOf(clean.get(), test.get(), jar.get())) +} + +configurations { + testImplementation { + extendsFrom(compileOnly.get()) + } +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aa991fc..e1bef7e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index c4faa33..0000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'PlaceholderAPI' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..70e18e7 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "PlaceholderAPI"