Skip to content

Commit

Permalink
Implemented version string replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Sep 10, 2023
1 parent 45b08d4 commit 1caefe3
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 17 deletions.
27 changes: 20 additions & 7 deletions buildSrc/src/main/groovy/com.viaversion.java-conventions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ plugins {
repositories {
mavenLocal()
maven {
url = uri('https://repo.viaversion.com')
url = uri("https://repo.viaversion.com")
}

maven {
url = uri('https://repo.maven.apache.org/maven2/')
url = uri("https://repo.maven.apache.org/maven2/")
}

maven {
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
}

maven {
url = uri('https://oss.sonatype.org/content/repositories/snapshots')
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
}

maven {
url = uri('https://maven.fabricmc.net/')
url = uri("https://maven.fabricmc.net/")
}

maven {
url = uri('https://repo.spongepowered.org/repository/maven-public/')
url = uri("https://repo.spongepowered.org/repository/maven-public/")
}

maven {
url = uri('https://nexus.velocitypowered.com/repository/maven-public/')
url = uri("https://nexus.velocitypowered.com/repository/maven-public/")
}
}

Expand All @@ -46,6 +46,19 @@ version = project.maven_version

java.sourceCompatibility = JavaVersion.VERSION_1_8

tasks {
// Variable replacements
processResources {
inputs.property "version", project.version

for (final def file in ["plugin.yml", "bungee.yml", "META-INF/sponge_plugins.json", "fabric.mod.json"]) {
filesMatching(file) {
expand "version": version
}
}
}
}

publishing {
repositories {
maven {
Expand Down
2 changes: 1 addition & 1 deletion bukkit/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ViaRewind
version: ${project.version}
version: ${version}
main: com.viaversion.viarewind.BukkitPlugin
api-version: 1.13
folia-supported: true
Expand Down
2 changes: 1 addition & 1 deletion bungee/src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: ViaRewind
main: com.viaversion.viarewind.BungeePlugin
authors: [Gerrygames, FlorianMichael/EnZaXD, creeper123321123]
version: ${project.version}
version: ${version}
depends: [ViaVersion]
softdepends: [ViaBackwards]
website: https://viaversion.com/rewind
12 changes: 8 additions & 4 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ plugins {
}

plugins {
id "net.kyori.blossom" version "1.3.1"
id "net.raphimc.class-token-replacer" version "1.0.0"
}

dependencies {
}

blossom {
replaceToken("\$VERSION", project.version, "src/main/java/com/viaversion/viarewind/api/ViaRewindPlatform.java")
replaceToken("\$IMPL_VERSION", "git-ViaRewind-${project.version}:${latestCommitHash()}", "src/main/java/com/viaversion/viarewind/api/ViaRewindPlatform.java")
sourceSets {
main {
classTokenReplacer {
property("\${version}", rootProject.maven_version)
property("\${impl_version}", "git-${project.name}-${rootProject.maven_version}:${project.latestCommitHash()}")
}
}
}

String latestCommitHash() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
*/
public interface ViaRewindPlatform {

String VERSION = "$VERSION";
String IMPL_VERSION = "$IMPL_VERSION";
String VERSION = "${version}";
String IMPL_VERSION = "${impl_version}";

/**
* Initialize ViaRewind
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"schemaVersion": 1,
"id": "viarewind",
"name": "ViaRewind",
"version": "${project.version}",
"version": "${version}",
"license": "GPL-3.0",
"contact": {
"homepage": "https://viaversion.com/rewind",
Expand Down
2 changes: 1 addition & 1 deletion sponge/src/main/resources/META-INF/sponge_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"license": "GNU GPLv3",
"global": {
"version": "${project.version}",
"version": "${version}",
"links": {
"homepage": "https://viaversion.com/rewind",
"source": "https://github.com/ViaVersion/ViaRewind",
Expand Down

0 comments on commit 1caefe3

Please sign in to comment.