Skip to content

Commit

Permalink
Setup multi project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Jul 21, 2024
1 parent 41b9eba commit 9d48917
Show file tree
Hide file tree
Showing 46 changed files with 604 additions and 84 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ hs_err_pid*
# Project files
/.idea/*
!/.idea/copyright/
/.gradle/
/build/
/out/
.gradle/
build/
out/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# ViaAprilFools
ViaVersion addon to add support for some notable Minecraft snapshots.

ViaAprilFools is not usable by itself as a standalone software, as it is an addon for ViaVersion which adds more protocol translators.
ViaAprilFools is intended to be implemented in a ViaVersion based protocol translator.
ViaAprilFools itself runs on Paper and Velocity servers and can be implemented in any other platform which supports ViaVersion.

If you are looking to implement ViaAprilFools in your own software you can start by reading the [Usage](#usage) section.
If you just want to use ViaAprilFools yourself you can check out some projects which implement it in the [Projects](#projects-implementing-viaaprilfools) section.
Expand All @@ -19,6 +18,7 @@ If you just want to use ViaAprilFools yourself you can check out some projects w
### Projects implementing ViaAprilFools
- [ViaProxy](https://github.com/ViaVersion/ViaProxy): Standalone proxy which uses ViaVersion to translate between Minecraft versions. Allows Minecraft 1.7+ clients to join to any version server.
- [ViaFabricPlus](https://github.com/ViaVersion/ViaFabricPlus): Fabric mod for the latest Minecraft version with QoL fixes and enhancements to the gameplay.
- [ViaFabric](https://github.com/ViaVersion/ViaFabric): Client-side and server-side ViaVersion implementation for Fabric

## Releases
### Gradle/Maven
Expand Down
7 changes: 7 additions & 0 deletions build-logic/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
id "groovy-gradle-plugin"
}

repositories {
gradlePluginPortal()
}
89 changes: 89 additions & 0 deletions build-logic/src/main/groovy/vaf.base-conventions.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
plugins {
id "java-library"
id "maven-publish"
id "idea"
}

repositories {
mavenCentral()
maven {
name = "ViaVersion"
url "https://repo.viaversion.com"
}
maven {
name = "SpigotMC"
url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
}
maven {
name = "SpongePowered"
url "https://repo.spongepowered.org/repository/maven-public/"
}
maven {
name = "VelocityPowered"
url "https://nexus.velocitypowered.com/repository/maven-public/"
}
}

base {
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8"

archivesName = project.name
group = rootProject.maven_group
version = rootProject.maven_version

description = "ViaVersion addon to add support for some notable Minecraft snapshots"
}

dependencies {
compileOnly "com.viaversion:viaversion-common:5.0.0"
compileOnly "com.viaversion:viabackwards-common:5.0.0"
}

publishing {
repositories {
maven {
name = "Via"
url = "https://repo.viaversion.com/"

credentials(PasswordCredentials)
authentication {
basic(BasicAuthentication)
}
}
}
publications {
maven(MavenPublication) {
groupId = project.maven_group
artifactId = project.name
version = project.maven_version

from components.java

pom {
name = "ViaAprilFools"
description = project.description
url = "https://github.com/ViaVersion/ViaAprilFools"
licenses {
license {
name = "GPL-3.0 License"
url = "https://github.com/ViaVersion/ViaAprilFools/blob/main/LICENSE"
}
}
developers {
developer {
id = "RK_01"
}
developer {
id = "FlorianMichael/EnZaXD"
}
}
scm {
connection = "scm:git:git://github.com/ViaVersion/ViaAprilFools.git"
developerConnection = "scm:git:ssh://github.com/ViaVersion/ViaAprilFools.git"
url = "https://github.com/ViaVersion/ViaAprilFools.git"
}
}
}
}
}
7 changes: 7 additions & 0 deletions build-logic/src/main/groovy/vaf.platform-conventions.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
id "vaf.base-conventions"
}

dependencies {
compileOnly project(":viaaprilfools-common")
}
198 changes: 120 additions & 78 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,112 +1,154 @@
plugins {
id "java-library"
id "maven-publish"
id "idea"
id "net.raphimc.class-token-replacer" version "1.1.2"
id "vaf.base-conventions"

id "io.papermc.hangar-publish-plugin" version "0.1.2"
id "com.modrinth.minotaur" version "2.+"
}

base {
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8"

group = project.maven_group ?: rootProject.maven_group
archivesName = project.maven_name ?: rootProject.maven_name
version = project.maven_version ?: rootProject.maven_version
archivesName = "ViaAprilFools"
}

repositories {
mavenCentral()
maven {
name = "ViaVersion"
url "https://repo.viaversion.com"
}
configurations {
publishInclude
}

dependencies {
compileOnly "com.viaversion:viaversion-common:5.0.0"
compileOnly "com.viaversion:viabackwards-common:5.0.0"
compileOnly "org.yaml:snakeyaml:2.2"
compileOnly "com.google.guava:guava:33.2.1-jre"
compileOnly "io.netty:netty-handler:4.1.111.Final"
}

sourceSets {
main {
classTokenReplacer {
property("\${version}", project.version)
property("\${impl_version}", "git-${project.name}-${project.version}:${project.latestCommitHash()}")
}
}
publishInclude project(":viaaprilfools-common")
publishInclude project(":viaaprilfools-bukkit")
publishInclude project(":viaaprilfools-fabric")
publishInclude project(":viaaprilfools-velocity")
}

java {
withSourcesJar()
withJavadocJar()
}

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"
)
}
from("LICENSE") {
rename { "${it}_${project.name ?: rootProject.name}" }
}
}

publishing {
repositories {
maven {
name = "Via"
url = "https://repo.viaversion.com/"

credentials(PasswordCredentials)
authentication {
basic(BasicAuthentication)
}
idea {
module {
["run"].each {
excludeDirs << file("$it")
}
}
publications {
maven(MavenPublication) {
groupId = project.maven_group
artifactId = project.maven_name
version = project.maven_version
}

from components.java
// -----------------------------------------------------
// Publishing

pom {
name = "ViaAprilFools"
description = "ViaVersion addon to add support for some notable Minecraft snapshots"
url = "https://github.com/ViaVersion/ViaAprilFools"
licenses {
license {
name = "GPL-3.0 License"
url = "https://github.com/ViaVersion/ViaAprilFools/blob/main/LICENSE"
}
}
developers {
developer {
id = "RK_01"
}
}
scm {
connection = "scm:git:git://github.com/ViaVersion/ViaAprilFools.git"
developerConnection = "scm:git:ssh://github.com/ViaVersion/ViaAprilFools.git"
url = "https://github.com/ViaVersion/ViaAprilFools.git"
}
}
}
def latestCommitHash() {
def byteOut = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = byteOut
}
return byteOut.toString('UTF-8').trim()
}

idea {
module {
["run"].each {
excludeDirs << file("$it")
}
def latestCommitMessage() {
def byteOut = new ByteArrayOutputStream()
exec {
commandLine 'git', 'log', '-1', '--pretty=%B'
standardOutput = byteOut
}
return byteOut.toString('UTF-8').trim()
}

String latestCommitHash() {
def stdout = new ByteArrayOutputStream()
def branchName() {
def byteOut = new ByteArrayOutputStream()
exec {
commandLine "git", "rev-parse", "--short", "HEAD"
standardOutput = stdout
commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD'
standardOutput = byteOut
}
return stdout.toString().trim()
return byteOut.toString('UTF-8').trim()
}

def branch = branchName()
def baseVersion = project.maven_version
def isRelease = !baseVersion.contains('-')
if (!isRelease) { // Only publish releases from the main branch
def suffixedVersion = isRelease ? baseVersion : baseVersion + "+" + System.getenv("GITHUB_RUN_NUMBER")
def commitHash = latestCommitHash()
def changelogContent = "[${commitHash}](https://github.com/ViaVersion/ViaAprilFools/commit/${commitHash}) ${latestCommitMessage()}"
modrinth {
def mcVersions = project.mcVersions
.split(',')
.collect { it.trim() }

token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set("viaaprilfools")
versionType.set(isRelease ? "release" : "beta")
versionNumber.set(suffixedVersion)
versionName.set(suffixedVersion)
changelog.set(changelogContent)
uploadFile.set(jar.archiveFile)
gameVersions.set(mcVersions)
loaders.add("fabric")
loaders.add("paper")
loaders.add("folia")
loaders.add("velocity")
autoAddDependsOn.set(false)
detectLoaders.set(false)
dependencies {
required.project("viaversion")
required.project("viabackwards")
optional.project("viafabric")
}
}

hangarPublish {
publications.register("plugin") {
version = suffixedVersion
id = "ViaAprilFools"
channel = isRelease ? "Release" : "Snapshot"
changelog = changelogContent
apiKey = System.getenv("HANGAR_TOKEN")
platforms {
PAPER {
jar = project.jar.archiveFile
platformVersions = [property('mcVersionRange') as String]
dependencies {
hangar("ViaVersion") {
required = true
}
hangar("ViaBackwards") {
required = true
}
}
}
VELOCITY {
jar = project.jar.archiveFile
platformVersions = [property("velocityVersion") as String]
dependencies {
hangar("ViaVersion") {
required = true
}
hangar("ViaBackwards") {
required = true
}
}
}
}
}
}
}
13 changes: 13 additions & 0 deletions bukkit/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
plugins {
id "vaf.platform-conventions"
}

dependencies {
compileOnly(annotationProcessor("org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT"))
}

processResources {
filesMatching("plugin.yml") {
expand("version": project.version, "description": project.description)
}
}
Loading

0 comments on commit 9d48917

Please sign in to comment.