|
| 1 | +//================================================ Dependency ================================================ |
| 2 | + |
| 3 | +fun getDependency(groupName: String, name: String): String { |
| 4 | + val group = Properties.dependencies[groupName] ?: throw DependencyGroupNotFoundException(groupName) |
| 5 | + val dependency = group[name] ?: throw DependencyNotFoundException(name) |
| 6 | + return if (dependency.contains("%version%")) { |
| 7 | + val version = Properties.versions[groupName] ?: throw NoVersionFoundException(groupName) |
| 8 | + dependency.replace("%version%", version) |
| 9 | + } else { |
| 10 | + dependency |
| 11 | + } |
| 12 | +} |
| 13 | + |
| 14 | +class DependencyNotFoundException(dependency: String) : Exception("Dependency: $dependency not Found") |
| 15 | +class NoVersionFoundException(group: String) : Exception("There is not Version for Group: $group") |
| 16 | +class DependencyGroupNotFoundException(group: String) : Exception("Cannot find dependency Group: $group") |
| 17 | + |
| 18 | +//============================================================================================================ |
| 19 | + |
| 20 | + |
| 21 | +//=================================================== Git ==================================================== |
| 22 | + |
| 23 | +fun getCommitHash(): String = try { |
| 24 | + val runtime = Runtime.getRuntime() |
| 25 | + val process = runtime.exec("git rev-parse --short HEAD") |
| 26 | + val out = process.inputStream |
| 27 | + out.bufferedReader().readText().trim() |
| 28 | +} catch (ignored: Exception) { |
| 29 | + "unknown" |
| 30 | +} |
| 31 | + |
| 32 | +//============================================================================================================ |
| 33 | + |
| 34 | +//============================================ Properties ==================================================== |
| 35 | +object Properties { |
| 36 | + |
| 37 | + @JvmStatic |
| 38 | + val group = "net.neverstopgaming" |
| 39 | + |
| 40 | + @JvmStatic |
| 41 | + val version = "1.0.0-SNAPSHOT" |
| 42 | + |
| 43 | + @JvmStatic |
| 44 | + val versions: MutableMap<String, String> = mutableMapOf<String, String>().also { |
| 45 | + it["kotlin"] = "1.5.10" |
| 46 | + it["simplecloud"] = "2.2.0" |
| 47 | + it["nsg"] = "1.0.0-SNAPSHOT" |
| 48 | + } |
| 49 | + |
| 50 | + @JvmStatic |
| 51 | + val dependencies: MutableMap<String, MutableMap<String, String>> = |
| 52 | + mutableMapOf<String, MutableMap<String, String>>().also { |
| 53 | + it["kotlin"] = mutableMapOf( |
| 54 | + Pair("stdlib", "org.jetbrains.kotlin:kotlin-stdlib:%version%"), |
| 55 | + Pair("serialization", "org.jetbrains.kotlin:kotlin-serialization:%version%") |
| 56 | + ) |
| 57 | + it["google"] = mutableMapOf( |
| 58 | + "gson" to "com.google.code.gson:gson:2.8.6", |
| 59 | + "guice" to "com.google.inject:guice:5.0.1", |
| 60 | + "guava" to "com.google.guava:guava:30.1.1-jre", |
| 61 | + "guava-failureaccess" to "com.google.guava:failureaccess:1.0.1" |
| 62 | + ) |
| 63 | + it["javax"] = mutableMapOf( |
| 64 | + "inject" to "javax.inject:javax.inject:1" |
| 65 | + ) |
| 66 | + it["aopalliance"] = mutableMapOf( |
| 67 | + "aopalliance" to "aopalliance:aopalliance:1.0" |
| 68 | + ) |
| 69 | + it["kotlinx"] = mutableMapOf( |
| 70 | + "coroutines-core" to "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3" |
| 71 | + ) |
| 72 | + it["database"] = mutableMapOf( |
| 73 | + "mongo" to "org.mongodb:mongodb-driver-sync:4.3.0", |
| 74 | + "redis" to "io.lettuce:lettuce-core:6.1.0.RELEASE" |
| 75 | + ) |
| 76 | + it["minecraft"] = mutableMapOf( |
| 77 | + "bukkit" to "com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT", |
| 78 | + "velocity" to "com.velocitypowered:velocity-api:3.0.1" |
| 79 | + ) |
| 80 | + it["simplecloud"] = mutableMapOf( |
| 81 | + "api" to "eu.thesimplecloud.simplecloud:simplecloud-api:%version%", |
| 82 | + "base" to "eu.thesimplecloud.simplecloud:simplecloud-base:%version%", |
| 83 | + "plugin" to "eu.thesimplecloud.simplecloud:simplecloud-plugin:%version%", |
| 84 | + "launcher" to "eu.thesimplecloud.simplecloud:simplecloud-launcher:%version%", |
| 85 | + ) |
| 86 | + it["components"] = mutableMapOf( |
| 87 | + "minimessage" to "net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT", |
| 88 | + "adventure" to "net.kyori:adventure-api:4.9.3" |
| 89 | + ) |
| 90 | + it["nsg"] = mutableMapOf( |
| 91 | + "api" to "net.neverstopgaming.backend:nsg-api:%version%", |
| 92 | + "core" to "net.neverstopgaming.backend:nsg-core:%version%", |
| 93 | + "proxy" to "net.neverstopgaming.backend:nsg-proxy:%version%", |
| 94 | + "server" to "net.neverstopgaming.backend:nsg-server:%version%", |
| 95 | + "spigot" to "net.neverstopgaming.backend:nsg-server:%version%", |
| 96 | + "manager" to "net.neverstopgaming.backend:nsg-manager:%version%", |
| 97 | + "adapter" to "net.neverstopgaming.backend:nsg-adapter:%version%", |
| 98 | + ) |
| 99 | + it["components"] = mutableMapOf( |
| 100 | + "minimessage" to "net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT", |
| 101 | + "adventure" to "net.kyori:adventure-api:4.9.3" |
| 102 | + ) |
| 103 | + } |
| 104 | + |
| 105 | + |
| 106 | +} |
| 107 | +//============================================================================================================ |
| 108 | + |
| 109 | +//=========================================== Repositories =================================================== |
| 110 | +object Repositories { |
| 111 | + const val MAVEN_CENTRAL = "https://repo1.maven.org/maven2/" |
| 112 | + const val MINECRAFT_SPIGOT = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" |
| 113 | + const val SONATYPE = "https://oss.sonatype.org/content/repositories/snapshots/" |
| 114 | + const val MINECRAFT_VELOCITY = "https://repo.velocitypowered.com/snapshots/" |
| 115 | + const val MINECRAFT = "https://libraries.minecraft.net/" |
| 116 | + const val MINECRAFT_PAPER = "https://papermc.io/repo/repository/maven-public/" |
| 117 | + const val DESTROYSTOKYO = "https://repo.destroystokyo.com/repository/maven-public/" |
| 118 | + const val SIMPLECLOUD = "https://repo.thesimplecloud.eu/artifactory/list/gradle-release-local/" |
| 119 | +} |
| 120 | +//============================================================================================================ |
0 commit comments