-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
199 lines (170 loc) · 6.52 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
import net.minecraftforge.gradle.common.util.ModConfig
import net.minecraftforge.gradle.common.util.RunConfig
import org.apache.maven.artifact.versioning.ComparableVersion
import java.nio.file.Files
import java.nio.file.Paths
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
maven { url = 'https://plugins.gradle.org/m2/' }
jcenter()
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
classpath group: 'org.apache.maven', name: 'maven-artifact', version: '3.6.3+'
classpath 'gradle.plugin.com.matthewprenger:CurseGradle:1.4.0'
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'com.matthewprenger.cursegradle'
apply plugin: 'maven-publish'
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/master/generic/secrets.gradle'
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/master/generic/markdown-git-changelog.gradle'
loadSecrets()
group = "de.melanx.${modid}"
archivesBaseName = "${modid}-${mc_version}"
version = getVersion(group, archivesBaseName, mod_version)
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
minecraft {
mappings("snapshot", mappings_version)
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
createRunConfig("client")
createRunConfig("server")
createRunConfig("data", { RunConfig run ->
run.args "--mod", modid, "--all", "--output", file("src/generated/resources/"), "--existing", file("src/main/resources")
})
}
def createRunConfig(String name, Closure extra = {}) {
minecraft.runs.create(name) { RunConfig run ->
run.workingDirectory project.file("run_" + name)
run.property "forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP"
run.property "forge.logging.console.level", "debug"
run.mods.create(modid) { ModConfig mod ->
source sourceSets.main
}
}.with(extra)
}
sourceSets.main.resources {
srcDir 'src/generated/resources'
}
jar {
manifest {
attributes([
"Specification-Title" : modid,
"Specification-Vendor" : "MelanX",
"Specification-Version" : "1",
"Implementation-Title" : project.name,
"Implementation-Version" : "${version}",
"Implementation-Vendor" : "MelanX",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
jar.finalizedBy('reobfJar')
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives jar
archives sourcesJar
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = project.group
artifactId = project.archivesBaseName
version = project.version
artifact jar
artifact sourcesJar
pom {
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
}
}
}
repositories {
maven {
url "/var/www/maven"
}
}
}
repositories {
maven {
name = "JEI"
url = "https://dvs1.progwml6.com/files/maven/"
}
maven {
name = "LibX"
url = "https://maven.melanx.de/"
}
maven {
name = "TOP"
url = "https://maven.tterrag.com/"
}
}
dependencies {
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
compile fg.deobf("io.github.noeppi_noeppi.mods:LibX:${mc_version}-${libx_version}")
compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api")
runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}")
runtime fg.deobf("mcjty.theoneprobe:TheOneProbe-1.16:${top_version}")
// runtime fg.deobf("de.melanx.recipeprinter:recipeprinter-1.16.3:1.1+5")
}
private static String getVersion(String group, String artifact, String baseVersion) {
java.nio.file.Path mavenPath = Paths.get('/var/www/maven').resolve(group.replace('.', '/')).resolve(artifact)
if (!Files.isDirectory(mavenPath)) {
return "${baseVersion}.0"
}
return "${baseVersion}." + Files.walk(mavenPath)
.filter { path -> Files.isRegularFile(path) && path.getFileName().toString().endsWith('.pom') }
.map { path ->
String fileName = path.getFileName().toString()
fileName.substring(fileName.indexOf('-', artifact.size()) + 1, fileName.length() - 4)
}.filter { version -> version.startsWith(baseVersion) }
.max { s1, s2 -> new ComparableVersion(s1).compareTo(new ComparableVersion(s2)) }
.map { ver -> ver.substring(ver.findLastIndexOf { str -> !"0123456789".contains(str) } + 1) }
.map { ver -> ver.isEmpty() ? "-1" : ver }
.map { ver -> (ver.toInteger() + 1).toString() }
.orElse("0")
}
curseforge {
apiKey = findProperty('curse_auth') ?: 0
def versions = "${curse_versions}".split(', ')
project {
if (project.hasProperty('curse_project')) {
id = "${curse_project}"
releaseType = 'release'
changelog = getGitChangelog()
println(changelog)
changelogType = 'markdown'
versions.each {
addGameVersion "${it}"
}
if (project.hasProperty('curse_requirements') || project.hasProperty('curse_optionals')) {
mainArtifact(jar) {
relations {
if (project.hasProperty('curse_requirements')) {
def requirements = "${curse_requirements}".split(', ')
requirements.each {
requiredLibrary "${it}"
}
}
if (project.hasProperty('curse_optionals')) {
def optionals = "${curse_optionals}".split(', ')
optionals.each {
optionalLibrary "${it}"
}
}
}
}
}
addArtifact(sourcesJar)
}
}
}