mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-21 18:15:26 +01:00
Merge pull request #2885 from Multiverse/MV5
This commit is contained in:
commit
5d6edc7b82
2
.github/labeler.yml
vendored
Normal file
2
.github/labeler.yml
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
prerelease:
|
||||
- '*'
|
17
.github/workflows/pr_labeler.yml
vendored
Normal file
17
.github/workflows/pr_labeler.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
name: "Pull Request Labeler"
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened]
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
prerelease_labeler:
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/labeler@v4
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
90
.github/workflows/promote_release.yml
vendored
Normal file
90
.github/workflows/promote_release.yml
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
name: Manually promote last prerelease to release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version to promote'
|
||||
required: true
|
||||
version-bump:
|
||||
description: 'Version bump to apply - should usually match the version bump used for the prerelease since last release'
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- 'patch'
|
||||
- 'minor'
|
||||
- 'major'
|
||||
|
||||
jobs:
|
||||
manually_promote_release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Verify input version is prerelease
|
||||
run: |
|
||||
if [[ "${{ github.event.inputs.version }}" != *"pre"* ]]; then
|
||||
echo "Version must be a prerelease"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Get release info
|
||||
id: get-release
|
||||
uses: cardinalby/git-get-release-action@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
with:
|
||||
tag: ${{ github.event.inputs.version }}
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ steps.get-release.outputs.tag_name }}
|
||||
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'adopt'
|
||||
cache: gradle
|
||||
|
||||
- name: Validate Gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
|
||||
- name: Remove prerelease tag
|
||||
run: |
|
||||
echo "Removing prerelease tag from version"
|
||||
echo "VERSION=$(echo ${{ steps.get-release.outputs.tag_name }} | sed -E 's/-pre.*//')" >> $GITHUB_ENV
|
||||
|
||||
- name: Build
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: clean build -x test -x checkstyleMain -x checkstyleTest
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_VERSION: ${{ env.VERSION }}
|
||||
|
||||
- name: Create release
|
||||
id: release
|
||||
uses: Multiverse/release-on-push-action@skip_prs
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
bump_version_scheme: ${{ github.event.inputs.version-bump }}
|
||||
tag_prefix: ''
|
||||
release_name: "<RELEASE_VERSION>"
|
||||
use_github_release_notes: true
|
||||
ref: ${{ steps.get-release.outputs.target_commitish }}
|
||||
skip_prs: true
|
||||
|
||||
- name: Publish package
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: publish
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_VERSION: ${{ env.VERSION }}
|
||||
|
||||
- name: Upload release artifact
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: build/libs/multiverse-core-${{ env.VERSION }}.jar
|
||||
asset_name: multiverse-core-${{ steps.release.outputs.tag_name }}.jar
|
||||
tag: ${{ steps.release.outputs.tag_name }}
|
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
@ -28,27 +28,37 @@ jobs:
|
||||
|
||||
- name: Create release
|
||||
id: release
|
||||
uses: rymndhng/release-on-push-action@v0.27.0
|
||||
uses: Multiverse/release-on-push-action@support_prerelease
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
bump_version_scheme: norelease
|
||||
tag_prefix: ''
|
||||
release_name: "Release <RELEASE_VERSION>"
|
||||
release_name: "<RELEASE_VERSION>"
|
||||
use_github_release_notes: true
|
||||
|
||||
- name: Modify version scheme
|
||||
run: |
|
||||
if [[ "${{ steps.release.outputs.tag_name }}" == *"pre"* ]]; then
|
||||
echo "Replacing prerelease version scheme with SNAPSHOT"
|
||||
echo "VERSION=$(echo ${{ steps.release.outputs.tag_name }} | sed -E 's/-pre.*/-SNAPSHOT/')" >> $GITHUB_ENV
|
||||
else
|
||||
echo "Using release version scheme"
|
||||
echo "VERSION=${{ steps.release.outputs.tag_name }}" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Publish package
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: publish
|
||||
env:
|
||||
GITHUB_VERSION: ${{ steps.release.outputs.tag_name }}
|
||||
GITHUB_VERSION: ${{ env.VERSION }}
|
||||
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-core-${{ steps.release.outputs.tag_name }}.jar
|
||||
file: build/libs/multiverse-core-${{ env.VERSION }}.jar
|
||||
asset_name: multiverse-core-${{ steps.release.outputs.tag_name }}.jar
|
||||
tag: ${{ steps.release.outputs.tag_name }}
|
||||
|
2
.github/workflows/require_label.yml
vendored
2
.github/workflows/require_label.yml
vendored
@ -15,4 +15,4 @@ jobs:
|
||||
with:
|
||||
mode: exactly
|
||||
count: 1
|
||||
labels: "release:major, release:minor, release:patch, no release"
|
||||
labels: "release:major, release:minor, release:patch, no version bump"
|
||||
|
74
build.gradle
74
build.gradle
@ -5,16 +5,23 @@ plugins {
|
||||
id 'maven-publish'
|
||||
id 'checkstyle'
|
||||
id 'com.github.johnrengelman.shadow' version '7.1.2'
|
||||
id "org.jetbrains.kotlin.jvm" version "1.8.10"
|
||||
}
|
||||
|
||||
version = System.getenv('GITHUB_VERSION') ?: 'local'
|
||||
group = 'com.onarandombox.multiversecore'
|
||||
description = 'Multiverse-Core'
|
||||
|
||||
java.sourceCompatibility = JavaVersion.VERSION_11
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
|
||||
}
|
||||
@ -50,11 +57,13 @@ repositories {
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
oldTestImplementation.extendsFrom implementation
|
||||
oldTestRuntime.extendsFrom runtime
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Spigot
|
||||
implementation('org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT') {
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
|
||||
|
||||
// Economy
|
||||
implementation('com.github.MilkBowl:VaultAPI:1.7.1') {
|
||||
@ -82,9 +91,21 @@ dependencies {
|
||||
api 'org.jetbrains:annotations:22.0.0'
|
||||
|
||||
// Tests
|
||||
testImplementation 'junit:junit:4.13.1'
|
||||
testImplementation 'org.mockito:mockito-core:3.11.2'
|
||||
testImplementation 'commons-io:commons-io:2.7'
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10'
|
||||
testImplementation 'com.github.seeseemelk:MockBukkit-v1.19:2.141.0'
|
||||
testImplementation('com.googlecode.json-simple:json-simple:1.1.1') {
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test'
|
||||
|
||||
// Old Tests
|
||||
oldTestImplementation 'org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT'
|
||||
oldTestImplementation('com.googlecode.json-simple:json-simple:1.1.1') {
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
oldTestImplementation 'junit:junit:4.13.1'
|
||||
oldTestImplementation 'org.mockito:mockito-core:3.11.2'
|
||||
oldTestImplementation 'commons-io:commons-io:2.7'
|
||||
}
|
||||
|
||||
|
||||
@ -109,6 +130,19 @@ configurations {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sourceSets {
|
||||
oldTest {
|
||||
java {
|
||||
compileClasspath += main.output
|
||||
runtimeClasspath += main.output
|
||||
srcDir file('src/old-test/java')
|
||||
}
|
||||
resources.srcDir file('src/old-test/resources')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
@ -143,6 +177,19 @@ compileJava {
|
||||
source = prepareSource.outputs
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
// We're not using Kotlin in the plugin itself, just tests!
|
||||
enabled = false
|
||||
}
|
||||
configurations {
|
||||
compileOnly {
|
||||
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
|
||||
}
|
||||
runtimeOnly {
|
||||
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
def props = [version: "${project.version}"]
|
||||
inputs.properties props
|
||||
@ -184,14 +231,17 @@ shadowJar {
|
||||
configurations = [project.configurations.api]
|
||||
|
||||
archiveFileName = "$baseName-$version.$extension"
|
||||
|
||||
dependencies {
|
||||
exclude(dependency {
|
||||
it.moduleGroup == 'org.jetbrains.kotlin'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn shadowJar
|
||||
jar.enabled = false
|
||||
|
||||
|
||||
// Excludes all test
|
||||
// TODO: Remove this when we have tests for MV5
|
||||
test {
|
||||
exclude '**/*'
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
@ -168,6 +168,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
this.anchorManager.loadAnchors();
|
||||
this.registerEvents();
|
||||
this.registerCommands();
|
||||
this.setUpLocales();
|
||||
this.registerDestinations();
|
||||
this.setupMetrics();
|
||||
this.saveMVConfig();
|
||||
@ -220,6 +221,15 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
this.commandManager.registerCommand(new UnloadCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register locales
|
||||
*/
|
||||
private void setUpLocales() {
|
||||
this.commandManager.usePerIssuerLocale(true, true);
|
||||
this.commandManager.getLocales().addFileResClassLoader(this);
|
||||
this.commandManager.getLocales().addMessageBundles("multiverse-core");
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all the destinations.
|
||||
*/
|
||||
|
@ -0,0 +1,33 @@
|
||||
package org.mvplugins.multiverse.core
|
||||
|
||||
import be.seeseemelk.mockbukkit.MockBukkit
|
||||
import be.seeseemelk.mockbukkit.ServerMock
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore
|
||||
import com.onarandombox.MultiverseCore.utils.TestingMode
|
||||
import kotlin.test.AfterTest
|
||||
import kotlin.test.BeforeTest
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertNotNull
|
||||
|
||||
class MockBukkitTest {
|
||||
|
||||
lateinit var server: ServerMock
|
||||
lateinit var plugin: MultiverseCore
|
||||
|
||||
@BeforeTest
|
||||
fun setUp() {
|
||||
TestingMode.enable()
|
||||
server = MockBukkit.mock()
|
||||
plugin = MockBukkit.load(MultiverseCore::class.java)
|
||||
}
|
||||
|
||||
@AfterTest
|
||||
fun tearDown() {
|
||||
MockBukkit.unmock()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MockBukkit loads the plugin`() {
|
||||
assertNotNull(plugin)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user