Skip to content

Commit

Permalink
chore: spotless (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
powercasgamer committed Nov 11, 2023
1 parent 984b91b commit 37dddac
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .spotless/mizule.importorder
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Organize Import Order
#Tue Mar 30 19:56:59 PDT 2021
0=
1=java
2=javax
3=\#
56 changes: 55 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import com.diffplug.gradle.spotless.FormatExtension
import net.kyori.indra.licenser.spotless.HeaderFormat
import java.util.*

plugins {
id("org.jetbrains.kotlin.jvm") version "1.9.20"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("net.kyori.indra") version "3.1.3"
id("net.kyori.indra.licenser.spotless") version "3.1.3"
id("net.kyori.indra.git") version "3.1.3"
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7"
`java-library`
application
}
Expand Down Expand Up @@ -34,6 +41,46 @@ indra {
mitLicense()
}

spotless {
fun FormatExtension.applyCommon() {
trimTrailingWhitespace()
endWithNewline()
encoding("UTF-8")
toggleOffOn()
}
java {
importOrderFile(rootProject.file(".spotless/mizule.importorder"))
removeUnusedImports()
formatAnnotations()
applyCommon()
target("*/src/*/java/**/*.java")
}
kotlinGradle {
applyCommon()
ktlint("0.50.0")
}
kotlin {
applyCommon()
ktlint("0.50.0")
}
}

indraSpotlessLicenser {
headerFormat(HeaderFormat.starSlash())
licenseHeaderFile(rootProject.projectDir.resolve("HEADER"))

val currentYear = Calendar.getInstance().apply {
time = Date()
}.get(Calendar.YEAR)
val createdYear = providers.gradleProperty("createdYear").map { it.toInt() }.getOrElse(currentYear)
val year = if (createdYear == currentYear) createdYear.toString() else "$createdYear-$currentYear"

property("name", providers.gradleProperty("projectName").getOrElse("template"))
property("year", year)
property("description", project.description ?: "A template project")
property("author", providers.gradleProperty("projectAuthor").getOrElse("template"))
}

application {
mainClass.set("dev.mizule.imagery.app.launcher.Launcher")
}
Expand All @@ -46,4 +93,11 @@ tasks {
runShadow {
workingDir = file("run").also(File::mkdirs)
}
}
}

idea {
module {
isDownloadJavadoc = true
isDownloadSources = true
}
}
31 changes: 29 additions & 2 deletions app/src/main/kotlin/dev/mizule/imagery/app/App.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*
* This file is part of Imagery, licensed under the MIT License.
*
* Copyright (c) 2023 powercas_gamer
* Copyright (c) 2023 contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.mizule.imagery.app

import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
Expand All @@ -17,7 +41,10 @@ import org.spongepowered.configurate.jackson.JacksonConfigurationLoader
import org.spongepowered.configurate.kotlin.objectMapperFactory
import java.nio.file.Path
import java.util.concurrent.TimeUnit
import kotlin.io.path.*
import kotlin.io.path.Path
import kotlin.io.path.createDirectories
import kotlin.io.path.inputStream
import kotlin.io.path.outputStream

private val logger = KotlinLogging.logger {}

Expand Down Expand Up @@ -76,7 +103,7 @@ class App(private val config: Config) {
System.currentTimeMillis(),
file.filename(),
file.extension(),
MimeTypes.getDefaultMimeByExtension(file.extension())
MimeTypes.getDefaultMimeByExtension(file.extension()),
)

dataNode.node(uploadedFile.id).set(uploadedFile)
Expand Down
26 changes: 25 additions & 1 deletion app/src/main/kotlin/dev/mizule/imagery/app/config/Config.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*
* This file is part of Imagery, licensed under the MIT License.
*
* Copyright (c) 2023 powercas_gamer
* Copyright (c) 2023 contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.mizule.imagery.app.config

import org.spongepowered.configurate.objectmapping.ConfigSerializable
Expand All @@ -15,5 +39,5 @@ data class Config(
val indexPath: String = "./files.json",

@Comment("The path to the uploaded file storage directory.")
val storagePath: String = "./storage"
val storagePath: String = "./storage",
)
24 changes: 24 additions & 0 deletions app/src/main/kotlin/dev/mizule/imagery/app/launcher/Launcher.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*
* This file is part of Imagery, licensed under the MIT License.
*
* Copyright (c) 2023 powercas_gamer
* Copyright (c) 2023 contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
@file:JvmName("Launcher")

package dev.mizule.imagery.app.launcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package dev.mizule.imagery.app.model

data class ImageLookupResult(
val url: String,
val delete: String = "$url/del"
val delete: String = "$url/del",
)
24 changes: 24 additions & 0 deletions app/src/main/kotlin/dev/mizule/imagery/app/model/UploadedFile.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*
* This file is part of Imagery, licensed under the MIT License.
*
* Copyright (c) 2023 powercas_gamer
* Copyright (c) 2023 contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.mizule.imagery.app.model

import org.spongepowered.configurate.objectmapping.ConfigSerializable
Expand Down

0 comments on commit 37dddac

Please sign in to comment.