Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spotless #15

Draft
wants to merge 2 commits into
base: 1.17.x/dev
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions .internal/license-header.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* Copyright (c) $YEAR Ampflower
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

8 changes: 8 additions & 0 deletions .internal/spotless.importorder
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Organize Import Order
#Wed Jul 07 02:53:11 PDT 2021
0=
1=java
2=javax
3=\#
4=\#java
5=\#javax
457 changes: 457 additions & 0 deletions .internal/spotless.xml

Large diffs are not rendered by default.

73 changes: 49 additions & 24 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/* Copyright (c) 2021 Ampflower
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

import java.net.URI

plugins {
Expand All @@ -6,6 +12,7 @@ plugins {
id("fabric-loom")
`maven-publish`
id("io.github.juuxel.loom-quiltflower")
id("com.diffplug.spotless")
}

val minecraft_version: String by project
Expand All @@ -21,11 +28,14 @@ val isActions = System.getenv("GITHUB_ACTIONS").toBoolean()
val baseVersion: String = "$project_version+mc.$minecraft_version"

group = "gay.ampflower"
version = when {
isRelease -> baseVersion
isActions -> "$baseVersion-build.${System.getenv("GITHUB_RUN_NUMBER")}-commit.${System.getenv("GITHUB_SHA").substring(0, 7)}-branch.${System.getenv("GITHUB_REF")?.substring(11)?.replace('/', '.') ?: "unknown"}"
else -> "$baseVersion-build.local"
}

version =
when {
isRelease -> baseVersion
isActions ->
"$baseVersion-build.${System.getenv("GITHUB_RUN_NUMBER")}-commit.${System.getenv("GITHUB_SHA").substring(0, 7)}-branch.${System.getenv("GITHUB_REF")?.substring(11)?.replace('/', '.') ?: "unknown"}"
else -> "$baseVersion-build.local"
}

java {
sourceCompatibility = JavaVersion.VERSION_16
Expand All @@ -44,33 +54,45 @@ dependencies {
modImplementation("me.lucko", "fabric-permissions-api", fabric_permissions_version)
}

spotless {
java {
importOrderFile(rootDir.resolve(".internal/spotless.importorder"))
eclipse().configFile(rootDir.resolve(".internal/spotless.xml"))

licenseHeaderFile(rootDir.resolve(".internal/license-header.java"))
}
kotlinGradle {
target("*.gradle.kts", "ply-*/*.gradle.kts")
ktfmt().dropboxStyle()
licenseHeaderFile(
rootDir.resolve(".internal/license-header.java"), "(import|plugins|rootProject)")
}
}

tasks {
withType<JavaCompile> {
options.encoding = "UTF-8"
options.isDeprecation = true
options.isWarnings = true
}
val sourcesJar = register<Jar>("sourcesJar") {
dependsOn("classes")
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val sourcesJar =
register<Jar>("sourcesJar") {
dependsOn("classes")
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
processResources {
val map = mapOf(
"version" to project.version,
"project_version" to project_version,
"loader_version" to loader_version,
"minecraft_required" to project.property("minecraft_required")?.toString()
)
val map =
mapOf(
"version" to project.version,
"project_version" to project_version,
"loader_version" to loader_version,
"minecraft_required" to project.property("minecraft_required")?.toString())
inputs.properties(map)

filesMatching("fabric.mod.json") {
expand(map)
}
}
withType<Jar> {
from("LICENSE")
filesMatching("fabric.mod.json") { expand(map) }
}
withType<Jar> { from("LICENSE") }
register<Copy>("poolBuilds") {
dependsOn(build)
if (isPublish) {
Expand All @@ -82,11 +104,14 @@ tasks {
} else {
for (p in subprojects) {
if (p.name == "ply-debug" || !p.name.startsWith("ply-")) continue
from(p.tasks.jar, p.tasks.remapJar, p.tasks.getByName("sourcesJar"), p.tasks.remapSourcesJar)
from(
p.tasks.jar,
p.tasks.remapJar,
p.tasks.getByName("sourcesJar"),
p.tasks.remapSourcesJar)
}
from(jar, remapJar, sourcesJar, remapSourcesJar)
}
into(project.buildDir.resolve("pool"))
}
}

41 changes: 23 additions & 18 deletions ply-anti-xray/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/* Copyright (c) 2021 Ampflower
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

import com.modrinth.minotaur.TaskModrinthUpload
import java.net.URI

Expand All @@ -21,11 +27,14 @@ val isActions = System.getenv("GITHUB_ACTIONS").toBoolean()
val baseVersion: String = "$project_version+mc.$minecraft_version"

group = "gay.ampflower"
version = when {
isRelease -> baseVersion
isActions -> "$baseVersion-build.${System.getenv("GITHUB_RUN_NUMBER")}-commit.${System.getenv("GITHUB_SHA").substring(0, 7)}-branch.${System.getenv("GITHUB_REF")?.substring(11)?.replace('/', '.') ?: "unknown"}"
else -> "$baseVersion-build.local"
}

version =
when {
isRelease -> baseVersion
isActions ->
"$baseVersion-build.${System.getenv("GITHUB_RUN_NUMBER")}-commit.${System.getenv("GITHUB_SHA").substring(0, 7)}-branch.${System.getenv("GITHUB_REF")?.substring(11)?.replace('/', '.') ?: "unknown"}"
else -> "$baseVersion-build.local"
}

repositories {
maven { url = URI.create("https://oss.sonatype.org/content/repositories/snapshots") }
Expand Down Expand Up @@ -58,21 +67,17 @@ tasks {
from(sourceSets.main.get().allSource)
}
processResources {
val map = mapOf(
"version" to project.version,
"project_version" to project_version,
"loader_version" to loader_version,
"minecraft_required" to project.property("minecraft_required")?.toString()
)
val map =
mapOf(
"version" to project.version,
"project_version" to project_version,
"loader_version" to loader_version,
"minecraft_required" to project.property("minecraft_required")?.toString())
inputs.properties(map)

filesMatching("fabric.mod.json") {
expand(map)
}
}
withType<Jar> {
from("LICENSE")
filesMatching("fabric.mod.json") { expand(map) }
}
withType<Jar> { from("LICENSE") }
register<TaskModrinthUpload>("publishModrinth") {
token = System.getenv("MODRINTH_TOKEN")
projectId = modrinth_id
Expand All @@ -82,4 +87,4 @@ tasks {
addGameVersion(minecraft_version)
addLoader("fabric")
}
}
}
42 changes: 24 additions & 18 deletions ply-common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/* Copyright (c) 2021 Ampflower
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

import java.net.URI

plugins {
Expand All @@ -18,11 +24,14 @@ val isActions = System.getenv("GITHUB_ACTIONS").toBoolean()
val baseVersion: String = "$project_version+mc.$minecraft_version"

group = "gay.ampflower"
version = when {
isRelease -> baseVersion
isActions -> "$baseVersion-build.${System.getenv("GITHUB_RUN_NUMBER")}-commit.${System.getenv("GITHUB_SHA").substring(0, 7)}-branch.${System.getenv("GITHUB_REF")?.substring(11)?.replace('/', '.') ?: "unknown"}"
else -> "$baseVersion-build.local"
}

version =
when {
isRelease -> baseVersion
isActions ->
"$baseVersion-build.${System.getenv("GITHUB_RUN_NUMBER")}-commit.${System.getenv("GITHUB_SHA").substring(0, 7)}-branch.${System.getenv("GITHUB_REF")?.substring(11)?.replace('/', '.') ?: "unknown"}"
else -> "$baseVersion-build.local"
}

repositories {
maven { url = URI.create("https://oss.sonatype.org/content/repositories/snapshots") }
Expand All @@ -33,6 +42,7 @@ dependencies {
mappings("net.fabricmc", "yarn", yarn_mappings, classifier = "v2")
modImplementation("net.fabricmc", "fabric-loader", loader_version)
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
Expand All @@ -50,19 +60,15 @@ tasks {
from(sourceSets.main.get().allSource)
}
processResources {
val map = mapOf(
"version" to project.version,
"project_version" to project_version,
"loader_version" to loader_version,
"minecraft_required" to project.property("minecraft_required")?.toString()
)
val map =
mapOf(
"version" to project.version,
"project_version" to project_version,
"loader_version" to loader_version,
"minecraft_required" to project.property("minecraft_required")?.toString())
inputs.properties(map)

filesMatching("fabric.mod.json") {
expand(map)
}
}
withType<Jar> {
from("LICENSE")
filesMatching("fabric.mod.json") { expand(map) }
}
}
withType<Jar> { from("LICENSE") }
}
45 changes: 24 additions & 21 deletions ply-database/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/* Copyright (c) 2021 Ampflower
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

import java.net.URI

plugins {
Expand All @@ -20,11 +26,14 @@ val isActions = System.getenv("GITHUB_ACTIONS").toBoolean()
val baseVersion: String = "$project_version+mc.$minecraft_version"

group = "gay.ampflower"
version = when {
isRelease -> baseVersion
isActions -> "$baseVersion-build.${System.getenv("GITHUB_RUN_NUMBER")}-commit.${System.getenv("GITHUB_SHA").substring(0, 7)}-branch.${System.getenv("GITHUB_REF")?.substring(11)?.replace('/', '.') ?: "unknown"}"
else -> "$baseVersion-build.local"
}

version =
when {
isRelease -> baseVersion
isActions ->
"$baseVersion-build.${System.getenv("GITHUB_RUN_NUMBER")}-commit.${System.getenv("GITHUB_SHA").substring(0, 7)}-branch.${System.getenv("GITHUB_REF")?.substring(11)?.replace('/', '.') ?: "unknown"}"
else -> "$baseVersion-build.local"
}

repositories {
maven { url = URI.create("https://oss.sonatype.org/content/repositories/snapshots") }
Expand Down Expand Up @@ -56,23 +65,17 @@ tasks {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
remapJar {
dependsOn(":utilities:jar")
}
remapJar { dependsOn(":utilities:jar") }
processResources {
val map = mapOf(
"version" to project.version,
"project_version" to project_version,
"loader_version" to loader_version,
"minecraft_required" to project.property("minecraft_required")?.toString()
)
val map =
mapOf(
"version" to project.version,
"project_version" to project_version,
"loader_version" to loader_version,
"minecraft_required" to project.property("minecraft_required")?.toString())
inputs.properties(map)

filesMatching("fabric.mod.json") {
expand(map)
}
}
withType<Jar> {
from("LICENSE")
filesMatching("fabric.mod.json") { expand(map) }
}
}
withType<Jar> { from("LICENSE") }
}
41 changes: 23 additions & 18 deletions ply-debug/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/* Copyright (c) 2021 Ampflower
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

import java.net.URI

plugins {
Expand All @@ -20,11 +26,14 @@ val isActions = System.getenv("GITHUB_ACTIONS").toBoolean()
val baseVersion: String = "$project_version+mc.$minecraft_version"

group = "gay.ampflower"
version = when {
isRelease -> baseVersion
isActions -> "$baseVersion-build.${System.getenv("GITHUB_RUN_NUMBER")}-commit.${System.getenv("GITHUB_SHA").substring(0, 7)}-branch.${System.getenv("GITHUB_REF")?.substring(11)?.replace('/', '.') ?: "unknown"}"
else -> "$baseVersion-build.local"
}

version =
when {
isRelease -> baseVersion
isActions ->
"$baseVersion-build.${System.getenv("GITHUB_RUN_NUMBER")}-commit.${System.getenv("GITHUB_SHA").substring(0, 7)}-branch.${System.getenv("GITHUB_REF")?.substring(11)?.replace('/', '.') ?: "unknown"}"
else -> "$baseVersion-build.local"
}

repositories {
maven { url = URI.create("https://oss.sonatype.org/content/repositories/snapshots") }
Expand Down Expand Up @@ -61,19 +70,15 @@ tasks {
from(sourceSets.main.get().allSource)
}
processResources {
val map = mapOf(
"version" to project.version,
"project_version" to project_version,
"loader_version" to loader_version,
"minecraft_required" to project.property("minecraft_required")?.toString()
)
val map =
mapOf(
"version" to project.version,
"project_version" to project_version,
"loader_version" to loader_version,
"minecraft_required" to project.property("minecraft_required")?.toString())
inputs.properties(map)

filesMatching("fabric.mod.json") {
expand(map)
}
}
withType<Jar> {
from("LICENSE")
filesMatching("fabric.mod.json") { expand(map) }
}
}
withType<Jar> { from("LICENSE") }
}
Loading