forked from neoforged/NeoForge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
108 lines (93 loc) · 3.11 KB
/
build.gradle
File metadata and controls
108 lines (93 loc) · 3.11 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
import java.util.regex.Matcher
import java.util.regex.Pattern
plugins {
id 'net.neoforged.gradleutils' version '3.0.0-alpha.10' apply false
id 'com.diffplug.spotless' version '6.22.0' apply false
id 'net.neoforged.licenser' version '0.7.2' apply false
}
apply plugin: 'net.neoforged.gradleutils'
gradleutils.version {
minecraftVersion project.minecraft_version
versionPrefix = null // Reset version prefix, which is set by prev. line
tags {
label = 'beta'
cleanMarkerLabel = 'stable'
}
branches {
suffixBranch = true
}
}
changelog {
from "20.2"
disableAutomaticPublicationRegistration()
}
// Print version, generally useful to know - also appears on CI
System.out.println("NeoForge version ${gradleutils.version.toString()}")
allprojects {
version gradleutils.version.toString()
group 'net.neoforged'
repositories {
mavenLocal()
}
}
apply plugin: 'com.diffplug.spotless'
apply plugin: 'net.neoforged.licenser'
repositories {
mavenCentral()
}
// Put licenser here otherwise it tries to license all source sets including decompiled MC sources
license {
header = file('codeformat/HEADER.txt')
skipExistingHeaders = true
tasks {
neoforge {
// Add all NeoForge sources
files.from rootProject.fileTree("src", {
include "**/*.java"
})
}
}
}
// Put spotless here because it wants the files to live inside the project root
spotless {
java {
target rootProject.fileTree("src", {
include "**/*.java"
})
endWithNewline()
indentWithSpaces()
removeUnusedImports()
toggleOffOn()
eclipse().configFile file('codeformat/formatter-config.xml')
importOrder()
// courtesy of diffplug/spotless#240
// https://github.com/diffplug/spotless/issues/240#issuecomment-385206606
custom 'noWildcardImports', { String fileContents ->
if (fileContents.contains('*;\n')) {
throw new GradleException('No wildcard imports are allowed!')
}
}
bumpThisNumberIfACustomStepChanges(1)
}
format 'patches', {
target rootProject.fileTree("patches")
custom 'noImportChanges', { String fileContents ->
if (fileContents.contains('+import') || fileContents.contains('-import')) {
throw new GradleException("Import changes are not allowed in patches!")
}
return fileContents
}
//Trim any trailing whitespace from patch additions
def trailingWhitespace = Pattern.compile('^\\+.*[ \t]+\$', Pattern.UNIX_LINES | Pattern.MULTILINE)
custom 'trimTrailingWhitespacePatches', { String fileContents ->
Matcher matcher = trailingWhitespace.matcher(fileContents)
StringBuilder sb = new StringBuilder()
while (matcher.find()) {
matcher.appendReplacement(sb, matcher.group().trim())
}
matcher.appendTail(sb)
return sb.toString()
}
bumpThisNumberIfACustomStepChanges(2)
}
}