Skip to content

Commit

Permalink
refactor: v2 (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
ybw0014 authored Oct 3, 2024
1 parent 8034658 commit 29e993b
Show file tree
Hide file tree
Showing 65 changed files with 2,379 additions and 10,573 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2

[*.json]
indent_size = 2
indent_style = tab
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
if: startsWith(github.event.head_commit.message, '[CI skip]') == false
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin

- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build with Gradle
run: ./gradlew clean shadowJar
23 changes: 0 additions & 23 deletions .github/workflows/maven.yml

This file was deleted.

125 changes: 18 additions & 107 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,113 +1,24 @@
# User-specific stuff
.idea/

*.iml
*.ipr
*.iws

# IntelliJ
out/

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*
.gradle
**/build/
!src/**/build/

# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# Ignore Gradle GUI config
gradle-app.setting

# General
.DS_Store
.AppleDouble
.LSOverride
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Icon must end with two \r
Icon
# Avoid ignore Gradle wrappper properties
!gradle-wrapper.properties

# Thumbnails
._*
# Cache of project
.gradletasknamecache

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Eclipse Gradle plugin generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

target/

pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next

release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml

# Common working directory
run/
.idea/
.env
148 changes: 148 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
group = "net.guizhanss"
val mainPackage = "net.guizhanss.minecraft.guizhanlib"

plugins {
java
`java-library`
`maven-publish`
signing
id("io.freefair.lombok") version "8.7.1"
id("com.gradleup.shadow") version "8.3.0"
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
}

repositories {
mavenCentral()
maven(url = "https://jitpack.io/")
maven(url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven(url = "https://papermc.io/repo/repository/maven-public")
maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots/")
}

dependencies {
fun compileOnlyAndTestImplementation(dependencyNotation: Any) {
compileOnly(dependencyNotation)
testImplementation(dependencyNotation)
}

implementation("net.guizhanss:guizhanlib-all:2.0.0")
implementation("org.bstats:bstats-bukkit:3.1.0")
implementation("com.google.code.findbugs:jsr305:3.0.2")
api("com.github.houbb:pinyin:0.4.0")

compileOnlyAndTestImplementation("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
compileOnlyAndTestImplementation("com.github.Slimefun:Slimefun4:RC-37")

// mockbukkit
testImplementation("com.github.MockBukkit:MockBukkit:c7cc678834")
// junit
testImplementation(platform("org.junit:junit-bom:5.11.1"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
withJavadocJar()
withSourcesJar()
}

tasks.compileJava {
options.encoding = "UTF-8"
}

tasks.javadoc {
options.encoding = "UTF-8"
}

tasks.test {
useJUnitPlatform()
}

tasks.shadowJar {
fun doRelocate(from: String, to: String? = null) {
val last = to ?: from.split(".").last()
relocate(from, "$mainPackage.libs.$last")
}

doRelocate("io.papermc.lib", "paperlib")
doRelocate("com.github.houbb")
doRelocate("org.bstats")
archiveClassifier = ""
}

publishing {
publications {
create<MavenPublication>("maven") {
project.shadow.component(this)

artifact(tasks.named("javadocJar").get())
artifact(tasks.named("sourcesJar").get())

groupId = rootProject.group as String
artifactId = project.name
version = rootProject.version as String

pom {
name.set("GuizhanLibPlugin")
description.set("A library plugin for Slimefun addon development.")
url.set("https://github.com/ybw0014/GuizhanLibPlugin")

licenses {
license {
name.set("GPL-3.0 license")
url.set("https://github.com/ybw0014/GuizhanLibPlugin/blob/master/LICENSE")
distribution.set("repo")
}
}

developers {
developer {
name.set("ybw0014")
url.set("https://ybw0014.dev/")
}
}

scm {
connection.set("scm:git:git://github.com/ybw0014/GuizhanLibPlugin.git")
developerConnection.set("scm:git:ssh://github.com:ybw0014/GuizhanLibPlugin.git")
url.set("https://github.com/ybw0014/guizhanlibplugin/tree/master")
}
}
}
}

repositories {
maven {
name = "CentralRelease"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getProperty("OSSRH_USERNAME", "")
password = System.getProperty("OSSRH_PASSWORD", "")
}
}
maven {
name = "CentralSnapshot"
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
credentials {
username = System.getProperty("OSSRH_USERNAME", "")
password = System.getProperty("OSSRH_PASSWORD", "")
}
}
}
}

signing {
useGpgCmd()
sign(configurations.runtimeElements.get())
}

bukkit {
main = "$mainPackage.GuizhanLib"
apiVersion = "1.18"
authors = listOf("ybw0014")
description = "A library plugin for Simplified Chinese Slimefun addons."
website = "https://github.com/ybw0014/GuizhanLibPlugin"
depend = listOf("Slimefun")
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=2.0.0
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 29e993b

Please sign in to comment.