-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild.gradle
226 lines (189 loc) · 7.32 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
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'org.cadixdev.licenser' version '0.6.1'
}
apply plugin: 'maven-publish' // for uploading to a maven repo
if (gradle.startParameter.taskNames.contains("checkstyle")) {
apply plugin: "checkstyle"
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
repositories {
mavenLocal()
maven { name="Modmuss50"; url="https://maven.modmuss50.me/" }
maven { name="AlexIIL"; url="https://maven.alexiil.uk/" }
}
archivesBaseName = "libblockatttributes"
version = "0.14.0"
license {
header = project.file('misc/LICENSE_HEADER.txt');
newLine = false;
}
dependencies {
minecraft "com.mojang:minecraft:1.20"
mappings "net.fabricmc:yarn:1.20+build.1:v2"
modCompileOnly "net.fabricmc:fabric-loader:0.14.21"
modLocalRuntime "net.fabricmc:fabric-loader:0.14.21"
//Fabric api
modCompileOnly "net.fabricmc.fabric-api:fabric-api:0.83.0+1.20"
modLocalRuntime "net.fabricmc.fabric-api:fabric-api:0.83.0+1.20"
// Item-inventory
//modImplementation("com.github.emilyploszaj:item-inventory:v1.1.0") { transitive = false }
// Misc
implementation "com.google.code.findbugs:jsr305:3.0.1"
testImplementation "junit:junit:4.12"
}
test {
// Yarn for 1.18.2 doesn't work for tests ATM
// java.lang.IllegalAccessError: class net.minecraft.world.gen.chunk.ChunkGeneratorSettings
// tried to access protected method 'net.minecraft.world.gen.noise.SimpleNoiseRouter net.minecraft.world.gen.densityfunction.DensityFunctions.method_41103(net.minecraft.world.gen.chunk.GenerationShapeConfig, boolean)'
// (net.minecraft.world.gen.chunk.ChunkGeneratorSettings and net.minecraft.world.gen.densityfunction.DensityFunctions are in unnamed module of loader 'app')
enabled = false
}
sourceSets {
main {
java {
srcDir "src/fatjar/java"
exclude "alexiil/mc/lib/attributes/item/compat/mod/emi/iteminv/**"
}
}
}
task checkstyle {}
if (gradle.startParameter.taskNames.contains("checkstyle")) {
checkstyle {
configFile = file("guidelines/lba.checkstyle")
toolVersion = "8.35"
}
tasks["checkstyle"].dependsOn checkstyleMain
tasks["checkstyleMain"].enabled = true
tasks["checkstyleTest"].enabled = false
}
processResources {
inputs.property "version", project.version
duplicatesStrategy = DuplicatesStrategy.FAIL
filesMatching('fabric.mod.json', {
filter({str -> str.replace("$version", project.version)});
})
}
compileJava {
options.compilerArgs << "-Xmaxerrs" << "2000"
options.compilerArgs << "-Xmaxwarns" << "2"
options.compilerArgs << "-Xlint:all"
options.compilerArgs << "-Xdiags:verbose"
}
javadoc {
exclude "alexiil/mc/lib/attributes/mixin";
exclude "alexiil/mc/lib/attributes/fluid/mixin/impl";
exclude "alexiil/mc/lib/attributes/fatjar";
options.group("Items Module", "alexiil.mc.lib.attributes.item*");
options.group("Fluids Module", "alexiil.mc.lib.attributes.fluid*");
options.group("Core Module", "alexiil.mc.lib.attributes*");
destinationDir file(new File(System.getenv("JAVADOC_DIR") ?: "$projectDir/build/javadoc", "$version"));
options.optionFiles << file('javadoc.options');
}
build.dependsOn(javadoc);
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
it.options.release = 17
}
java.withSourcesJar()
new File("run/").mkdirs();
test {
workingDir = "run/"
}
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
if (System.getenv("UPLOAD_MAVEN_URL") != null) {
task packageJavadoc(type: Zip, dependsOn: javadoc) {
from javadoc.destinationDir
archiveFileName = "libnetworkstack-javadoc-" + version + ".zip"
}
task uploadJavadoc(dependsOn: packageJavadoc) {
doLast {
HttpClient cl = HttpClient.newBuilder().authenticator(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(System.getenv("UPLOAD_USERNAME"), System.getenv("UPLOAD_PASSWORD").toCharArray());
}
}).build();
java.io.File file = packageJavadoc.outputs.files.singleFile;
java.nio.file.Path path = file.toPath();
HttpRequest put = HttpRequest.newBuilder()
.PUT(HttpRequest.BodyPublishers.ofFile(path))
.uri(new URI(System.getenv("UPLOAD_MAVEN_URL") + "/tmp-javadocs/" + file.getName()))
.build();
HttpResponse<String> response = cl.send(put, HttpResponse.BodyHandlers.ofString());
if ((int)(response.statusCode() / 100) != 2) {
println(response.statusCode());
println(response.body());
throw new Error("Upload Javadoc Zip Failed!");
}
}
}
}
publishing {
repositories {
if (System.getenv("UPLOAD_MAVEN_URL") != null) {
maven {
url System.getenv("UPLOAD_MAVEN_URL");
credentials {
username System.getenv("UPLOAD_USERNAME");
password System.getenv("UPLOAD_PASSWORD");
}
}
} else {
maven {
url System.getenv("MAVEN_DIR") ?: "$projectDir/build/maven"
}
}
}
}
// #####################
//
// Extra jar section
//
// #####################
apply from: "extra_jar_def.gradle"
ext.mainName = "libblockattributes"
ext.mavenGroupId = "alexiil.mc.lib";
ext.extra_jar_def__optimised_compression = true;
ext.extra_jar_def__common_manifest.put(null, ['Sealed': 'true']);
// Custom modules
def itemsIncludes = [
"alexiil/mc/lib/attributes/item/**",
"assets/libblockattributes/icon_items.png",
"libblockattributes_item.common.json"
];
def fluidsIncludes = [
"alexiil/mc/lib/attributes/fluid/**",
"assets/libblockattributes/lang/**",
"assets/libblockattributes/textures/fluid/**",
"assets/libblockattributes/icon_fluids.png",
"libblockattributes_fluid.common.json",
"libblockattributes_fluid.client.json"
];
def allIncludes = [
"assets/libblockattributes/icon_all.png"
];
def coreExclude = new HashSet<>();
coreExclude.addAll(itemsIncludes);
coreExclude.addAll(fluidsIncludes);
coreExclude.add("alexiil/mc/lib/attributes/fatjar/**");
itemsIncludes.add("assets/libblockattributes/icon_all.png")
fluidsIncludes.add("assets/libblockattributes/icon_all.png")
def jsr305 = ["com.google.code.findbugs", "jsr305", "3.0.1"]
generateJar("core", ["**"], coreExclude, true, [], [], [jsr305]);
generateJar("items", itemsIncludes, [], true, ["core"], [], [jsr305]);
generateJar("fluids", fluidsIncludes, [], true, ["core"], [], [jsr305]);
generateJar("all", allIncludes, [], false, [], ["core", "items", "fluids"], [jsr305]);
generateFatJar("fatjar_devonly", ["**"], [], false, [], ["core", "items", "fluids"], [jsr305]);
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}