-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
141 lines (113 loc) · 3.28 KB
/
build.gradle
File metadata and controls
141 lines (113 loc) · 3.28 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
buildscript {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath 'com.gradleup.shadow:shadow-gradle-plugin:+'
}
}
plugins {
id 'org.gradlex.extra-java-module-info' version '1.12'
}
apply plugin: 'com.gradleup.shadow'
apply plugin: 'java'
apply plugin: 'maven-publish'
group = 'org.mangorage'
version = getLatestGitTag() + "." + getLatestGitVersion()
println("Version: " + version)
extraJavaModuleInfo {
setDeriveAutomaticModuleNamesFromFileNames(true)
}
def getLatestGitTag() {
def result = "git describe --long --tags".execute().text.trim()
if (result.empty) {
throw new RuntimeException("Failed to retrieve commit count")
} else {
return result.split("-")[0]
}
}
def getLatestGitVersion() {
def result = "git describe --long --tags".execute().text.trim()
if (result.empty) {
throw new RuntimeException("Failed to retrieve commit count")
} else {
def commitCount = result.split("-")[1].toInteger()
return commitCount
}
}
repositories {
mavenCentral()
}
java {
modularity.inferModulePath = true
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
dependencies {
testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
implementation 'net.sf.jopt-simple:jopt-simple:5.0.4'
implementation 'com.google.code.gson:gson:2.10.1'
shadow 'net.sf.jopt-simple:jopt-simple:5.0.4'
shadow 'com.google.code.gson:gson:2.10.1'
}
test {
useJUnitPlatform()
}
jar {
manifest {
attributes(
'Main-Class': 'org.mangorage.installer.Installer',
'ModuleMainClass': 'org.mangorage.installer.Installer'
)
}
}
task runInstaler(type: JavaExec) {
group = 'Installer Tasks'
description = 'Runs the main class in the build/run directory'
mainClass.set('org.mangorage.installer.Installer') // replace with your actual main class
classpath = sourceSets.main.runtimeClasspath
workingDir = file("$buildDir/run")
doFirst {
workingDir.mkdirs() // Make sure the directory exists
}
}
shadowJar {
group "main tasks"
archiveClassifier.set('')
excludes.remove('module-info.class')
relocate('com.google.gson', 'internal.shaded.com.google.gson')
relocate('joptsimple', 'internal.shaded.joptsimple')
}
publishing {
publications.register("installer", MavenPublication) {
artifact shadowJar
pom {
name = 'MangoBot Installer'
description = 'The Installer for my Discord Bot Project'
url = 'https://github.com/MangoRageBot/Installer'
issueManagement {
system = 'github'
url = 'https://github.com/MangoRageBot/Installer/issues'
}
developers {
developer {
id = 'mangorage'
name = 'MangoRage'
}
}
}
}
repositories {
maven {
url = "https://maven.mangorage.org/releases/"
credentials {
username = System.getenv("MAVEN_USER")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
}