From fbe30d9da5a5388432a234b9c7f0c10bb837ce3e Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Sun, 21 Jul 2024 19:43:38 +0200 Subject: [PATCH] Cleanup build files Delete not needed gradle.properties and moves the universal submodule to the root project --- .github/FUNDING.yml | 2 +- README.md | 2 +- .../main/groovy/vr.base-conventions.gradle | 74 +++++++++++++++ .../main/groovy/vr.java-conventions.gradle | 89 ------------------- .../groovy/vr.platform-conventions.gradle | 7 ++ universal/build.gradle => build.gradle | 76 ++++++++-------- bukkit/build.gradle | 21 ++++- bukkit/gradle.properties | 1 - common/build.gradle | 17 +--- common/gradle.properties | 1 - fabric/build.gradle | 17 +++- fabric/gradle.properties | 1 - gradle.properties | 3 +- settings.gradle | 18 ++-- universal/gradle.properties | 1 - velocity/build.gradle | 12 ++- velocity/gradle.properties | 1 - .../viaversion/viarewind/VelocityPlugin.java | 1 - 18 files changed, 170 insertions(+), 174 deletions(-) create mode 100644 build-logic/src/main/groovy/vr.base-conventions.gradle delete mode 100644 build-logic/src/main/groovy/vr.java-conventions.gradle create mode 100644 build-logic/src/main/groovy/vr.platform-conventions.gradle rename universal/build.gradle => build.gradle (74%) delete mode 100644 bukkit/gradle.properties delete mode 100644 common/gradle.properties delete mode 100644 fabric/gradle.properties delete mode 100644 universal/gradle.properties delete mode 100644 velocity/gradle.properties diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index f4e8de368..a61575655 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,2 @@ github: FlorianMichael -custom: ['https://florianmichael.de/donate', 'https://viaversion.com/donate', 'https://creeper123123321.github.io/#donate'] +custom: ['https://florianmichael.de/donate', 'https://creeper123123321.github.io/#donate'] diff --git a/README.md b/README.md index 897ccd37e..3f1bcff16 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Other Links Building - After cloning this repository, build the project with Gradle by running `./gradlew build` and take the created jar out -of the `universal/build/libs` directory. +of the `build/libs` directory. You need JDK 17 or newer to build ViaRewind. diff --git a/build-logic/src/main/groovy/vr.base-conventions.gradle b/build-logic/src/main/groovy/vr.base-conventions.gradle new file mode 100644 index 000000000..e1751a23e --- /dev/null +++ b/build-logic/src/main/groovy/vr.base-conventions.gradle @@ -0,0 +1,74 @@ +plugins { + id "java-library" + id "maven-publish" + id "idea" +} + +repositories { + mavenCentral() + maven { + name = "ViaVersion" + url "https://repo.viaversion.com" + } +} + +base { + java.toolchain.languageVersion = JavaLanguageVersion.of(17) + compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8" + + group = rootProject.maven_group + version = rootProject.maven_version + description = rootProject.maven_description +} + +dependencies { + compileOnly "com.viaversion:viaversion:${project.viaversion_version}" + compileOnly "com.viaversion:viabackwards:${project.viabackwards_version}" +} + +publishing { + repositories { + maven { + name = "Via" + url = "https://repo.viaversion.com/" + + credentials(PasswordCredentials) + authentication { + basic(BasicAuthentication) + } + } + } + publications { + main(MavenPublication) { + artifactId = project.name + groupId = project.maven_group + version = project.maven_version + + from components.java + + pom { + name = "ViaRewind" + description = project.description + url = "https://github.com/ViaVersion/ViaRewind" + licenses { + license { + name = "GPL-3.0 License" + url = "https://github.com/ViaVersion/ViaRewind/blob/main/LICENSE" + } + } + developers { + developer { + id = "FlorianMichael" + name = "EnZaXD" + email = "florian.michael07@gmail.com" + } + } + scm { + connection = "scm:git:git://github.com/ViaVersion/ViaRewind.git" + developerConnection = "scm:git:ssh://github.com/ViaVersion/ViaRewind.git" + url = "github.com/ViaVersion/ViaRewind" + } + } + } + } +} diff --git a/build-logic/src/main/groovy/vr.java-conventions.gradle b/build-logic/src/main/groovy/vr.java-conventions.gradle deleted file mode 100644 index b1de7065a..000000000 --- a/build-logic/src/main/groovy/vr.java-conventions.gradle +++ /dev/null @@ -1,89 +0,0 @@ -plugins { - id "java-library" - id "maven-publish" -} - -repositories { - maven { - url = uri("https://repo.viaversion.com") - } - maven { - url = uri("https://repo.maven.apache.org/maven2/") - } - maven { - url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") - } - maven { - url = uri("https://oss.sonatype.org/content/repositories/snapshots") - } - maven { - url = uri("https://maven.fabricmc.net/") - } - maven { - url = uri("https://repo.spongepowered.org/repository/maven-public/") - } - maven { - url = uri("https://nexus.velocitypowered.com/repository/maven-public/") - } -} - -dependencies { - compileOnly "com.viaversion:viaversion:${project.viaversion_version}" - compileOnly "com.viaversion:viabackwards:${project.viabackwards_version}" - compileOnly "io.netty:netty-all:${project.netty_version}" - compileOnly "com.google.guava:guava:${project.guava_version}" -} - -base { - archivesName = project.maven_name - group = project.maven_group - version = project.maven_version - description = "ViaBackwards addon to allow 1.8.x and 1.7.x clients on newer server versions." -} - -java.sourceCompatibility = JavaVersion.VERSION_17 - -tasks { - // Variable replacements - processResources { - for (final def file in ["plugin.yml", "fabric.mod.json"]) { - filesMatching(file) { - expand( - "version": project.version, - "description": project.description - ) - } - } - } -} - -publishing { - repositories { - maven { - name = "Via" - url = "https://repo.viaversion.com/" - - credentials(PasswordCredentials) - authentication { - basic(BasicAuthentication) - } - } - } - publications { - main(MavenPublication) { - artifactId = project.maven_name - groupId = project.maven_group - version = project.maven_version - - from(components.java) - } - } -} - -tasks.withType(JavaCompile) { - options.encoding = 'UTF-8' -} - -tasks.withType(Javadoc) { - options.encoding = 'UTF-8' -} diff --git a/build-logic/src/main/groovy/vr.platform-conventions.gradle b/build-logic/src/main/groovy/vr.platform-conventions.gradle new file mode 100644 index 000000000..2ab5c369e --- /dev/null +++ b/build-logic/src/main/groovy/vr.platform-conventions.gradle @@ -0,0 +1,7 @@ +plugins { + id "vr.base-conventions" +} + +dependencies { + compileOnly project(":viarewind-common") +} \ No newline at end of file diff --git a/universal/build.gradle b/build.gradle similarity index 74% rename from universal/build.gradle rename to build.gradle index 508b29060..5b3b7d8ea 100644 --- a/universal/build.gradle +++ b/build.gradle @@ -1,59 +1,53 @@ plugins { - id "com.github.johnrengelman.shadow" version "8.1.1" + id "vr.base-conventions" + id "io.papermc.hangar-publish-plugin" version "0.1.2" id "com.modrinth.minotaur" version "2.+" - id "java-library" - id "maven-publish" } -dependencies { - api project(":viarewind-common") - api project(":viarewind-bukkit") - api project(":viarewind-fabric") - api project(":viarewind-velocity") +base { + archivesName = "ViaRewind" } -java { - withSourcesJar() - withJavadocJar() +configurations { + publishInclude } -shadowJar { - manifest { - attributes["paperweight-mappings-namespace"] = "mojang" - } - archiveClassifier.set("") - archiveBaseName.set("ViaRewind-" + project.maven_version) - configurations { - api - } +dependencies { + publishInclude project(":viarewind-common") + publishInclude project(":viarewind-bukkit") + publishInclude project(":viarewind-fabric") + publishInclude project(":viarewind-velocity") } -publishing { - repositories { - maven { - name = "Via" - url = "https://repo.viaversion.com/" - - credentials(PasswordCredentials) - authentication { - basic(BasicAuthentication) - } +jar { + dependsOn configurations.publishInclude + from { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + configurations.publishInclude.collect { + zipTree(it) } + } { + exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA" + } + manifest { + attributes( + "paperweight-mappings-namespace": "mojang" + ) } - publications { - shadow(MavenPublication) { publication -> - artifactId = project.maven_name - groupId = project.maven_group - version = project.maven_version + from("LICENSE") { + rename { "${it}_${project.name ?: rootProject.name}" } + } +} - from project.shadow.component(publication) +idea { + module { + ["run"].each { + excludeDirs << file("$it") } } } -build.dependsOn shadowJar - // ----------------------------------------------------- // Publishing @@ -103,7 +97,7 @@ if (!isRelease || isMainBranch) { // Only publish releases from the main branch versionNumber.set(suffixedVersion) versionName.set(suffixedVersion) changelog.set(changelogContent) - uploadFile.set(shadowJar.archiveFile) + uploadFile.set(jar.archiveFile) gameVersions.set(mcVersions) loaders.add("fabric") loaders.add("paper") @@ -127,7 +121,7 @@ if (!isRelease || isMainBranch) { // Only publish releases from the main branch apiKey = System.getenv("HANGAR_TOKEN") platforms { PAPER { - jar = shadowJar.archiveFile + jar = project.jar.archiveFile platformVersions = [property('mcVersionRange') as String] dependencies { hangar("ViaVersion") { @@ -139,7 +133,7 @@ if (!isRelease || isMainBranch) { // Only publish releases from the main branch } } VELOCITY { - jar = shadowJar.archiveFile + jar = project.jar.archiveFile platformVersions = [property("velocityVersion") as String] dependencies { hangar("ViaVersion") { diff --git a/bukkit/build.gradle b/bukkit/build.gradle index 1e8eb64b8..b820ccd26 100644 --- a/bukkit/build.gradle +++ b/bukkit/build.gradle @@ -1,9 +1,24 @@ plugins { - id "vr.java-conventions" + id "vr.platform-conventions" } -dependencies { - api project(":viarewind-common") +repositories { + maven { + name = "SpigotMC" + url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" + } + maven { + name = "SpongePowered" + url "https://repo.spongepowered.org/repository/maven-public/" + } +} +dependencies { compileOnly(annotationProcessor("org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT")) } + +processResources { + filesMatching("plugin.yml") { + expand("version": project.version, "description": project.description) + } +} \ No newline at end of file diff --git a/bukkit/gradle.properties b/bukkit/gradle.properties deleted file mode 100644 index a86c35ffd..000000000 --- a/bukkit/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -maven_name=viarewind-bukkit diff --git a/common/build.gradle b/common/build.gradle index 04e6f19cb..c009cc68a 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,28 +1,19 @@ plugins { - id "vr.java-conventions" -} + id "vr.base-conventions" -plugins { id "net.raphimc.class-token-replacer" version "1.0.0" } dependencies { + compileOnly "io.netty:netty-all:${project.netty_version}" + compileOnly "com.google.guava:guava:${project.guava_version}" } sourceSets { main { classTokenReplacer { property("\${version}", rootProject.maven_version) - property("\${impl_version}", "git-ViaRewind-${rootProject.maven_version}:${project.latestCommitHash()}") + property("\${impl_version}", "git-ViaRewind-${rootProject.maven_version}:${rootProject.latestCommitHash()}") } } } - -String latestCommitHash() { - def stdout = new ByteArrayOutputStream() - exec { - commandLine 'git', 'rev-parse', '--short', 'HEAD' - standardOutput = stdout - } - return stdout.toString().trim() -} diff --git a/common/gradle.properties b/common/gradle.properties deleted file mode 100644 index 5adf84606..000000000 --- a/common/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -maven_name=viarewind-common diff --git a/fabric/build.gradle b/fabric/build.gradle index 0f5516c46..9a957b439 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,10 +1,21 @@ plugins { - id "vr.java-conventions" + id "vr.platform-conventions" } -dependencies { - api project(":viarewind-common") +repositories { + maven { + name = "FabricMC" + url "https://maven.fabricmc.net/" + } +} +dependencies { compileOnly(annotationProcessor("net.fabricmc:fabric-loader:0.11.3")) compileOnly(annotationProcessor("org.apache.logging.log4j:log4j-api:2.17.1")) } + +processResources { + filesMatching("fabric.mod.json") { + expand("version": project.version, "description": project.description) + } +} \ No newline at end of file diff --git a/fabric/gradle.properties b/fabric/gradle.properties deleted file mode 100644 index 252dc33fb..000000000 --- a/fabric/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -maven_name=viarewind-fabric diff --git a/gradle.properties b/gradle.properties index 2232ebf6f..7f77f2805 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,8 +3,9 @@ org.gradle.jvmargs=-Xmx8G org.gradle.parallel=true # project -maven_version=4.0.2-SNAPSHOT maven_group=com.viaversion +maven_version=4.0.2-SNAPSHOT +maven_description=ViaBackwards addon to allow 1.8.x and 1.7.x clients on newer server versions. # libraries viaversion_version=5.0.2-SNAPSHOT diff --git a/settings.gradle b/settings.gradle index a0392fbaf..448237f71 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ -import java.util.function.Consumer +rootProject.name = "viarewind" includeBuild("build-logic") @@ -7,17 +7,9 @@ setupViaSubproject("bukkit") setupViaSubproject("fabric") setupViaSubproject("velocity") -setupSubproject("viarewind", project -> { - project.projectDir = file("universal") -}) - void setupViaSubproject(String name) { - setupSubproject("viarewind-" + name, project -> { - project.projectDir = file(name) - }) -} + var pName = "viarewind-" + name -void setupSubproject(String name, Consumer block) { - include name - block.accept(project(":" + name)) -} + include pName + project(":" + pName).projectDir = file(name) +} \ No newline at end of file diff --git a/universal/gradle.properties b/universal/gradle.properties deleted file mode 100644 index 52f99cb1f..000000000 --- a/universal/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -maven_name=viarewind diff --git a/velocity/build.gradle b/velocity/build.gradle index 35c2d13d8..794b5edb1 100644 --- a/velocity/build.gradle +++ b/velocity/build.gradle @@ -1,9 +1,15 @@ plugins { - id "vr.java-conventions" + id "vr.platform-conventions" } -dependencies { - api project(":viarewind-common") +repositories { + maven { + name = "VelocityPowered" + url "https://nexus.velocitypowered.com/repository/maven-public/" + } +} +dependencies { + compileOnly("com.viaversion:viaversion-velocity:5.0.0") // Needed for logger wrapper compileOnly(annotationProcessor("com.velocitypowered:velocity-api:3.1.1")) } diff --git a/velocity/gradle.properties b/velocity/gradle.properties deleted file mode 100644 index ac8d47471..000000000 --- a/velocity/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -maven_name=viarewind-velocity diff --git a/velocity/src/main/java/com/viaversion/viarewind/VelocityPlugin.java b/velocity/src/main/java/com/viaversion/viarewind/VelocityPlugin.java index 50e33907f..68e55d19e 100644 --- a/velocity/src/main/java/com/viaversion/viarewind/VelocityPlugin.java +++ b/velocity/src/main/java/com/viaversion/viarewind/VelocityPlugin.java @@ -21,7 +21,6 @@ import com.velocitypowered.api.event.PostOrder; import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; -import com.velocitypowered.api.event.proxy.ProxyReloadEvent; import com.velocitypowered.api.plugin.Dependency; import com.velocitypowered.api.plugin.Plugin; import com.velocitypowered.api.plugin.annotation.DataDirectory;