Skip to content

Commit

Permalink
Merge pull request #515 from Multiverse/gradle-update
Browse files Browse the repository at this point in the history
Implement grade and new GHA release
  • Loading branch information
benwoo1110 authored Feb 21, 2023
2 parents e7b8b36 + 86fe16a commit b029840
Show file tree
Hide file tree
Showing 14 changed files with 618 additions and 341 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/build.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Create Release Version & Publish Package

on:
push:
branches: [main]

jobs:
release_on_push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: gradle

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Test & Build
uses: gradle/gradle-build-action@v2
with:
arguments: clean build -x assemble -x shadowJar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create release
id: release
uses: rymndhng/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
bump_version_scheme: norelease
tag_prefix: ''
release_name: "Release <RELEASE_VERSION>"
use_github_release_notes: true

- name: Publish package
uses: gradle/gradle-build-action@v2
with:
arguments: publish
env:
GITHUB_VERSION: ${{ steps.release.outputs.tag_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload release artifact
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/libs/multiverse-inventories-${{ steps.release.outputs.tag_name }}.jar
asset_name: multiverse-inventories-${{ steps.release.outputs.tag_name }}.jar
tag: ${{ steps.release.outputs.tag_name }}
18 changes: 18 additions & 0 deletions .github/workflows/require_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Require PR Labels

on:
pull_request:
types: [opened, labeled, unlabeled, synchronize]
branches: [main]

jobs:
require_label:
runs-on: ubuntu-latest
steps:
- uses: mheap/github-action-required-labels@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
mode: exactly
count: 1
labels: "release:major, release:minor, release:patch, no release"
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Run unit tests against all PRs

on:
pull_request:
types: [opened, synchronize]

jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: gradle

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Run unit tests
uses: gradle/gradle-build-action@v2
with:
arguments: build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ debug.log
# Doxygen
/docs/html
debug.txt

# Gradle
.gradle

159 changes: 159 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
plugins {
id 'java-library'
id 'maven-publish'
id 'checkstyle'
id 'com.github.johnrengelman.shadow' version '7.1.2'
}

version = System.getenv('GITHUB_VERSION') ?: 'local'
group = 'com.onarandombox.multiverseinventories'
description = 'Multiverse-Inventories'

java.sourceCompatibility = JavaVersion.VERSION_11

repositories {
mavenLocal()
mavenCentral()

maven {
name = 'onarandombox'
url = uri('https://repo.onarandombox.com/content/groups/public')
}

maven {
name ='papermc'
url = uri('https://papermc.io/repo/repository/maven-public/')
}

maven {
name = 'jitpack.io'
url = uri('https://jitpack.io/')
}
}

dependencies {
// Spigot
implementation('org.bukkit:bukkit:1.14.4-R0.1-SNAPSHOT') {
exclude group: 'junit', module: 'junit'
}

// Core
implementation('com.onarandombox.multiversecore:Multiverse-Core:4.2.2') {
exclude group: 'me.main__.util', module: 'SerializationConfig'
}

// Config
api 'com.dumptruckman.minecraft:JsonConfiguration:1.1'
api ('com.googlecode.json-simple:json-simple:1.1.1') {
exclude group: 'junit', module: 'junit'
}

// Utils
api 'io.papermc:paperlib:1.0.7'
api('com.dumptruckman.minecraft:Logging:1.1.1') {
exclude group: 'junit', module: 'junit'
}

// Other plugins for import
implementation('uk.co:MultiInv:3.0.6') {
exclude group: '*', module: '*'
}
implementation('me.drayshak:WorldInventories:1.0.2') {
exclude group: '*', module: '*'
}

// Legacy Multiverse-Adventure
implementation('com.onarandombox.multiverseadventure:Multiverse-Adventure:2.5.0-SNAPSHOT') {
exclude group: '*', module: '*'
}

// Tests
testImplementation 'com.github.MilkBowl:VaultAPI:1.7.1'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:3.11.2'
}


java {
withSourcesJar()
withJavadocJar()
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}

tasks.withType(Javadoc).configureEach {
options.encoding = 'UTF-8'
}


configurations {
[apiElements, runtimeElements].each {
it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
it.outgoing.artifact(shadowJar)
}
}

publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
repositories {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/Multiverse/Multiverse-Inventories"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}


processResources {
def props = [version: "${project.version}"]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}

// This task should never be skipped. The tests depend on this having been run but we want the new version number
// that is created after tests are run and before we run again to publish.
outputs.upToDateWhen { false }
}


checkstyle {
toolVersion = '6.1.1'
configFile file('config/mv_checks.xml')
ignoreFailures = true
}


javadoc {
source = sourceSets.main.allJava
classpath = configurations.compileClasspath
}


project.configurations.api.canBeResolved = true

shadowJar {
relocate 'com.dumptruckman.minecraft.util.Logging', 'com.onarandombox.multiverseinventories.utils.InvLogging'
relocate 'com.dumptruckman.minecraft.util.DebugLog', 'com.onarandombox.multiverseinventories.utils.DebugFileLogger'
relocate 'com.dumptruckman.bukkit.configuration', 'com.onarandombox.multiverseinventories.utils.configuration'
relocate 'io.papermc.lib', 'com.onarandombox.multiverseinventories.utils.paperlib'
relocate 'net.minidev.json', 'com.onarandombox.multiverseinventories.utils.json'

configurations = [project.configurations.api]

archiveFileName = "$baseName-$version.$extension"
}

build.dependsOn shadowJar
jar.enabled = false
12 changes: 5 additions & 7 deletions config/mv_checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
<module name="JavadocPackage">
<property name="allowLegacy" value="true"/>
</module>
<module name="NewlineAtEndOfFile">
<property name="severity" value="info"/>
</module>
<module name="NewlineAtEndOfFile" />
<module name="Translation"/>
<module name="FileLength"/>
<module name="FileTabCharacter">
Expand Down Expand Up @@ -78,7 +76,10 @@
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>
</module>
<module name="MethodLength"/>
<module name="MethodLength">
<property name="severity" value="warning"/>
<property name="countEmpty" value="false"/>
</module>
<module name="ParameterNumber"/>
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/>
Expand All @@ -103,7 +104,6 @@
</module>
<module name="LeftCurly"/>
<module name="RightCurly"/>
<module name="DoubleCheckedLocking"/>
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField">
Expand All @@ -115,7 +115,6 @@
<property name="ignoreNumbers" value="-1, 0, 0.5, 1, 2, 3"/>
</module>
<module name="MissingSwitchDefault"/>
<module name="RedundantThrows"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<!-- Don't like errors for `final` missing
Expand All @@ -140,4 +139,3 @@
<module name="MissingOverride"/>
</module>
</module>

Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit b029840

Please sign in to comment.