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:
30
.github/workflows/build.yml
vendored
Normal file
30
.github/workflows/build.yml
vendored
Normal 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
|
||||
@@ -9,8 +9,8 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("net.kyori", "indra-common", "2.0.6")
|
||||
implementation("org.jfrog.buildinfo", "build-info-extractor-gradle", "4.26.1")
|
||||
implementation("net.kyori", "indra-common", "3.0.1")
|
||||
implementation("net.kyori", "indra-git", "3.0.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")
|
||||
}
|
||||
|
||||
@@ -28,9 +28,6 @@ import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.ProjectDependency
|
||||
import org.gradle.kotlin.dsl.the
|
||||
|
||||
fun Project.isSnapshot(): Boolean =
|
||||
version.toString().endsWith("-SNAPSHOT")
|
||||
|
||||
fun Project.fullVersion(): String {
|
||||
var version = version.toString()
|
||||
if (version.endsWith("-SNAPSHOT")) {
|
||||
@@ -42,14 +39,19 @@ fun Project.fullVersion(): String {
|
||||
fun Project.lastCommitHash(): String? =
|
||||
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 =
|
||||
System.getenv("GIT_BRANCH") ?: "local/dev"
|
||||
fun Project.buildNumber(): Int =
|
||||
Integer.parseInt(System.getenv("BUILD_NUMBER") ?: "-1")
|
||||
the<IndraGitExtension>().branchName() ?: System.getenv("BRANCH_NAME") ?: "local/dev"
|
||||
|
||||
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() ?: "??"
|
||||
|
||||
val providedDependencies = mutableMapOf<String, MutableSet<Pair<String, Any>>>()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
// id("net.ltgt.errorprone")
|
||||
id("net.kyori.indra")
|
||||
id("net.kyori.indra.git")
|
||||
}
|
||||
|
||||
@@ -9,6 +9,21 @@ dependencies {
|
||||
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 {
|
||||
processResources {
|
||||
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()
|
||||
}
|
||||
@@ -1,33 +1,15 @@
|
||||
plugins {
|
||||
id("floodgate.shadow-conventions")
|
||||
id("com.jfrog.artifactory")
|
||||
id("maven-publish")
|
||||
id("net.kyori.indra.publishing")
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("mavenJava") {
|
||||
groupId = project.group as String
|
||||
artifactId = project.name
|
||||
version = project.version as String
|
||||
indra {
|
||||
configurePublications {
|
||||
if (shouldAddBranchName()) {
|
||||
version = versionWithBranchName()
|
||||
}
|
||||
}
|
||||
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
artifactory {
|
||||
setContextUrl("https://repo.opencollab.dev/artifactory")
|
||||
publish {
|
||||
repository {
|
||||
setRepoKey(if (isSnapshot()) "maven-snapshots" else "maven-releases")
|
||||
setMavenCompatible(true)
|
||||
}
|
||||
defaults {
|
||||
publications("mavenJava")
|
||||
setPublishArtifacts(true)
|
||||
setPublishPom(true)
|
||||
setPublishIvy(false)
|
||||
}
|
||||
}
|
||||
publishSnapshotsTo("geysermc", "https://repo.opencollab.dev/artifactory/maven-snapshots")
|
||||
publishReleasesTo("geysermc", "https://repo.opencollab.dev/artifactory/maven-releases")
|
||||
}
|
||||
@@ -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 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 fieldName the field to get the value from
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
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
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
10
gradlew
vendored
10
gradlew
vendored
@@ -1,7 +1,7 @@
|
||||
#!/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");
|
||||
# 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
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
# * expansions <EFBFBD>$var<EFBFBD>, <EFBFBD>${var}<EFBFBD>, <EFBFBD>${var:-default}<EFBFBD>, <EFBFBD>${var+SET}<EFBFBD>,
|
||||
# <EFBFBD>${var#prefix}<EFBFBD>, <EFBFBD>${var%suffix}<EFBFBD>, and <EFBFBD>$( cmd )<EFBFBD>;
|
||||
# * compound commands having a testable exit status, especially <EFBFBD>case<EFBFBD>;
|
||||
# * various built-in commands including <EFBFBD>command<EFBFBD>, <EFBFBD>set<EFBFBD>, and <EFBFBD>ulimit<EFBFBD>.
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
@file:Suppress("UnstableApiUsage")
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
|
||||
dependencyResolutionManagement {
|
||||
@@ -54,6 +55,10 @@ pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
}
|
||||
plugins {
|
||||
id("net.kyori.indra")
|
||||
id("net.kyori.indra.git")
|
||||
}
|
||||
includeBuild("build-logic")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user