-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
140 lines (119 loc) · 3.93 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
plugins {
id 'idea'
id 'maven-publish'
}
def javaVersion = 21
group = maven_group_id
def ENV = System.getenv()
def NOW = new Date()
def buildTime = ENV.BUILD_TIME ?: NOW.format('yyyyMMddHHmmss')
boolean isPreviewBuild = !ENV.TAG || ENV.TAG.matches(".+-.+")
def buildNumber = !ENV.TAG ? ("${ENV.BUILD_NUMBER ? "build.${ENV.BUILD_NUMBER}" : buildTime}") : ""
version = (ENV.TAG ?: "${libs.versions.minecraft.get()}-development") + ((isPreviewBuild && !ENV.TAG) ? "+${buildNumber}" : "")
def mod_name = rootProject.name.replaceAll("-", "_").toLowerCase(Locale.ROOT)
println("Building ${project.name} ${version}")
subprojects {
apply plugin: 'java-library'
project.group = rootProject.group
project.version = rootProject.version
java {
toolchain {
languageVersion = JavaLanguageVersion.of(javaVersion)
vendor = JvmVendorSpec.MICROSOFT
}
withSourcesJar()
withJavadocJar()
}
javadoc {
options.tags = ["reason"]
}
base {
archivesName = "${rootProject.name}-${project.name}"
}
jar {
from(rootProject.file("LICENSE.md")) {
rename { "LICENSE_${mod_name}.md" }
}
manifest {
attributes([
'Specification-Title' : rootProject.name,
'Specification-Version' : project.version,
'Implementation-Title' : "${rootProject.name}-${project.name}",
'Maven-Artifact' : "${maven_group_id}:${rootProject.name}-${project.name}:${project.version}",
'Implementation-Version' : project.version,
'Implementation-Timestamp' : NOW.format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Timestamp' : NOW.toInstant().toEpochMilli(),
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
'Built-On-Minecraft' : libs.versions.minecraft.get()
])
}
}
sourcesJar {
from(rootProject.file("LICENSE.md")) {
rename { "LICENSE_${mod_name}.md" }
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release.set(javaVersion)
}
processResources {
filteringCharset "UTF-8"
def expandProps = [
"version" : version,
"maven_group_id" : maven_group_id,
"mod_id" : mod_id,
"mod_display_name" : mod_display_name,
"mod_description" : mod_description,
"sources_url" : sources_url,
"issues_url" : issues_url,
"license_url" : license_url,
"discord_url" : discord_url,
"homepage_url" : homepage_url,
"minecraft_version" : libs.versions.minecraft.get(),
"curseforge_id" : curseforge_id,
"modrinth_id" : modrinth_id,
"fabric_loader_version" : fabric.versions.fabric.loader.get(),
"java_version" : javaVersion
]
filesMatching(['pack.mcmeta', '*.mod.json', 'META-INF/*mods.toml', '*.mixins.json']) {
expand expandProps
}
inputs.properties(expandProps)
}
publishing {
publications {
"mavenJava${project.name}"(MavenPublication) {
artifactId "${rootProject.name}-${project.name}"
from components.java
}
}
}
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}
}
publishing {
repositories {
if (ENV.MAVEN_UPLOAD_URL) {
maven {
url = ENV.MAVEN_UPLOAD_URL
credentials {
username = ENV.MAVEN_UPLOAD_USERNAME
password = ENV.MAVEN_UPLOAD_PASSWORD
}
}
}
}
}
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}