forked from TheCurle/Camelot
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
180 lines (148 loc) · 4.73 KB
/
build.gradle
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import net.neoforged.gradleutils.PomUtilsExtension
import java.nio.file.Files
plugins {
id 'java-library'
id 'maven-publish'
id 'net.neoforged.gradleutils' version '3.0.0-alpha.13'
id 'com.github.johnrengelman.shadow' version '7.+'
}
group 'net.neoforged.camelot'
println("Version: ${version = gradleutils.version}")
gradleutils {
setupCentralPublishing()
setupSigning(signAllPublications: true)
}
tasks.register('run', JavaExec).configure {
classpath(sourceSets.main.runtimeClasspath)
mainClass.set('net.neoforged.camelot.BotMain')
jvmArgs('--enable-preview')
workingDir = project.file('run')
doFirst {
if (!workingDir.exists()) {
Files.createDirectories(workingDir.toPath())
}
}
javaLauncher.set(project.javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(21)
})
}
abstract class Log extends DefaultTask {
@OutputFile
abstract RegularFileProperty getOutput()
Log() {
outputs.upToDateWhen { false }
}
@TaskAction
void exec() {
new ProcessBuilder('git', 'log', '-5', '--pretty=oneline')
.redirectOutput(getOutput().asFile.get())
.start().waitFor()
}
}
tasks.register('gitLog', Log) {
it.output.set(new File(project.buildDir, 'gitlog'))
}
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
java.toolchain.vendor = JvmVendorSpec.GRAAL_VM
java {
withJavadocJar()
withSourcesJar()
}
compileJava {
options.encoding = 'UTF-8'
options.compilerArgs.add('--enable-preview')
}
javadoc {
final opt = options as CoreJavadocOptions
opt.addStringOption('-release', '21')
opt.addBooleanOption('-enable-preview', true)
}
evaluationDependsOn(':config')
configurations {
library.extendsFrom(implementation)
module
runtimeClasspath.extendsFrom(module, library)
}
dependencies {
implementation project(':config')
api libs.chewtils
api libs.jda
implementation libs.trove4j
implementation libs.guava
implementation libs.logback
implementation libs.bundles.database
// YML parsing and generation
implementation libs.bundles.jackson
// GitHub API interaction library
implementation libs.githubapi
// GitHub api JWT generation
implementation libs.bundles.jjwt
// Converting private keys for GitHub auth
implementation libs.bcpkix
implementation libs.bundles.graal
implementation libs.args4j
implementation libs.fastutil
implementation libs.semver
implementation libs.mavenartifact
implementation(libs.javalin.get()) {
exclude module: 'slf4j-api'
}
implementation libs.j2html
implementation libs.angusmail
implementation libs.json
compileOnly(annotationProcessor(libs.autoservice.get()))
compileOnlyApi(libs.annotations)
testImplementation(libs.bundles.testing)
project(':modules').subprojects.each {
library(project(path: it.path, configuration: 'library'))
configurations.module.dependencies.add(dependencies.create(it) {
transitive = false
})
}
}
jar {
manifest.attributes([
'Maven-Artifact': "${project.group}:${archivesBaseName}:${project.version}",
'Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Specification-Title': archivesBaseName,
'Specification-Vendor': 'NeoForged',
'Specification-Version': '1',
'Implementation-Title': archivesBaseName,
'Implementation-Version': "${project.version}",
'Implementation-Vendor': 'NeoForged',
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Built-On-Java': "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
'Main-Class': 'net.neoforged.camelot.BotMain'
])
}
tasks.register('outputVersion') {
doLast {
file(System.getenv('GITHUB_ENV')) << "\nBOT_VERSION=${project.version}"
}
}
shadowJar {
mergeServiceFiles()
archiveClassifier = 'all'
archiveFile.set(project.file("$buildDir/libs/camelot-all.jar"))
dependsOn(tasks.gitLog)
from(tasks.gitLog.output)
configurations = [project.configurations.library, project.configurations.module]
}
test {
useJUnitPlatform()
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifactId = 'camelot'
pom {
name = 'Camelot'
description = 'The Camelot Discord bot'
rootProject.pomUtils.githubRepo(it, 'Camelot')
rootProject.pomUtils.neoForgedDeveloper(it)
rootProject.pomUtils.license(it, PomUtilsExtension.License.MIT)
}
}
}
}