Skip to content

Commit

Permalink
Migrate to common gradle config (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
Floweynt authored Sep 6, 2024
1 parent 1306c19 commit c174e05
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 569 deletions.
43 changes: 3 additions & 40 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,9 @@
name: Build and deploy master
name: Build master

on:
push:
branches:
- master
tags:
- '*'

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.17
uses: actions/setup-java@v1
with:
java-version: 1.17

- name: git config
run: |
git config --global user.name "Monumenta CI"
git config --global user.email "Monumenta.CI@NotARealEmail.com"
- name: Cache maven dependencies
uses: actions/cache@v2
env:
cache-name: cache-maven-dependencies
with:
# maven files are stored in `~/.m2/repository`
path: |
~/.m2/repository
~/.gradle/caches
~/.gradle/wrapper
# Create the key based on runner os, cache name, and a hash of all the pom.xml files
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Build and deploy to Github Package Registry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew publish
call-build-common:
uses: TeamMonumenta/monumenta-automation/.github/workflows/plugin_build_common.yml@master
54 changes: 3 additions & 51 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,5 @@
name: Pull request CI

name: Reviewdog checks
on: [pull_request]

jobs:
reviewdog:
name: reviewdog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'

- name: Setup reviewdog
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest

- name: git config
run: |
git config --global user.name "Monumenta CI"
git config --global user.email "Monumenta.CI@NotARealEmail.com"
- name: Cache maven dependencies
uses: actions/cache@v2
env:
cache-name: cache-maven-dependencies
with:
# maven files are stored in `~/.m2/repository`
path: |
~/.m2/repository
~/.gradle/caches
~/.gradle/wrapper
# Create the key based on runner os, cache name, and a hash of all the pom.xml files
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Build and report style/pmd/warnings
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -o pipefail
./gradlew build --console=plain 2>&1 | tee compile.log
set +o pipefail
cat compile.log | reviewdog -efm="%f:%l: warning:%m" -name="compiler-warnings" -level=error -fail-on-error -reporter=github-pr-check
cat build/reports/pmd/main.xml | reviewdog -efm='%+P<file name="%f">' -efm='%W<violation beginline="%l%.%#begincolumn="%c%.%#' -efm='%-C<%.%#' -efm='%+C%.%#' -efm='%-Q' -name="pmd" -level=error -fail-on-error -reporter=github-pr-check
cat build/reports/checkstyle/main.xml | reviewdog -f=checkstyle -name="checkstyle" -level=error -fail-on-error -reporter=github-pr-check
call-pr-common:
uses: TeamMonumenta/monumenta-automation/.github/workflows/plugin_pr_common.yml@master
9 changes: 9 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Publish
on:
push:
tags:
- '*'
jobs:
call-build-common:
uses: TeamMonumenta/monumenta-automation/.github/workflows/plugin_publish_common.yml@master
secrets: inherit
138 changes: 18 additions & 120 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,133 +1,31 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import net.ltgt.gradle.errorprone.CheckSeverity
import net.ltgt.gradle.errorprone.errorprone
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription

plugins {
java
`maven-publish`
id("com.palantir.git-version") version "0.12.2"
id("com.github.johnrengelman.shadow") version "7.1.2"
id("net.minecrell.plugin-yml.bukkit") version "0.5.1" // Generates plugin.yml
id("net.ltgt.errorprone") version "2.0.2"
id("net.ltgt.nullaway") version "1.3.0"
id("com.playmonumenta.deployment") version "1.+"
checkstyle
pmd
}

repositories {
mavenLocal()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://jitpack.io")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven("https://maven.playmonumenta.com/releases")
// NBT API, pulled in by CommandAPI
maven("https://repo.codemc.org/repository/maven-public/")
maven("https://repo.maven.apache.org/maven2/")
maven("https://repo.codemc.org/repository/maven-public/")
id("com.playmonumenta.gradle-config") version "1.+"
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
compileOnly("dev.jorel:commandapi-bukkit-core:9.4.1")
compileOnly("de.tr7zw:item-nbt-api-plugin:2.12.0-SNAPSHOT")
compileOnly("com.playmonumenta:redissync:4.1:all")
compileOnly("com.playmonumenta:nbteditor:4.1:all")
compileOnly("com.google.code.gson:gson:2.8.5")
errorprone("com.google.errorprone:error_prone_core:2.10.0")
errorprone("com.uber.nullaway:nullaway:0.9.5")
}

group = "com.playmonumenta"
val gitVersion: groovy.lang.Closure<String> by extra
version = gitVersion()
description = "libraryofsouls"
java.sourceCompatibility = JavaVersion.VERSION_17
java.targetCompatibility = JavaVersion.VERSION_17

// Configure plugin.yml generation
bukkit {
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
main = "com.playmonumenta.libraryofsouls.LibraryOfSouls"
apiVersion = "1.18"
name = "LibraryOfSouls"
authors = listOf("The Monumenta Team")
depend = listOf("CommandAPI", "NBTEditor")
softDepend = listOf("MonumentaRedisSync")
}

pmd {
isConsoleOutput = true
toolVersion = "6.41.0"
ruleSets = listOf("$rootDir/pmd-ruleset.xml")
setIgnoreFailures(true)
}

java {
withJavadocJar()
withSourcesJar()
}

publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
compileOnly(libs.commandapi)
compileOnly(libs.nbtapi)
compileOnly(libs.redissync) {
artifact {
classifier = "all"
}
}
repositories {
maven {
name = "MonumentaMaven"
url = when (version.toString().endsWith("SNAPSHOT")) {
true -> uri("https://maven.playmonumenta.com/snapshots")
false -> uri("https://maven.playmonumenta.com/releases")
}

credentials {
username = System.getenv("USERNAME")
password = System.getenv("TOKEN")
}
compileOnly(libs.nbteditor) {
artifact {
classifier = "all"
}
}
compileOnly(libs.gson)
}

tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.compilerArgs.add("-Xmaxwarns")
options.compilerArgs.add("10000")
options.compilerArgs.add("-Xlint:deprecation")

options.errorprone {
option("NullAway:AnnotatedPackages", "com.playmonumenta")

allErrorsAsWarnings.set(true)

/*** Disabled checks ***/
// These we almost certainly don't want
check(
"InlineMeSuggester",
CheckSeverity.OFF
) // We won't keep deprecated stuff around long enough for this to matter
check("CatchAndPrintStackTrace", CheckSeverity.OFF) // This is the primary way a lot of exceptions are handled
check(
"FutureReturnValueIgnored",
CheckSeverity.OFF
) // This one is dumb and doesn't let you check return values with .whenComplete()
check(
"ImmutableEnumChecker",
CheckSeverity.OFF
) // Would like to turn this on but we'd have to annotate a bunch of base classes
check(
"LockNotBeforeTry",
CheckSeverity.OFF
) // Very few locks in our code, those that we have are simple and refactoring like this would be ugly
check("StaticAssignmentInConstructor", CheckSeverity.OFF) // We have tons of these on purpose
check("StringSplitter", CheckSeverity.OFF) // We have a lot of string splits too which are fine for this use
check(
"MutablePublicArray",
CheckSeverity.OFF
) // These are bad practice but annoying to refactor and low risk of actual bugs
}
monumenta {
name("LibraryOfSouls")
paper(
"com.playmonumenta.libraryofsouls.LibraryOfSouls", BukkitPluginDescription.PluginLoadOrder.POSTWORLD, "1.18",
depends = listOf("CommandAPI", "NBTEditor"),
softDepends = listOf("MonumentaRedisSync"),
apiJarVersion = "1.20-R0.1-SNAPSHOT"
)
}

ssh.easySetup(tasks.named<ShadowJar>("shadowJar").get(), "LibraryOfSouls")
Loading

0 comments on commit c174e05

Please sign in to comment.