-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
210 lines (181 loc) · 6.14 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
plugins {
id 'fabric-loom' version '0.9-SNAPSHOT'
id 'maven-publish'
id 'org.cadixdev.licenser' version '0.6.1'
//id "checkstyle"
}
def env = System.getenv()
version = project.modVersion + '.' + env.BUILD_NUMBER ?: 'local'
group = project.mavenGroup
dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraftVersion}"
mappings "net.fabricmc:yarn:${project.yarnMappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loaderVersion}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.apiVersion}"
}
sourceSets {
code {
compileClasspath += sourceSets.main.compileClasspath
compileClasspath += configurations.minecraftNamed
runtimeClasspath += sourceSets.main.runtimeClasspath
compileClasspath += configurations.minecraftNamed
}
data {
compileClasspath += sourceSets.code.compileClasspath
compileClasspath += sourceSets.code.output
runtimeClasspath += sourceSets.code.compileClasspath
runtimeClasspath += sourceSets.code.output
}
}
//checkstyle {
// configFile = rootProject.file("checkstyle.xml")
// toolVersion = '8.31'
//}
license {
header = file('HEADER.txt')
include '**/*.java'
style.java = 'BLOCK_COMMENT'
newLine = false
}
tasks.withType(JavaCompile) {
options.release = 16
options.encoding = "UTF-8"
}
tasks.withType(Javadoc) {
options {
source = "16"
encoding = 'UTF-8'
charSet = 'UTF-8'
memberLevel = JavadocMemberLevel.PACKAGE
quiet()
// https://docs.oracle.com/en/java/javase/17/docs/specs/man/javadoc.html#additional-options-provided-by-the-standard-doclet
addBooleanOption 'Xdoclint:none', true
}
}
tasks.withType(Jar) {
from "LICENSE"
}
def dataDir = file("$buildDir/datadump/")
def dataCacheDir = file("$dataDir/.cache/")
def outputDirectory = file("$buildDir/pom-properties")
def pomProperties = file("$outputDirectory/pom.properties")
task generateData(type: JavaExec) {
enabled = false
doFirst {
dataDir.mkdirs()
}
classpath = sourceSets.data.runtimeClasspath
mainClass = project.dataEntry
// arguments to pass to the application
workingDir dataDir
inputs.files sourceSets.data.output
outputs.dir dataDir
args dataDir.getAbsolutePath()
doLast {
dataCacheDir.delete()
}
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set "sources"
from sourceSets.code.allSource
from "LICENSE"
}
javadoc {
source = sourceSets.code.allJava
classpath = sourceSets.code.compileClasspath
options {
if (file("readme.html").exists()) {
overview = "readme.html"
}
links(
"https://maven.fabricmc.net/docs/fabric-api-${project.apiVersion}/",
"https://maven.fabricmc.net/docs/fabric-loader-${project.loaderVersion}/",
//"https://maven.fabricmc.net/docs/yarn-${project.yarnMappings}/", // mapping jd broke for now
'https://guava.dev/releases/21.0/api/docs/',
'https://asm.ow2.io/javadoc/',
'https://logging.apache.org/log4j/2.x/log4j-api/apidocs/',
'https://docs.oracle.com/en/java/javase/16/docs/api/'
// Need to add minecraft jd publication once there is one available
)
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set "javadoc"
from javadoc.destinationDir
}
jar {
dependsOn generateData
from sourceSets.code.output
}
//processResources {
//from(generateData.outputs.files) {
// include "/data/"
//}
//from sourceSets.code.resources.srcDirs
//inputs.properties "version": project.version, "description": project.description
//filesMatching(['fabric.mod.json', 'pack.mcmeta']]) {
// expand(
// "version": project.version,
// "description": project.description,
// "repoOwner": project.repoOwner,
// "repoName": project.repoName,
// "id": project.modId,
// "minecraftVersionLimit": project.minecraftVersionLimit,
// "loaderVersionLimit": project.loaderVersionLimit
// )
//}
//}
artifacts {
archives remapJar
archives(sourcesJar) {
classifier = "sources"
builtBy remapSourcesJar
}
archives javadocJar
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
pom {
name = project.name
description = project.description
url = "https://github.com/${project.repoOwner}/${project.repoName}"
licenses {
license {
name = project.codeLicense
}
}
scm {
url = "https://github.com/${project.repoOwner}/${project.repoName}"
}
}
// add all the jars that should be included when publishing to maven
afterEvaluate {
artifact remapJar
artifact(sourcesJar) {
classifier = "sources"
builtBy remapSourcesJar
}
artifact javadocJar
}
}
}
if (env.GITHUB_TOKEN) {
// select the repositories you want to publish to
repositories {
maven {
name = "GitHub"
url = uri("https://maven.pkg.github.com/${project.repoOwner}/${project.repoName}")
credentials {
username = env.GITHUB_ACTOR
password = env.GITHUB_TOKEN
}
}
}
}
}