forked from mezz/JustEnoughItems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
251 lines (215 loc) · 6.07 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
import se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
}
}
plugins {
id 'java'
id 'eclipse'
id 'idea'
id "maven-publish"
id "com.diffplug.spotless" version "5.14.3"
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'se.bjurr.gitchangelog.git-changelog-gradle-plugin' version '1.71.4'
}
apply plugin: 'net.minecraftforge.gradle'
apply from: 'buildtools/ColoredOutput.gradle'
//adds the build number to the end of the version string if on a build server
String build_number = System.getenv().BUILD_NUMBER
if (build_number == null) {
build_number = '9999'
}
String semver = "${version_major}.${version_minor}.${version_patch}"
// these two are required for the java plugin to generate jar files with a version
version = "${semver}.${build_number}"
group = 'mezz.jei' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
sourceSets {
api {
//The API has no resources
resources.srcDirs = []
}
main {
compileClasspath += sourceSets.api.output
runtimeClasspath += sourceSets.api.output
}
test {
//The test module has no resources
resources.srcDirs = []
compileClasspath += sourceSets.api.output
runtimeClasspath += sourceSets.api.output
}
}
configurations {
apiImplementation.extendsFrom(implementation)
apiRuntimeOnly.extendsFrom(runtimeOnly)
}
// Mojang ships Java 17 to end users in 1.18+
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
dependencies {
minecraft([
group : "${project.forge_group}",
name : 'forge',
version: "${project.minecraft_version}-${project.forge_version}"
])
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}
minecraft {
mappings channel: 'official', version: project.minecraft_version
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs {
client {
property 'forge.logging.console.level', 'debug'
workingDirectory file('run')
mods {
jei.sources((SourceSet[]) [sourceSets.main, sourceSets.api])
}
}
server {
property 'forge.logging.console.level', 'debug'
workingDirectory file('run')
mods {
jei.sources((SourceSet[]) [sourceSets.main, sourceSets.api])
}
}
}
}
def replaceResources = tasks.register("replaceResources", Copy) {
it.outputs.upToDateWhen { false }
//Copy it into the build dir
it.from(sourceSets.main.resources) {
include "META-INF/mods.toml"
expand 'version': version, 'mc_version': minecraft_version_range, 'forge_version': forge_version_range, "loader_version": loader_version_range
}
it.into "$buildDir/resources/main/"
}
processResources {
duplicatesStrategy(DuplicatesStrategy.FAIL)
exclude('META-INF/mods.toml')
configure { finalizedBy(replaceResources) }
}
classes.configure {
dependsOn(replaceResources)
}
javadoc {
source = [sourceSets.main.allJava, sourceSets.api.allJava]
// prevent java 8's strict doclint for javadocs from failing builds
options.addStringOption('Xdoclint:none', '-quiet')
}
task makeChangelog(type: GitChangelogTask) {
fromRepo = file("$projectDir")
file = file('changelog.html')
untaggedName = "Current release ${project.version}"
fromCommit = '2fe051cf727adce1be210a46f778aa8fe031331e'
toRef = 'HEAD'
templateContent = file('changelog.mustache').getText('UTF-8')
}
curseforge {
apiKey = project.findProperty('curseforge_apikey') ?: '0'
project {
id = curse_project_id
changelog = file('changelog.html')
changelogType = 'html'
releaseType = 'beta'
addGameVersion "${minecraft_version}"
}
}
afterEvaluate {
tasks.curseforge238222.dependsOn makeChangelog
}
jar {
from sourceSets.main.output
from sourceSets.api.output
manifest.attributes([
'Specification-Title' : 'Just Enough Items',
'Specification-Vendor' : 'mezz',
'Specification-Version' : "${semver}",
'Implementation-Title' : project.name,
'Implementation-Version' : "${project.version}",
'Implementation-Vendor' : 'mezz',
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"Automatic-Module-Name": "mezz.jei",
])
finalizedBy 'reobfJar'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
duplicatesStrategy(DuplicatesStrategy.FAIL)
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
duplicatesStrategy(DuplicatesStrategy.FAIL)
archiveClassifier.set('sources')
from sourceSets.main.allJava
from sourceSets.api.allJava
}
task apiJar(type: Jar) {
duplicatesStrategy(DuplicatesStrategy.FAIL)
archiveClassifier.set('api')
from sourceSets.api.output
afterEvaluate { finalizedBy reobfApiJar }
// TODO: when FG bug is fixed, remove allJava from the api jar.
// https://github.com/MinecraftForge/ForgeGradle/issues/369
// Gradle should be able to pull them from the -sources jar.
from sourceSets.api.allJava
}
task deobfJar(type: Jar) {
duplicatesStrategy(DuplicatesStrategy.FAIL)
archiveClassifier.set('deobf')
from sourceSets.main.output
from sourceSets.api.output
}
artifacts {
archives javadocJar
archives sourcesJar
archives apiJar
archives deobfJar
}
reobf {
apiJar { classpath.from(sourceSets.api.compileClasspath) }
jar { classpath.from(sourceSets.main.compileClasspath) }
}
task reobf {
dependsOn reobfJar
dependsOn reobfApiJar
}
publishing {
publications { PublicationContainer publicationContainer ->
publicationContainer.register("maven", MavenPublication) { MavenPublication publication ->
publication.artifacts = [apiJar, jar, javadocJar, deobfJar, sourcesJar]
}
}
repositories {
if (project.hasProperty('DEPLOY_DIR')) {
maven { url DEPLOY_DIR }
}
}
}
idea {
module {
for (String exclude in ['run', 'out', 'logs']) {
excludeDirs += file(exclude)
}
}
}
test {
useJUnitPlatform()
include 'mezz/jei/**'
exclude 'mezz/jei/lib/**'
}
spotless {
java {
target 'src/*/java/mezz/jei/**/*.java'
endWithNewline()
trimTrailingWhitespace()
removeUnusedImports()
}
}
repositories {
mavenCentral()
}