-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
183 lines (168 loc) · 6.64 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
subprojects {
apply plugin: 'maven-publish'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(java_version)
vendor = JvmVendorSpec.ADOPTOPENJDK
}
withSourcesJar()
withJavadocJar()
}
if (System.getenv('RELEASE_TYPE') != null) {
status = System.getenv('RELEASE_TYPE').toLowerCase()
if (status != 'release') {
if (status == 'snapshot') status = status.toUpperCase()
version = "${version}-${status}"
}
} else {
version = "${version}-SNAPSHOT"
}
archivesBaseName = "${mod_name}-${project.name.toLowerCase()}-${minecraft_version}"
jar {
from("LICENSE") {
rename { "${it}_${mod_name}" }
}
manifest {
mainAttributes([
'Specification-Title' : mod_name,
'Specification-Vendor' : author,
'Specification-Version' : project.jar.archiveVersion,
'Implementation-Title' : project.name,
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : 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,
'LICENSE' : 'MIT'
])
}
}
repositories {
mavenLocal()
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 {
implementation 'org.jetbrains:annotations:23.0.0'
}
if (project.name != 'Xplat') {
dependencies {
implementation project(':Xplat')
}
project(":Xplat").afterEvaluate { xplat ->
processResources {
from xplat.sourceSets.main.resources
}
processTestResources {
from xplat.sourceSets.test.resources
}
tasks.withType(JavaCompile).configureEach {
source(xplat.sourceSets.main.allSource)
}
}
}
project.ext.issue_tracker_url = "https://github.com/${organisation}/${repository}/issues"
project.ext.sources_url = "https://github.com/${organisation}/${repository}"
processResources {
Map<String, ?> buildProps = project.properties.clone()
buildProps.values().removeIf { !it.getClass().isPrimitive() && !(it instanceof CharSequence) }
inputs.properties buildProps
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml']) {
expand buildProps
}
filesMatching("*.mixins.json") {
// In Fabric, all refmaps are merged together and the refmap name is pre-set by Loom
// Make sure everyone uses that name
expand "refmap_target": archivesBaseName + "-"
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
it.options.release = java_version as int
}
// Disables Gradle's custom module metadata from being published to maven. The
// metadata includes mapped dependencies which are not reasonably consumable by
// other mod developers.
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
publishing {
publications {
publications.create(project.name+'ToMaven', MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
artifact jar
pom {
name = rootProject.name
url = "https://github.com/${organisation}/${repository}"
packaging = 'jar'
scm {
connection = "scm:git:git://github.com/${organisation}/${repository}.git"
developerConnection = "scm:git:[email protected]:${organisation}/${repository}.git"
url = "https://github.com/${organisation}/${repository}"
}
issueManagement {
system = 'github'
url = "https://github.com/${organisation}/${repository}.git/issues"
}
organization {
name = "${organisation_name}"
url = "https://github.com/${organisation}"
}
developers {
developer {
id = "${author.toLowerCase()}"
name = "${author}"
email = "${author_email}"
organization = "${organisation_name}"
organizationUrl = "https://github.com/${organisation}"
timezone = "${timezone}"
}
}
licenses {
license {
name = 'MIT'
url = "https://github.com/${organisation}/${repository}/blob/${branch}/LICENSE"
distribution = 'repo'
}
}
withXml {
asNode().dependencies.dependency.each { dep ->
if(dep.version.last().value().last().contains('_mapped_')) {
assert dep.parent().remove(dep)
}
}
}
}
}
}
repositories {
maven {
if ((System.getenv("MAVEN_USER") != null) &&
(System.getenv("MAVEN_PASSWORD") != null) &&
(System.getenv("MAVEN_URL") != null)
) {
url System.getenv("MAVEN_URL")
credentials {
username System.getenv("MAVEN_USER")
password System.getenv("MAVEN_PASSWORD")
}
} else {
url "$buildDir/repo"
}
}
}
}
}