Skip to content

Commit

Permalink
more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
powercasgamer committed Nov 22, 2023
1 parent ef69583 commit c87df90
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 13 deletions.
54 changes: 44 additions & 10 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,31 +1,54 @@
import org.gradle.nativeplatform.platform.internal.Architectures
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import java.util.*

plugins {
id("common-conventions")
id("kotlin-conventions")
id("xyz.jpenilla.gremlin-gradle")
application
}

val operatingSystem: OperatingSystem = DefaultNativePlatform.getCurrentOperatingSystem()

dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))
runtimeDownload(kotlin("reflect"))
implementation("io.github.oshai:kotlin-logging-jvm:5.1.0")
implementation("org.jetbrains.kotlinx:kotlinx-cli-jvm:0.3.6")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.16.0")
implementation("org.slf4j:slf4j-simple:2.0.9")
implementation("io.javalin:javalin:6.0.0-beta.2")
implementation("io.javalin:javalin:6.0.0-SNAPSHOT")
implementation("com.github.ben-manes.caffeine:caffeine:3.1.8")
implementation("org.spongepowered:configurate-jackson:4.2.0-SNAPSHOT")
implementation("org.spongepowered:configurate-hocon:4.2.0-SNAPSHOT")
implementation(libs.gremlin.runtime)
implementation("org.spongepowered:configurate-extra-kotlin:4.2.0-SNAPSHOT")
}

indra {
javaVersions {
target(17)
minimumToolchain(17)
}
mitLicense()
runtimeDownload("com.aayushatharva.brotli4j:brotli4j:1.13.0")
runtimeDownload(
"com.aayushatharva.brotli4j:native-" +
if (operatingSystem.isWindows) {
"windows-x86_64"
} else if (operatingSystem.isMacOsX) {
if (DefaultNativePlatform.getCurrentArchitecture().isArm()) {
"osx-aarch64"
} else {
"osx-x86_64"
}
} else if (operatingSystem.isLinux) {
if (Architectures.ARM_V7.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) {
"linux-armv7"
} else if (Architectures.AARCH64.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) {
"linux-aarch64"
} else if (Architectures.X86_64.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) {
"linux-x86_64"
} else {
throw IllegalStateException("Unsupported architecture: ${DefaultNativePlatform.getCurrentArchitecture().name}")
}
} else {
throw IllegalStateException("Unsupported operating system: $operatingSystem")
} + ":1.13.0",
)
}

application {
Expand All @@ -48,3 +71,14 @@ idea {
isDownloadSources = true
}
}

tasks.writeDependencies {
outputFileName.set("imagery-dependencies.txt")
repos.add("https://repo.papermc.io/repository/maven-public/")
repos.add("https://repo.maven.apache.org/maven2/")
}

gremlin {
defaultJarRelocatorDependencies.set(true)
defaultGremlinRuntimeDependency.set(false)
}
1 change: 1 addition & 0 deletions app/src/main/kotlin/dev/mizule/imagery/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class App(val config: Config, usersConfigOption: String) {
it.showJavalinBanner = false
it.router.ignoreTrailingSlashes = true
it.useVirtualThreads = true
it.http.brotliAndGzipCompression()
it.contextResolver.ip = { ctx ->
ctx.header(config.addressHeader) ?: ctx.req().remoteAddr
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/kotlin/dev/mizule/imagery/app/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ data class Config(
@Comment("The length of the random generated path.")
val pathLength: Int = 8,

@Comment("""
@Comment(
"""
Any kind of proxy services change real ip.
The origin ip should be available in one of the headers.
Nginx: X-Forwarded-For
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package dev.mizule.imagery.app.util

import org.slf4j.LoggerFactory
import xyz.jpenilla.gremlin.runtime.DependencyCache
import xyz.jpenilla.gremlin.runtime.DependencyResolver
import xyz.jpenilla.gremlin.runtime.DependencySet
import java.nio.file.Path

class ImageryDependencies {

fun resolve(cacheDir: Path): Set<Path> {
val deps = DependencySet.readFromClasspathResource(
ImageryDependencies::class.java.classLoader, "imagery-dependencies.txt"
)
val cache = DependencyCache(cacheDir)
val logger = LoggerFactory.getLogger(ImageryDependencies::class.java.simpleName)
val files: Set<Path>
DependencyResolver(logger).use { downloader ->
files = downloader.resolve(deps, cache).jarFiles()
}
cache.cleanup()
return files
}
}
6 changes: 6 additions & 0 deletions build-logic/src/main/kotlin/base-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ repositories {
mavenCentral()
sonatype.s01Snapshots()
sonatype.ossSnapshots()
maven("https://maven.reposilite.com/snapshots") {
mavenContent {
snapshotsOnly()
includeGroup("io.javalin")
}
}
}

extensions.configure(IndraExtension::class) {
Expand Down
1 change: 1 addition & 0 deletions build-logic/src/main/kotlin/common-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ indra {
minimumToolchain(17)
target(17)
}
mitLicense()

publishSnapshotsTo("mizule", "https://repo.mizule.dev/snapshots")
publishReleasesTo("mizule", "https://repo.mizule.dev/releases")
Expand Down
5 changes: 3 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[plugins]

[libraries]
# build-logic stuff
blossom = { module = "net.kyori:blossom", version.ref = "blossom" }
Expand All @@ -14,6 +12,9 @@ idea-gradle = { module = "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gra
gremlin-gradle = { module = "xyz.jpenilla:gremlin-gradle", version.ref = "gremlin" }
gremlin-runtime = { module = "xyz.jpenilla:gremlin-runtime", version.ref = "gremlin" }

[plugins]
gremlin-gradle = { id = "xyz.jpenilla.gremlin-gradle", version.ref = "gremlin" }

[versions]
indra = "3.1.3"
blossom = "2.1.0"
Expand Down

0 comments on commit c87df90

Please sign in to comment.