1
0
mirror of https://github.com/GeyserMC/Floodgate.git synced 2025-12-19 14:59:20 +00:00

Add branch name when not master, simplify publish, use GitHub Actions

And updated Gradle
This commit is contained in:
Tim203
2023-02-12 11:35:32 +01:00
parent f44319c968
commit da97a0f073
9 changed files with 79 additions and 55 deletions

30
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,30 @@
name: Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-java@v3
with:
java-version: 8
distribution: temurin
- name: Build
uses: gradle/gradle-build-action@v2
with:
arguments: build
- name: Publish
uses: gradle/gradle-build-action@v2
env:
ORG_GRADLE_PROJECT_geysermcUsername: "${{ secrets.DEPLOY_USER }}"
ORG_GRADLE_PROJECT_geysermcPassword: "${{ secrets.DEPLOY_PASS }}"
with:
arguments: publish

View File

@@ -9,8 +9,8 @@ repositories {
} }
dependencies { dependencies {
implementation("net.kyori", "indra-common", "2.0.6") implementation("net.kyori", "indra-common", "3.0.1")
implementation("org.jfrog.buildinfo", "build-info-extractor-gradle", "4.26.1") implementation("net.kyori", "indra-git", "3.0.1")
implementation("gradle.plugin.com.github.johnrengelman", "shadow", "7.1.1") implementation("gradle.plugin.com.github.johnrengelman", "shadow", "7.1.1")
implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext", "gradle-idea-ext", "1.1.7") implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext", "gradle-idea-ext", "1.1.7")
} }

View File

@@ -28,9 +28,6 @@ import org.gradle.api.Project
import org.gradle.api.artifacts.ProjectDependency import org.gradle.api.artifacts.ProjectDependency
import org.gradle.kotlin.dsl.the import org.gradle.kotlin.dsl.the
fun Project.isSnapshot(): Boolean =
version.toString().endsWith("-SNAPSHOT")
fun Project.fullVersion(): String { fun Project.fullVersion(): String {
var version = version.toString() var version = version.toString()
if (version.endsWith("-SNAPSHOT")) { if (version.endsWith("-SNAPSHOT")) {
@@ -42,14 +39,19 @@ fun Project.fullVersion(): String {
fun Project.lastCommitHash(): String? = fun Project.lastCommitHash(): String? =
the<IndraGitExtension>().commit()?.name?.substring(0, 7) the<IndraGitExtension>().commit()?.name?.substring(0, 7)
// retrieved from https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project
// some properties might be specific to Jenkins
fun Project.branchName(): String = fun Project.branchName(): String =
System.getenv("GIT_BRANCH") ?: "local/dev" the<IndraGitExtension>().branchName() ?: System.getenv("BRANCH_NAME") ?: "local/dev"
fun Project.buildNumber(): Int =
Integer.parseInt(System.getenv("BUILD_NUMBER") ?: "-1")
fun Project.buildNumberAsString(): String = fun Project.shouldAddBranchName(): Boolean =
System.getenv("IGNORE_BRANCH")?.toBoolean() ?: (branchName() !in arrayOf("master", "local/dev"))
fun Project.versionWithBranchName(): String =
branchName().replace(Regex("[^0-9A-Za-z-_]"), "-") + '-' + version
fun buildNumber(): Int =
System.getenv("BUILD_NUMBER")?.let { Integer.parseInt(it) } ?: -1
fun buildNumberAsString(): String =
buildNumber().takeIf { it != -1 }?.toString() ?: "??" buildNumber().takeIf { it != -1 }?.toString() ?: "??"
val providedDependencies = mutableMapOf<String, MutableSet<Pair<String, Any>>>() val providedDependencies = mutableMapOf<String, MutableSet<Pair<String, Any>>>()

View File

@@ -1,7 +1,7 @@
plugins { plugins {
`java-library` `java-library`
`maven-publish`
// id("net.ltgt.errorprone") // id("net.ltgt.errorprone")
id("net.kyori.indra")
id("net.kyori.indra.git") id("net.kyori.indra.git")
} }
@@ -9,6 +9,21 @@ dependencies {
compileOnly("org.checkerframework", "checker-qual", Versions.checkerQual) compileOnly("org.checkerframework", "checker-qual", Versions.checkerQual)
} }
indra {
github("GeyserMC", "Floodgate") {
ci(true)
issues(true)
scm(true)
}
mitLicense()
javaVersions {
// without toolchain & strictVersion sun.misc.Unsafe won't be found
minimumToolchain(8)
strictVersions(true)
}
}
tasks { tasks {
processResources { processResources {
filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json")) { filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json")) {
@@ -22,14 +37,4 @@ tasks {
) )
} }
} }
compileJava {
options.encoding = Charsets.UTF_8.name()
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
} }

View File

@@ -1,33 +1,15 @@
plugins { plugins {
id("floodgate.shadow-conventions") id("floodgate.shadow-conventions")
id("com.jfrog.artifactory") id("net.kyori.indra.publishing")
id("maven-publish")
} }
publishing { indra {
publications { configurePublications {
create<MavenPublication>("mavenJava") { if (shouldAddBranchName()) {
groupId = project.group as String version = versionWithBranchName()
artifactId = project.name
version = project.version as String
from(components["java"])
} }
} }
}
artifactory { publishSnapshotsTo("geysermc", "https://repo.opencollab.dev/artifactory/maven-snapshots")
setContextUrl("https://repo.opencollab.dev/artifactory") publishReleasesTo("geysermc", "https://repo.opencollab.dev/artifactory/maven-releases")
publish {
repository {
setRepoKey(if (isSnapshot()) "maven-snapshots" else "maven-releases")
setMavenCompatible(true)
}
defaults {
publications("mavenJava")
setPublishArtifacts(true)
setPublishPom(true)
setPublishIvy(false)
}
}
} }

View File

@@ -287,7 +287,7 @@ public final class ReflectionUtils {
} }
/** /**
* Get the value of a field and cast it to <T>. * Get the value of a field and cast it to T.
* *
* @param instance the instance to get the value from * @param instance the instance to get the value from
* @param field the field to get the value from * @param field the field to get the value from
@@ -301,7 +301,7 @@ public final class ReflectionUtils {
} }
/** /**
* Get the value of a field and cast it to <T>. * Get the value of a field and cast it to T.
* *
* @param instance the instance to get the value from * @param instance the instance to get the value from
* @param fieldName the field to get the value from * @param fieldName the field to get the value from

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

10
gradlew vendored
View File

@@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# #
# Copyright © 2015-2021 the original authors. # Copyright <EFBFBD> 2015-2021 the original authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script # Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features: # requires all of these POSIX shell features:
# * functions; # * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», # * expansions <EFBFBD>$var<EFBFBD>, <EFBFBD>${var}<EFBFBD>, <EFBFBD>${var:-default}<EFBFBD>, <EFBFBD>${var+SET}<EFBFBD>,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»; # <EFBFBD>${var#prefix}<EFBFBD>, <EFBFBD>${var%suffix}<EFBFBD>, and <EFBFBD>$( cmd )<EFBFBD>;
# * compound commands having a testable exit status, especially «case»; # * compound commands having a testable exit status, especially <EFBFBD>case<EFBFBD>;
# * various built-in commands including «command», «set», and «ulimit». # * various built-in commands including <EFBFBD>command<EFBFBD>, <EFBFBD>set<EFBFBD>, and <EFBFBD>ulimit<EFBFBD>.
# #
# Important for patching: # Important for patching:
# #

View File

@@ -1,3 +1,4 @@
@file:Suppress("UnstableApiUsage")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
dependencyResolutionManagement { dependencyResolutionManagement {
@@ -54,6 +55,10 @@ pluginManagement {
repositories { repositories {
gradlePluginPortal() gradlePluginPortal()
} }
plugins {
id("net.kyori.indra")
id("net.kyori.indra.git")
}
includeBuild("build-logic") includeBuild("build-logic")
} }