Skip to content

Commit

Permalink
refactor: restructure as multi module project
Browse files Browse the repository at this point in the history
  • Loading branch information
darksaid98 committed Dec 26, 2024
1 parent 83a1038 commit ef03ca0
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 428 deletions.
421 changes: 109 additions & 312 deletions .editorconfig

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ nb-configuration.xml
##############################
## OS X
##############################
.DS_Store
.DS_Store
/run/
164 changes: 55 additions & 109 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,135 +2,81 @@ import java.time.Instant

plugins {
`java-library`
`maven-publish`

alias(libs.plugins.maven.deployer) apply false
eclipse
idea
}

group = "com.github.milkdrinkers"
version = "2.0.0"
description = ""

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
withJavadocJar()
withSourcesJar()
}
subprojects {
apply(plugin = "java-library")
apply(plugin = rootProject.libs.plugins.maven.deployer.get().pluginId)

repositories {
mavenCentral()
applyCustomVersion()

maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") {
content {
includeGroup("org.bukkit")
includeGroup("org.spigotmc")
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://oss.sonatype.org/content/repositories/snapshots") // Required for Spigots Bungeecord dependency
maven("https://oss.sonatype.org/content/repositories/central") // Required for Spigots Bungeecord dependency
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") {
content { includeGroup("me.clip") }
}
}
maven("https://oss.sonatype.org/content/repositories/snapshots") // Required for Spigots Bungeecord dependency
maven("https://oss.sonatype.org/content/repositories/central") // Required for Spigots Bungeecord dependency

maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") {
content { includeGroup("me.clip") }
}
}

dependencies {
compileOnly("org.jetbrains:annotations:24.1.0")
annotationProcessor("org.jetbrains:annotations:24.1.0")
dependencies {
compileOnly(rootProject.libs.annotations)
annotationProcessor(rootProject.libs.annotations)

api("net.kyori:adventure-api:4.14.0")
api("net.kyori:adventure-text-minimessage:4.14.0")
api("net.kyori:adventure-text-serializer-gson:4.14.0")
api("net.kyori:adventure-text-serializer-legacy:4.14.0")
api("net.kyori:adventure-text-serializer-plain:4.14.0")
api(rootProject.libs.bundles.adventure)

compileOnly("org.spigotmc:spigot-api:1.20.6-R0.1-SNAPSHOT")
compileOnly(rootProject.libs.spigot.api)
compileOnly(rootProject.libs.placeholderapi)

compileOnly("me.clip:placeholderapi:2.11.6")
}

tasks {
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(8)
testImplementation(rootProject.libs.annotations)
testImplementation(platform(rootProject.libs.junit.bom))
testImplementation(rootProject.libs.bundles.junit)
}

javadoc {
isFailOnError = false
val options = options as StandardJavadocDocletOptions
options.encoding = Charsets.UTF_8.name()
options.overview = "src/main/javadoc/overview.html"
options.isDocFilesSubDirs = true
options.tags("apiNote:a:API Note:", "implNote:a:Implementation Note:", "implSpec:a:Implementation Requirements:")
options.use()
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
withJavadocJar()
withSourcesJar()
}
}

// Apply custom version arg
val versionArg = if (hasProperty("customVersion"))
(properties["customVersion"] as String).uppercase() // Uppercase version string
else
"${project.version}-SNAPSHOT-${Instant.now().epochSecond}" // Append snapshot to version

// Strip prefixed "v" from version tag
project.version = if (versionArg.first().equals('v', true))
versionArg.substring(1)
else
versionArg.uppercase()

publishing {
publications {
create<MavenPublication>("maven") {
groupId = "${rootProject.group}"
artifactId = "colorparser"
version = "${rootProject.version}"

pom {
name.set("ColorParser")
description.set(rootProject.description.orEmpty())
url.set("https://github.com/milkdrinkers/ColorParser")
licenses {
license {
name.set("GNU General Public License version 3")
url.set("https://opensource.org/license/gpl-3-0/")
}
}
developers {
developer {
id.set("darksaid98")
name.set("darksaid98")
organization.set("Milkdrinkers")
organizationUrl.set("https://github.com/milkdrinkers")
}
}
scm {
connection.set("scm:git:git://github.com/milkdrinkers/ColorParser.git")
developerConnection.set("scm:git:ssh://github.com:milkdrinkers/ColorParser.git")
url.set("https://github.com/milkdrinkers/ColorParser")
}
}
tasks {
compileJava {
options.encoding = Charsets.UTF_8.name()
options.compilerArgs.addAll(arrayListOf("-Xlint:all", "-Xlint:-processing", "-Xdiags:verbose"))
options.release.set(8)
}

from(components["java"])
javadoc {
isFailOnError = false
val options = options as StandardJavadocDocletOptions
options.encoding = Charsets.UTF_8.name()
options.overview = "src/main/javadoc/overview.html"
options.windowTitle = "${rootProject.name} Javadoc"
options.tags("apiNote:a:API Note:", "implNote:a:Implementation Note:", "implSpec:a:Implementation Requirements:")
options.addStringOption("Xdoclint:none", "-quiet")
options.use()
}
}

repositories {
maven {
name = "releases"
url = uri("https://maven.athyrium.eu/releases")
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
processResources {
filteringCharset = Charsets.UTF_8.name()
}
maven {
name = "snapshots"
url = uri("https://maven.athyrium.eu/snapshots")
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}

test {
useJUnitPlatform()
failFast = false
}
}
}

fun applyCustomVersion() {
// Apply custom version arg or append snapshot version
val ver = properties["altVer"]?.toString() ?: "${rootProject.version}-SNAPSHOT-${Instant.now().epochSecond}"

// Strip prefixed "v" from version tag
rootProject.version = (if (ver.first().equals('v', true)) ver.substring(1) else ver.uppercase()).uppercase()
}
50 changes: 50 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
deployer {
release {
version.set("${rootProject.version}")
description.set(rootProject.description.orEmpty())
}

projectInfo {
groupId = "io.github.milkdrinkers"
artifactId = "colorparser"
version = "${rootProject.version}"

name = rootProject.name
description = rootProject.description.orEmpty()
url = "https://github.com/milkdrinkers/ColorParser"

scm {
connection = "scm:git:git://github.com/milkdrinkers/ColorParser.git"
developerConnection = "scm:git:ssh://github.com:milkdrinkers/ColorParser.git"
url = "https://github.com/milkdrinkers/ColorParser"
}

license({
name = "GNU General Public License Version 3"
url = "https://opensource.org/license/gpl-3-0/"
})

developer({
name.set("darksaid98")
email.set("[email protected]")
url.set("https://github.com/darksaid98")
organization.set("Milkdrinkers")
})
}

content {
component {
fromJava()
}
}

centralPortalSpec {
auth.user.set(secret("MAVEN_USERNAME"))
auth.password.set(secret("MAVEN_PASSWORD"))
}

signing {
key.set(secret("GPG_KEY"))
password.set(secret("GPG_PASSWORD"))
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.milkdrinkers.colorparser;
package io.github.milkdrinkers.colorparser;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -89,7 +89,7 @@ private ColorParser() {
* Instantiates a new Color parser.
*
* @param text the string to parse.
* @deprecated use {@link com.github.milkdrinkers.colorparser.ColorParser#of(String)}.
* @deprecated use {@link ColorParser#of(String)}.
* Instantiates a new color parser object.
*/
@Deprecated
Expand All @@ -103,7 +103,7 @@ public ColorParser(String text) {
*
* @param text the string to parse.
* @return the color parser object.
* @deprecated use {@link com.github.milkdrinkers.colorparser.ColorParser#of(String)}
* @deprecated use {@link ColorParser#of(String)}
* Instantiates a new color parser object.
*/
@Deprecated
Expand Down
4 changes: 2 additions & 2 deletions README.md → docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<img src="https://img.shields.io/github/license/milkdrinkers/ColorParser?color=blue&style=flat-square" alt="license"/>
<a href="https://maven.athyrium.eu/#/releases/com/github/milkdrinkers/colorparser"><img alt="Maven metadata URL" src="https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fmaven.athyrium.eu%2Freleases%2Fcom%2Fgithub%2Fmilkdrinkers%2Fcolorparser%2Fmaven-metadata.xml&style=flat-square&label=Maven Version&color=44cc11"></a>
<a href="https://milkdrinkers.github.io/ColorParser/introduction"><img src="https://img.shields.io/badge/Documentation-900C3F?style=flat-square" alt="documentation"/></a>
<a href="https://maven.athyrium.eu/javadoc/releases/com/github/milkdrinkers/colorparser/latest"><img src="https://img.shields.io/badge/Javadoc-8A2BE2?style=flat-square" alt="javadoc"/></a>
<a href="https://javadoc.io/doc/io.github.milkdrinkers/colorparser"><img src="https://img.shields.io/badge/Javadoc-8A2BE2?style=flat-square" alt="javadoc"/></a>
<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/milkdrinkers/colorparser?style=flat-square&label=Last%20Commit">
</p>

Expand All @@ -19,7 +19,7 @@ A simple utility library for easily adding [MiniMessage](https://docs.advntr.dev
## Useful Links

* **Documentation** - [Link](https://milkdrinkers.github.io/ColorParser/introduction)
* **JavaDoc** - [Link](https://maven.athyrium.eu/javadoc/releases/com/github/milkdrinkers/colorparser/latest)
* **JavaDoc** - [Link](https://javadoc.io/doc/io.github.milkdrinkers/colorparser)
* **MiniMessage Formatting** - [Link](https://docs.advntr.dev/minimessage/format.html)
* **MiniMessage Previewer** - [Link](https://webui.advntr.dev/)
* **Adventure Documentation** - [Link](https://docs.advntr.dev/index.html)
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ org.gradle.caching=true
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2048M
group=io.github.milkdrinkers
version=2.0.0
description=A simple utility library for the Adventure library.
27 changes: 27 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[versions]
adventure = "4.14.0"

[libraries]
annotations = "org.jetbrains:annotations:26.0.1"
paper-api = "io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT"
spigot-api = "org.spigotmc:spigot-api:1.20.6-R0.1-SNAPSHOT"
adventure-api = { module = "net.kyori:adventure-api", version.ref = "adventure" }
adventure-minimessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "adventure" }
adventure-gson = { module = "net.kyori:adventure-text-serializer-gson", version.ref = "adventure" }
adventure-legacy = { module = "net.kyori:adventure-text-serializer-legacy", version.ref = "adventure" }
adventure-plain = { module = "net.kyori:adventure-text-serializer-plain", version.ref = "adventure" }
placeholderapi = "me.clip:placeholderapi:2.11.6"

# Testing
junit-bom = "org.junit:junit-bom:5.11.4"
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter" }
junit-platform = { module = "org.junit.platform:junit-platform-launcher" }

[bundles]
junit = ["junit-jupiter", "junit-platform"]
adventure = ["adventure-api", "adventure-minimessage", "adventure-gson", "adventure-legacy", "adventure-plain"]

[plugins]
maven-deployer = "io.deepmedia.tools.deployer:0.16.0"
shadow = "com.gradleup.shadow:8.3.5"
run-paper = "xyz.jpenilla.run-paper:2.3.1"
8 changes: 7 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ pluginManagement {
}

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
id("org.gradle.toolchains.foojay-resolver-convention") version("0.9.0")
}

rootProject.name = "ColorParser"

enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

include(
"common",
)

0 comments on commit ef03ca0

Please sign in to comment.