This repository was archived by the owner on Apr 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
113 lines (98 loc) · 3.74 KB
/
build.gradle.kts
File metadata and controls
113 lines (98 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
buildscript {
repositories {
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath("com.github.jengelman.gradle.plugins:shadow:6.1.0")
}
}
fun getCommitHash(): String = try {
val runtime = Runtime.getRuntime()
val process = runtime.exec("git rev-parse --short HEAD")
val out = process.inputStream
out.bufferedReader().readText().trim()
} catch (ignored: Exception) {
"unknown"
}
//Define Plugins
plugins {
id("java")
id("maven-publish")
id("com.github.johnrengelman.shadow") version "6.1.0"
kotlin("jvm") version "1.6.10"
}
//Define Repositorys
repositories {
mavenCentral()
maven("https://repo.cloudnetservice.eu/repository/releases/")
}
//Define Version and Group
group = "me.infinity.cloudnetmongodb"
version = "2.1.0"
//Define Dependencies for all Modules
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.6.10")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
implementation("org.mongodb:mongodb-driver-sync:4.4.1")
compileOnly("de.dytanic.cloudnet:cloudnet:3.4.2-RELEASE")
}
tasks {
//Set the Name of the Sources Jar
kotlinSourcesJar {
archiveFileName.set("${project.name}-${project.version}-${getCommitHash()}-sources.jar")
doFirst {
//Set Manifest
manifest {
attributes["Implementation-Title"] = project.name
attributes["Implementation-Version"] = findProperty("version").toString()
attributes["Specification-Version"] = findProperty("version").toString()
attributes["Implementation-Vendor"] = "Florin Dornig"
attributes["Built-By"] = System.getProperty("user.name")
attributes["Build-Jdk"] = System.getProperty("java.version")
attributes["Created-By"] = "Gradle ${gradle.gradleVersion}"
attributes["Commit-Hash"] = getCommitHash()
}
}
}
shadowJar {
//Set the Name of the Output File
archiveFileName.set("${project.name}-${project.version}-${getCommitHash()}-full.jar")
exclude("META-INF/**")
doFirst {
//Set Manifest
manifest {
attributes["Implementation-Title"] = project.name
attributes["Implementation-Version"] = findProperty("version").toString()
attributes["Specification-Version"] = findProperty("version").toString()
attributes["Implementation-Vendor"] = "Florin Dornig"
attributes["Built-By"] = System.getProperty("user.name")
attributes["Build-Jdk"] = System.getProperty("java.version")
attributes["Created-By"] = "Gradle ${gradle.gradleVersion}"
attributes["Commit-Hash"] = getCommitHash()
}
}
}
jar {
archiveFileName.set("${project.name}-${project.version}-${getCommitHash()}.jar")
doFirst {
//Set Manifest
manifest {
attributes["Implementation-Title"] = project.name
attributes["Implementation-Version"] = findProperty("version").toString()
attributes["Specification-Version"] = findProperty("version").toString()
attributes["Implementation-Vendor"] = "Florin Dornig"
attributes["Built-By"] = System.getProperty("user.name")
attributes["Build-Jdk"] = System.getProperty("java.version")
attributes["Created-By"] = "Gradle ${gradle.gradleVersion}"
attributes["Commit-Hash"] = getCommitHash()
}
}
}
compileKotlin {
kotlinOptions.jvmTarget = "11"
}
withType<JavaCompile> {
this.options.encoding = "UTF-8"
}
}