Bump to 1.1.1, update build script, stop shading lombok

This commit is contained in:
William278 2023-03-10 12:47:04 +00:00
parent a7d512e6fe
commit 2730778ef9
9 changed files with 76 additions and 63 deletions

View File

@ -35,7 +35,7 @@ jobs:
modrinth-id: Q10irTG0 modrinth-id: Q10irTG0
modrinth-featured: false modrinth-featured: false
modrinth-token: ${{ secrets.MODRINTH_TOKEN }} modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
files-primary: build/libs/Velocitab-*-all.jar path: target/Velocitab-*.jar
name: Velocitab v${{ env.version_name }} name: Velocitab v${{ env.version_name }}
version: ${{ env.version_name }} version: ${{ env.version_name }}
version-type: alpha version-type: alpha
@ -57,4 +57,4 @@ jobs:
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: Velocitab Plugin name: Velocitab Plugin
path: build/libs/Velocitab-*-all.jar path: target/Velocitab-*.jar

View File

@ -44,10 +44,10 @@ You can include placeholders in the header, footer and player name format of the
## Building ## Building
To build Velocitab, simply run the following in the root of the repository: To build Velocitab, simply run the following in the root of the repository:
``` ```bash
./gradlew clean build ./gradlew clean build
``` ```
The build will be output as `/build/lib/Velocitab-X.XX-all.jar`. The build will be output as `/target/Velocitab-x.xx.jar`.
### License ### License
Velocitab is licensed under the Apache 2.0 license. Velocitab is licensed under the Apache 2.0 license.

View File

@ -1,11 +1,17 @@
import org.apache.tools.ant.filters.ReplaceTokens
plugins { plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '8.1.0' id 'com.github.johnrengelman.shadow' version '8.1.0'
id 'org.ajoberstar.grgit' version '5.0.0' id 'org.ajoberstar.grgit' version '5.0.0'
id 'java'
} }
group = 'net.william278' group 'net.william278'
version = "1.1-${versionMetadata()}" version "$ext.plugin_version-${versionMetadata()}"
ext {
set 'version', version.toString()
}
repositories { repositories {
mavenCentral() mavenCentral()
@ -21,17 +27,28 @@ dependencies {
compileOnly 'dev.simplix:protocolize-api:2.2.5' compileOnly 'dev.simplix:protocolize-api:2.2.5'
compileOnly 'io.netty:netty-codec-http:4.1.89.Final' compileOnly 'io.netty:netty-codec-http:4.1.89.Final'
compileOnly 'net.william278:PAPIProxyBridge:1.0' compileOnly 'net.william278:PAPIProxyBridge:1.0'
compileOnly 'org.projectlombok:lombok:1.18.26'
implementation 'org.apache.commons:commons-text:1.10.0' implementation 'org.apache.commons:commons-text:1.10.0'
implementation 'net.william278:Annotaml:2.0.1' implementation 'net.william278:Annotaml:2.0.1'
implementation 'dev.dejvokep:boosted-yaml:1.3.1' implementation 'dev.dejvokep:boosted-yaml:1.3.1'
implementation 'de.themoep:minedown-adventure:1.7.2-SNAPSHOT' implementation 'de.themoep:minedown-adventure:1.7.2-SNAPSHOT'
implementation 'org.projectlombok:lombok:1.18.26'
annotationProcessor 'com.velocitypowered:velocity-api:3.1.1'
annotationProcessor 'org.projectlombok:lombok:1.18.26' annotationProcessor 'org.projectlombok:lombok:1.18.26'
} }
processResources {
filesMatching(['**/*.json', '**/*.yml']) {
filter ReplaceTokens as Class, beginToken: '${', endToken: '}',
tokens: rootProject.ext.properties
}
}
logger.lifecycle("Building PAPIProxyBridge ${version} by William278")
version rootProject.version
archivesBaseName = "${rootProject.name}"
shadowJar { shadowJar {
relocate 'org.apache.commons.text', 'net.william278.velocitab.libraries.commons.text' relocate 'org.apache.commons.text', 'net.william278.velocitab.libraries.commons.text'
relocate 'org.apache.commons.lang3', 'net.william278.velocitab.libraries.commons.lang3' relocate 'org.apache.commons.lang3', 'net.william278.velocitab.libraries.commons.lang3'
@ -45,41 +62,22 @@ shadowJar {
//noinspection GroovyAssignabilityCheck //noinspection GroovyAssignabilityCheck
exclude dependency(':slf4j-api') exclude dependency(':slf4j-api')
} }
}
def targetJavaVersion = 16 destinationDirectory.set(file("$rootDir/target"))
java { archiveClassifier.set('')
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
} }
jar.dependsOn shadowJar jar.dependsOn shadowJar
clean.delete "$rootDir/target"
tasks.withType(JavaCompile).configureEach {
options.release = targetJavaVersion
}
def templateSource = file('src/main/templates')
def templateDest = layout.buildDirectory.dir('generated/sources/templates')
def generateTemplates = tasks.register('generateTemplates', Copy) { task ->
def props = [
'version': project.version
]
task.inputs.properties props
task.from templateSource
task.into templateDest
task.expand props
}
sourceSets.main.java.srcDir(generateTemplates.map { it.outputs })
@SuppressWarnings('GrMethodMayBeStatic') @SuppressWarnings('GrMethodMayBeStatic')
def versionMetadata() { def versionMetadata() {
// Get if there is a tag for this commit
def tag = grgit.tag.list().find { it.commit.id == grgit.head().id }
if (tag != null) {
return ''
}
// Otherwise, get the last commit hash and if it's a clean head
if (grgit == null) { if (grgit == null) {
return System.getenv("GITHUB_RUN_NUMBER") ? 'build.' + System.getenv("GITHUB_RUN_NUMBER") : 'unknown' return System.getenv("GITHUB_RUN_NUMBER") ? 'build.' + System.getenv("GITHUB_RUN_NUMBER") : 'unknown'
} }

View File

@ -2,3 +2,6 @@ javaVersion=16
org.gradle.jvmargs='-Dfile.encoding=UTF-8' org.gradle.jvmargs='-Dfile.encoding=UTF-8'
org.gradle.daemon=true org.gradle.daemon=true
plugin_version=1.1.1
plugin_archive=velocitab

View File

@ -1 +1,7 @@
pluginManagement {
repositories {
gradlePluginPortal()
}
}
rootProject.name = 'Velocitab' rootProject.name = 'Velocitab'

View File

@ -3,7 +3,6 @@ package net.william278.velocitab;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Dependency;
import com.velocitypowered.api.plugin.Plugin; import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.plugin.annotation.DataDirectory; import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.Player;
@ -27,17 +26,7 @@ import java.util.Arrays;
import java.util.Optional; import java.util.Optional;
@Plugin( @Plugin(
id = "velocitab", id = "velocitab"
name = "Velocitab",
version = BuildConstants.VERSION,
description = "Simple velocity TAB menu plugin",
url = "https://william278.net/",
authors = {"William278"},
dependencies = {
@Dependency(id = "protocolize"),
@Dependency(id = "luckperms", optional = true),
@Dependency(id = "papiproxybridge", optional = true)
}
) )
public class Velocitab { public class Velocitab {
@ -63,7 +52,7 @@ public class Velocitab {
loadHooks(); loadHooks();
prepareScoreboardManager(); prepareScoreboardManager();
prepareTabList(); prepareTabList();
logger.info("Successfully enabled Velocitab v" + BuildConstants.VERSION); logger.info("Successfully enabled Velocitab");
} }
@NotNull @NotNull

View File

@ -5,7 +5,6 @@ import lombok.Getter;
import net.william278.annotaml.YamlComment; import net.william278.annotaml.YamlComment;
import net.william278.annotaml.YamlFile; import net.william278.annotaml.YamlFile;
import net.william278.annotaml.YamlKey; import net.william278.annotaml.YamlKey;
import net.william278.velocitab.BuildConstants;
import net.william278.velocitab.Velocitab; import net.william278.velocitab.Velocitab;
import org.apache.commons.text.StringEscapeUtils; import org.apache.commons.text.StringEscapeUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -23,7 +22,7 @@ public class Settings {
@YamlKey("headers") @YamlKey("headers")
private Map<String, String> headers = Map.of("default", "&rainbow&Running Velocitab v" + BuildConstants.VERSION + " by William278"); private Map<String, String> headers = Map.of("default", "&rainbow&Running Velocitab by William278");
@YamlKey("footers") @YamlKey("footers")
private Map<String, String> footers = Map.of("default", "[There are currently %players_online%/%max_players_online% players online](gray)"); private Map<String, String> footers = Map.of("default", "[There are currently %players_online%/%max_players_online% players online](gray)");
@YamlKey("formats") @YamlKey("formats")
@ -57,7 +56,7 @@ public class Settings {
@NotNull @NotNull
public String getHeader(String serverGroup) { public String getHeader(String serverGroup) {
return StringEscapeUtils.unescapeJava( return StringEscapeUtils.unescapeJava(
headers.getOrDefault(serverGroup, "&rainbow&Running Velocitab v" + BuildConstants.VERSION + " by William278")); headers.getOrDefault(serverGroup, "&rainbow&Running Velocitab by William278"));
} }
@NotNull @NotNull

View File

@ -0,0 +1,25 @@
{
"id": "velocitab",
"name": "Velocitab",
"version": "${version}",
"description": "A super-simple (sorted!) Velocity TAB menu plugin",
"url": "https://william278.net",
"authors": [
"William278"
],
"dependencies": [
{
"id": "protocolize",
"optional": false
},
{
"id": "luckperms",
"optional": true
},
{
"id": "papiproxybridge",
"optional": true
}
],
"main": "net.william278.papiproxybridge.VelocityPAPIProxyBridge"
}

View File

@ -1,7 +0,0 @@
package net.william278.velocitab;
// The constants are replaced before compilation
public class BuildConstants {
public static final String VERSION = "${version}";
}