Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
run: chmod +x ./gradlew

- name: Build and test
run: ./gradlew clean build
run: ./gradlew clean build -x spotlessCheck -x detektMain -x detektTest
42 changes: 42 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Lint

on:
pull_request:
branches:
- main
types: [opened, synchronize, reopened, ready_for_review]
push:
branches:
- main
- develop

concurrency:
group: lint-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
lint:
name: lint
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v7

- name: Set up JDK
uses: actions/setup-java@v6
with:
distribution: 'temurin'
java-version: '25'

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6

- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Run spotless and detekt
run: ./gradlew spotlessCheck detektMain detektTest --continue
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
run: ./gradlew clean build $GRADLE_ARGS

- name: Publish to SimpleCloud Repository
run: ./gradlew publish $GRADLE_ARGS
run: ./gradlew publish :build-logic:publish $GRADLE_ARGS
env:
SIMPLECLOUD_USERNAME: ${{ secrets.SIMPLECLOUD_USERNAME }}
SIMPLECLOUD_PASSWORD: ${{ secrets.SIMPLECLOUD_PASSWORD }}
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ This repository holds classes that are very commonly used in plugins.
### Gradle Kotlin

```kt
implementation("app.simplecloud.plugin:plugin-shared:VERSION")
implementation("app.simplecloud.api.plugin:plugin-shared:VERSION")
```

### Gradle Groovy

```groovy
implementation "app.simplecloud.plugin:plugin-shared:VERSION"
implementation "app.simplecloud.api.plugin:plugin-shared:VERSION"
```

### Maven

```xml
<dependency>
<groupId>app.simplecloud.plugin</groupId>
<groupId>app.simplecloud.api.plugin</groupId>
<artifactId>plugin-shared</artifactId>
<version>VERSION</version>
</dependency>
Expand Down Expand Up @@ -82,16 +82,16 @@ This repository is licensed under [Apache 2.0][license].

[modrinth]: https://modrinth.com/organization/simplecloud

[dev]: https://repo.simplecloud.app/#/snapshots/app/simplecloud/plugin
[dev]: https://repo.simplecloud.app/#/snapshots/app/simplecloud/api/plugin


[artifacts]: https://repo.simplecloud.app/#/snapshots/app/simplecloud/plugin
[artifacts]: https://repo.simplecloud.app/#/snapshots/app/simplecloud/api/plugin

[dev-artifacts]: https://repo.simplecloud.app/#/snapshots/app/simplecloud/plugin
[dev-artifacts]: https://repo.simplecloud.app/#/snapshots/app/simplecloud/api/plugin

[badge-maven-central]: https://img.shields.io/maven-central/v/app.simplecloud.droplet.api/droplet-api?labelColor=18181b&style=flat-square&color=65a30d&label=Release

[badge-dev]: https://repo.simplecloud.app/api/badge/latest/snapshots/app/simplecloud/plugin/plugin-shared?name=Dev&style=flat-square&color=0ea5e9
[badge-dev]: https://repo.simplecloud.app/api/badge/latest/snapshots/app/simplecloud/api/plugin/plugin-shared?name=Dev&style=flat-square&color=0ea5e9

<!-- ⛔ DON'T TOUCH -->

Expand Down
33 changes: 33 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
plugins {
`kotlin-dsl`
`maven-publish`
}

val baseVersion = "1.0.0"
val isRelease = providers.gradleProperty("release").isPresent
val commitHash = providers.exec {
commandLine("git", "rev-parse", "--short", "HEAD")
}.standardOutput.asText.get().trim()

group = "app.simplecloud.gradle"
version = if (isRelease) baseVersion else "$baseVersion-dev.$commitHash"

dependencies {
implementation(libs.kotlin.gradle.plugin)
implementation(libs.shadow.gradle.plugin)
implementation(libs.spotless.gradle.plugin)
implementation(libs.detekt.gradle.plugin)
}

publishing {
repositories {
maven {
name = "simplecloud"
url = uri("https://repo.simplecloud.app/snapshots")
credentials {
username = System.getenv("SIMPLECLOUD_USERNAME")
password = System.getenv("SIMPLECLOUD_PASSWORD")
}
}
}
}
14 changes: 14 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
dependencyResolutionManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}

versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}

rootProject.name = "build-logic"
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package app.simplecloud.gradle

import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction

/** Writes [text] to [outputFile]. */
abstract class WriteTextFile : DefaultTask() {

@get:Input
abstract val text: Property<String>

@get:OutputFile
abstract val outputFile: RegularFileProperty

@TaskAction
fun write() {
outputFile.get().asFile.writeText(text.get())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
kotlin("jvm")
id("com.gradleup.shadow")
id("simplecloud.spotless-conventions")
id("simplecloud.detekt-conventions")
}

repositories {
mavenCentral()
mavenLocal()
maven("https://buf.build/gen/maven")
maven("https://repo.spectr.is/snapshots")
maven("https://repo.simplecloud.app/snapshots")
maven("https://repo.papermc.io/repository/maven-public")
}

dependencies {
testImplementation(kotlin("test"))
}

kotlin {
jvmToolchain(25)
compilerOptions {
jvmTarget = JvmTarget.JVM_25
languageVersion = KotlinVersion.KOTLIN_2_4
apiVersion = KotlinVersion.KOTLIN_2_4
}
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
}

tasks.test {
useJUnitPlatform()
}

tasks.processResources {
val properties = mapOf("version" to project.version.toString())
inputs.properties(properties)
filesMatching(listOf("plugin.yml", "paper-plugin.yml")) {
expand(properties)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import app.simplecloud.gradle.WriteTextFile

plugins {
id("dev.detekt")
}

val defaultConfigText = checkNotNull(javaClass.getResource("/detekt/detekt.yml")) { "detekt.yml not found" }.readText()
val projectConfig = rootProject.file("config/detekt/detekt.yml")

val extractDetektConfig = tasks.register<WriteTextFile>("extractDetektConfig") {
description = "Extracts the detekt config"
text = defaultConfigText
outputFile = layout.buildDirectory.file("detekt/detekt.yml")
}

detekt {
buildUponDefaultConfig = true
parallel = true
config.setFrom(extractDetektConfig.flatMap { it.outputFile })
if (projectConfig.exists()) {
config.from(projectConfig)
}
}

pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
tasks.named("check") {
setDependsOn(dependsOn.filterNot { it is TaskProvider<*> && it.name == "detekt" })
dependsOn("detektMain", "detektTest")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
id("com.diffplug.spotless")
}

val ktlintVersion = "1.8.0"
val ktlintEditorConfig = mapOf(
"ktlint_code_style" to "intellij_idea",
"max_line_length" to "120",
"ij_kotlin_packages_to_use_import_on_demand" to "kotlin.**,kotlinx.**,io.ktor.**",
"ktlint_standard_function-signature" to "disabled",
"ktlint_standard_multiline-expression-wrapping" to "disabled",
"ktlint_standard_chain-method-continuation" to "disabled",
)

spotless {
kotlin {
ktlint(ktlintVersion).editorConfigOverride(ktlintEditorConfig)
}

kotlinGradle {
ktlint(ktlintVersion).editorConfigOverride(ktlintEditorConfig)
}
}
41 changes: 41 additions & 0 deletions build-logic/src/main/resources/detekt/detekt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
complexity:
TooManyFunctions:
active: false
LongParameterList:
allowedFunctionParameters: 6
allowedConstructorParameters: 8
ignoreDefaultParameters: true
LongMethod:
allowedLines: 80
CyclomaticComplexMethod:
ignoreSimpleWhenEntries: true

style:
ForbiddenMethodCall:
active: true
methods:
- 'kotlin.io.print'
- 'kotlin.io.println'
- 'java.math.BigDecimal.<init>(kotlin.Double)'
- 'java.math.BigDecimal.<init>(kotlin.String)'
- 'kotlin.system.measureTimeMillis'
- 'kotlin.apply'
- 'kotlin.also'
- 'kotlin.let'
- 'kotlin.run'
- 'kotlin.with'
- 'kotlin.takeIf'
- 'kotlin.takeUnless'
MagicNumber:
active: false
# formatting is handled by ktlint
MaxLineLength:
active: false
ReturnCount:
max: 3
excludeGuardClauses: true
ThrowsCount:
max: 3
excludeGuardClauses: true
WildcardImport:
active: false
52 changes: 11 additions & 41 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("maven-publish")
alias(libs.plugins.kotlin)
id("simplecloud.base-conventions") apply false
}

val baseVersion = "1.0.0"
Expand All @@ -13,51 +10,24 @@ val commitHash = providers.exec {
}.standardOutput.asText.get().trim()

allprojects {
group = "app.simplecloud.plugin"
group = "app.simplecloud.api.plugin"
version = if (isRelease) baseVersion else "$baseVersion-dev.$commitHash"

repositories {
mavenCentral()
mavenLocal()
maven("https://buf.build/gen/maven")
maven("https://repo.spectr.is/snapshots")
maven("https://repo.simplecloud.app/snapshots")
maven("https://repo.papermc.io/repository/maven-public")
}
}

subprojects {
apply {
plugin("maven-publish")
plugin("org.jetbrains.kotlin.jvm")
plugin("simplecloud.base-conventions")
}

dependencies {
testImplementation(rootProject.libs.kotlin.test)
compileOnly(rootProject.libs.kotlin.jvm)
compileOnly(rootProject.libs.kotlin.coroutines)
compileOnly(rootProject.libs.simplecloud.api)
compileOnly(rootProject.libs.bundles.cloud)
compileOnly(rootProject.libs.bundles.adventure)
compileOnly(rootProject.libs.bundles.configurate)
compileOnly(rootProject.libs.slf4j.api)
}

kotlin {
jvmToolchain(25)
compilerOptions {
jvmTarget = JvmTarget.JVM_25
languageVersion = KotlinVersion.KOTLIN_2_4
apiVersion = KotlinVersion.KOTLIN_2_4
}
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
}

tasks.test {
useJUnitPlatform()
"compileOnly"(rootProject.libs.kotlin.jvm)
"compileOnly"(rootProject.libs.kotlin.coroutines)
"compileOnly"(rootProject.libs.simplecloud.api)
"compileOnly"(rootProject.libs.bundles.cloud)
"compileOnly"(rootProject.libs.bundles.adventure)
"compileOnly"(rootProject.libs.bundles.configurate)
"compileOnly"(rootProject.libs.slf4j.api)
}

publishing {
Expand All @@ -79,4 +49,4 @@ subprojects {
}
}

}
}
Loading
Loading