Skip to content

Commit 3fdd8f7

Browse files
committed
Initial commit
0 parents  commit 3fdd8f7

13 files changed

Lines changed: 669 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
### JetBrains template
2+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
3+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
4+
5+
# User-specific stuff
6+
.idea/**/workspace.xml
7+
.idea/**/tasks.xml
8+
.idea/**/usage.statistics.xml
9+
.idea/**/dictionaries
10+
.idea/**/shelf
11+
12+
# Generated files
13+
.idea/**/contentModel.xml
14+
15+
# Sensitive or high-churn files
16+
.idea/**/dataSources/
17+
.idea/**/dataSources.ids
18+
.idea/**/dataSources.local.xml
19+
.idea/**/sqlDataSources.xml
20+
.idea/**/dynamic.xml
21+
.idea/**/uiDesigner.xml
22+
.idea/**/dbnavigator.xml
23+
24+
# Gradle
25+
.idea/**/gradle.xml
26+
.idea/**/libraries
27+
28+
# Gradle and Maven with auto-import
29+
# When using Gradle or Maven with auto-import, you should exclude module files,
30+
# since they will be recreated, and may cause churn. Uncomment if using
31+
# auto-import.
32+
# .idea/artifacts
33+
# .idea/compiler.xml
34+
# .idea/jarRepositories.xml
35+
# .idea/modules.xml
36+
# .idea/*.iml
37+
# .idea/modules
38+
# *.iml
39+
# *.ipr
40+
41+
# CMake
42+
cmake-build-*/
43+
44+
# Mongo Explorer plugin
45+
.idea/**/mongoSettings.xml
46+
47+
# File-based project format
48+
*.iws
49+
50+
# IntelliJ
51+
out/
52+
53+
# mpeltonen/sbt-idea plugin
54+
.idea_modules/
55+
56+
# JIRA plugin
57+
atlassian-ide-plugin.xml
58+
59+
# Cursive Clojure plugin
60+
.idea/replstate.xml
61+
62+
# Crashlytics plugin (for Android Studio and IntelliJ)
63+
com_crashlytics_export_strings.xml
64+
crashlytics.properties
65+
crashlytics-build.properties
66+
fabric.properties
67+
68+
# Editor-based Rest Client
69+
.idea/httpRequests
70+
71+
# Android studio 3.1+ serialized cache file
72+
.idea/caches/build_file_checksums.ser
73+
74+
### Gradle template
75+
.gradle
76+
**/build/
77+
!src/**/build/
78+
79+
# Ignore Gradle GUI config
80+
gradle-app.setting
81+
82+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
83+
!gradle-wrapper.jar
84+
85+
# Cache of project
86+
.gradletasknamecache
87+
88+
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
89+
# gradle/wrapper/gradle-wrapper.properties
90+

‎Jenkinsfile‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
def remote = [:]
2+
remote.name = "devserver"
3+
remote.host = "devserver.NeverStopGaming.net"
4+
remote.allowAnyHosts = true
5+
pipeline {
6+
7+
agent any
8+
9+
tools {
10+
jdk 'jdk-16'
11+
}
12+
13+
stages {
14+
stage("Clean") {
15+
steps {
16+
sh "chmod +x ./gradlew";
17+
sh "./gradlew clean";
18+
}
19+
}
20+
stage("Build") {
21+
steps {
22+
withCredentials([usernamePassword(credentialsId: 'nexus', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
23+
sh "./gradlew build --refresh-dependencies -DpublishPassword=$PASSWORD -DpublishName=$USERNAME"
24+
}
25+
}
26+
}
27+
stage("Publish") {
28+
steps {
29+
withCredentials([usernamePassword(credentialsId: 'nexus', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
30+
sh "./gradlew publish -DpublishPassword=$PASSWORD -DpublishName=$USERNAME"
31+
}
32+
}
33+
}
34+
stage("Build Shadow Jar") {
35+
steps {
36+
sh "./gradlew shadowJar"
37+
}
38+
post {
39+
success {
40+
archiveArtifacts artifacts: 'build/libs/*.jar', fingerprint: true
41+
}
42+
}
43+
}
44+
stage("SSH") {
45+
steps {
46+
script {
47+
withCredentials([usernamePassword(credentialsId: "devserver", passwordVariable: 'password', usernameVariable: 'userName')]) {
48+
remote.user = userName
49+
remote.password = password
50+
}
51+
}
52+
sshPut remote: remote, from: 'build/libs/ProxySystem-1.0.jar', into: "/home/cloud/templates/Proxy/plugins/"
53+
sshCommand remote: remote, command: "screen -S SimpleCloud -X stuff 'leave\nshutdowngroup Proxy\n'"
54+
}
55+
}
56+
}
57+
}

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Gradle template
2+

‎build.gradle.kts‎

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
3+
plugins {
4+
kotlin("jvm") version "1.5.31"
5+
id("maven-publish")
6+
id("com.github.johnrengelman.shadow") version "6.1.0"
7+
}
8+
9+
buildscript {
10+
repositories {
11+
gradlePluginPortal()
12+
mavenCentral()
13+
}
14+
dependencies {
15+
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.5.0")
16+
classpath("com.github.jengelman.gradle.plugins:shadow:6.1.0")
17+
}
18+
}
19+
20+
group = "net.neverstopgaming"
21+
version = "1.0"
22+
23+
repositories {
24+
mavenCentral()
25+
for (field in Repositories::class.java.declaredFields) {
26+
if (field.name != "INSTANCE") {
27+
println("Added Repository: " + field.get(null))
28+
maven(field.get(null))
29+
}
30+
}
31+
maven {
32+
url = uri("https://repo.neverstopgaming.net/repository/maven-internal/")
33+
credentials {
34+
this.username = System.getenv("repoName") ?: System.getenv("NEXUS_USER") ?: System.getProperty("publishName")
35+
this.password = System.getenv("repoPassword") ?: System.getenv("NEXUS_PASSWORD") ?: System.getProperty("publishPassword")
36+
}
37+
}
38+
}
39+
40+
dependencies {
41+
testImplementation(kotlin("test"))
42+
compileOnly(getDependency("simplecloud", "plugin"))
43+
compileOnly(getDependency("nsg", "api"))
44+
compileOnly(getDependency("nsg", "core"))
45+
compileOnly(getDependency("components", "minimessage"))
46+
}
47+
48+
tasks.test {
49+
useJUnit()
50+
}
51+
52+
tasks.withType<KotlinCompile>() {
53+
kotlinOptions.jvmTarget = "1.8"
54+
}
55+
56+
if (System.getProperty("publishName") != null && System.getProperty("publishPassword") != null) {
57+
publishing {
58+
(components["java"] as AdhocComponentWithVariants).withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
59+
skip()
60+
}
61+
publications {
62+
create<MavenPublication>(project.name) {
63+
groupId = Properties.group
64+
artifactId = project.name
65+
version = Properties.version
66+
from(components["java"])
67+
pom {
68+
name.set(project.name)
69+
url.set("https://github.com/NeverStopGaming/Backend")
70+
properties.put("inceptionYear", "2021")
71+
licenses {
72+
license {
73+
name.set("All Rights Reserved")
74+
url.set("All Rights Reserved")
75+
distribution.set("repo")
76+
}
77+
}
78+
developers {
79+
developer {
80+
id.set("Chaoten")
81+
name.set("Ben Chaoten")
82+
email.set("chaoten@NeverStopGaming.net")
83+
}
84+
}
85+
}
86+
}
87+
repositories {
88+
maven("https://repo.NeverStopGaming.net/repository/maven-internal/") {
89+
this.name = "maven-internal"
90+
credentials {
91+
this.password = System.getProperty("publishPassword")
92+
this.username = System.getProperty("publishName")
93+
}
94+
}
95+
}
96+
}
97+
}
98+
}

‎buildSrc/build.gradle.kts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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+
//============================================================================================================

‎gradle.properties‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kotlin.code.style=official

‎gradle/wrapper/gradle-wrapper.jar‎

58.1 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)