forked from ChiselsAndBits/Chisels-and-Bits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
220 lines (194 loc) · 8.2 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
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
maven { url = 'https://maven.parchmentmc.org' }
mavenLocal()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
name = 'ajoberstar-backup'
url = 'https://ajoberstar.org/bintray-backup/'
}
}
dependencies {
classpath "gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0"
classpath "gradle.plugin.com.matthewprenger:CurseGradle:1.4.0"
classpath "org.zaproxy.gradle:gradle-plugin-crowdin:0.2.1"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3"
classpath 'org.parchmentmc:librarian:1.+'
}
}
apply from: 'https://raw.githubusercontent.com/ldtteam/OperaPublicaCreator/main/gradle/modules/git.gradle'
apply from: 'https://raw.githubusercontent.com/ldtteam/OperaPublicaCreator/main/gradle/modules/util.gradle'
repositories {
mavenCentral()
maven {
name 'LDTTeam - Modding'
url 'https://ldtteam.jfrog.io/ldtteam/modding/'
}
}
version = opc.buildVersionNumberWithOffset(
(System.getenv().containsKey("Version") ? System.getenv("Version") : project.modVersion),
project.exactMinecraftVersion,
opc.getProperty("sourceVersionName"),
opc.getIntProperty("sourceVersionElementIndex"),
opc.getIntProperty("mcVersionElementIndex")
)
subprojects { subProject ->
if (!subProject.getChildProjects().isEmpty())
return;
apply from: 'https://raw.githubusercontent.com/ldtteam/OperaPublicaCreator/main/gradle/modules/git.gradle'
apply from: 'https://raw.githubusercontent.com/ldtteam/OperaPublicaCreator/main/gradle/modules/util.gradle'
apply plugin: 'java'
apply plugin: 'maven-publish'
subProject.version = rootProject.version
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
java.withSourcesJar()
java.withJavadocJar()
jar {
manifest {
attributes([
'Specification-Title' : mod_name,
'Specification-Vendor' : mod_author,
'Specification-Version' : project.jar.archiveVersion,
'Implementation-Title' : project.name,
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : mod_author,
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Timestampe' : System.currentTimeMillis(),
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
'Build-On-Minecraft' : minecraft_version
])
}
}
repositories {
mavenCentral()
maven {
name = 'Sponge / Mixin'
url = 'https://repo.spongepowered.org/repository/maven-public/'
}
maven {
name = 'BlameJared Maven (CrT / Bookshelf)'
url = 'https://maven.blamejared.com'
}
}
dependencies {
// unit testing
testImplementation 'junit:junit:4.11'
testImplementation "org.mockito:mockito-core:1.+"
testImplementation group: 'org.powermock', name: 'powermock-module-junit4', version: '1.6.5'
testImplementation group: 'org.powermock', name: 'powermock-api-mockito', version: '1.6.5'
testImplementation group: 'org.powermock', name: 'powermock-module-junit4-rule-agent', version: '1.6.5'
testImplementation 'org.assertj:assertj-core:3.9.0'
testImplementation group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
testImplementation group: 'org.openjdk.jmh', name: 'jmh-generator-annprocess', version: '1.21'
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
it.options.release = 17
}
tasks.withType(Javadoc.class, {task ->
task.options.tags(
'apiNote:a:API Note:',
'implSpec:a:Implementation Requirements:',
'implNote:a:Implementation Note:',
'reason:a:The reason for adding an @Overwrite'
)
})
publishing {
publications {
mavenJava(MavenPublication) {pub ->
from subProject.components.java
pom {
url = subProject.githubUrl
licenses {
license {
name = 'GNU GENERAL PUBLIC LICENSE Version 3'
url = 'https://www.gnu.org/licenses/gpl-3.0.en.html'
}
}
developers {
developer {
id = 'OrionDevelopment'
name = 'Marc Hermans'
email = '[email protected]'
}
}
scm {
connection = subProject.gitUrl
developerConnection = subProject.gitConnectUrl
url = subProject.projectUrl
}
}
//Replace all deobf dependencies with normal jar references.
pom.withXml { xmlProvider ->
def dependencies = asNode().dependencies
def allDeps = dependencies.'*';
allDeps.findAll {
println it
}
// Remove forge deps
allDeps.findAll() { el ->
el.artifactId.text() == 'forge' && el.groupId.text() == 'net.minecraftforge'
}.forEach() { el ->
el.parent().remove(el)
}
//remove forgegradle's mapped suffix from versions & set as optional so anyone else doesn't inherit them
allDeps.findAll() { el ->
el.version.text().contains('_mapped_')
}.each { el ->
def version = el.version
version.each {
it.setValue(it.text().substring(0, it.text().indexOf('_mapped_')))
}
}
}
}
}
if (System.getenv().containsKey("LDTTeamJfrogUsername") && System.getenv().containsKey("LDTTeamJfrogPassword")) {
repositories {
maven {
name 'LDTTeamJfrog'
credentials {
username System.getenv().get("LDTTeamJfrogUsername")
password System.getenv().get("LDTTeamJfrogPassword")
}
url 'https://ldtteam.jfrog.io/ldtteam/mods-maven'
}
}
}
repositories {
maven {
name 'RepoDirectory'
url 'file://' + rootProject.file('repo').getAbsolutePath()
}
}
}
}
task("createChangelog") {
group = 'upload'
doLast {
def teamCityURL = "https://buildsystem.ldtteam.com/"
project.rootProject.file("build/changelog.md").parentFile.mkdirs()
def file = new FileOutputStream(project.rootProject.file("build/changelog.md"))
def out = new BufferedOutputStream(file)
def changesXML = new XmlSlurper().parse(teamCityURL + "guestAuth/app/rest/changes?locator=build:(id:" + teamcity["teamcity.build.id"] + ")")
def changes = changesXML.change
out << "# Chisels & Bits Changelog \n"
out << "## Version: _" + version + "_ \n"
out << "### Changes: \n"
if (changes.size() > 0) {
for (int i = 0; i < changes.size(); i++) {
def changeDetailsURL = teamCityURL + "guestAuth/app/rest/changes/id:" + changes[i][email protected]()
def changeDetailsXml = new XmlSlurper().parse(changeDetailsURL)
def changeComment = changeDetailsXml.comment.text().trim()
out << "* " + changeComment + "\n"
}
} else {
out << "_No Changes detected!_"
}
out.close()
}
}