-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
131 lines (108 loc) · 3.76 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
plugins {
id 'maven-publish'
id 'net.minecraftforge.gradle' version '5.1.+'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
id 'org.spongepowered.mixin' version '0.7.+'
}
apply from: 'gradle/version.gradle'
versions {
customPrefix = mc_version
incrementPositionIfSnapshot(-2) // Second to last version: #.#.(#).#
skipIncrementForClassifiers('alpha', 'beta', 'pre', 'rc')
}
version = versions.getVersion()
println "Mod version: $version"
sourceSets {
data
main.resources {
srcDirs += data.resources.srcDirs
exclude '.cache/'
}
}
print "Java: ${System.getProperty('java.version')}"
print ", JVM: ${System.getProperty('java.vm.version')} (${System.getProperty('java.vendor')})"
println ", Arch: ${System.getProperty('os.arch')}"
minecraft {
mappings channel: mappings_channel, version: mappings_version
runs {
configureEach {
workingDirectory project.file('run/' + it.name) as File
property 'forge.logging.markers', logging_markers
property 'forge.logging.console.level', logging_console
ideaModule "${project.name}.main"
mods.register(modid as String) {
source sourceSets.main as SourceSet
}
}
client {
}
server {
}
data {
args '--mod', modid, '--all'
args '--output', sourceSets.data.resources.srcDirs[0].toString()
args '--existing', sourceSets.main.resources.srcDirs[0].toString()
ideaModule "${project.name}.data"
mods.named(modid as String) {
sources sourceSets.main as SourceSet, sourceSets.data as SourceSet
}
}
}
}
configurations {
dataImplementation.extendsFrom implementation
}
dependencies {
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
dataImplementation sourceSets.main.output
}
java {
archivesBaseName = "${project.name}-${mc_version}"
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
withSourcesJar()
}
var manifestAttributes = [
'Specification-Title' : modid,
'Specification-Vendor' : author,
'Specification-Version' : versions.getRawVersion(),
'Implementation-Title' : project.name,
'Implementation-Version': versions.getVersion(),
'Implementation-Vendor' : author,
"Git-Commit" : versions.getCommitId(),
"Git-Commit-Timestamp" : versions.getCommitTimestamp()
] as LinkedHashMap
tasks.withType(Jar).configureEach {
manifest.attributes(manifestAttributes)
includeEmptyDirs false
preserveFileTimestamps = false
reproducibleFileOrder = true
// Normalize line endings from CRLF to LF
filesMatching('META-INF/mods.toml') {
//noinspection UnnecessaryQualifiedReference
filter(org.apache.tools.ant.filters.FixCrLfFilter.class,
eol: org.apache.tools.ant.filters.FixCrLfFilter.CrLf.newInstance('lf'))
}
}
tasks.named('jar', Jar).configure {
finalizedBy 'reobfJar'
}
// noinspection UnnecessaryQualifiedReference
tasks.withType(net.minecraftforge.gradle.userdev.tasks.RenameJarInPlace).configureEach {
// Check if the tool is SpecialSource, just in case FG changes to using ForgeAutoRenamingTool in the future
if (it.tool.get().contains('SpecialSource')) {
args.add('--stable')
}
}
publishing {
publications.create('mavenJava', MavenPublication) {
from components.java
it.artifactId = project.name
it.version = "$mc_version-${versions.getRawVersion()}${versions.isSnapshot() ? '-SNAPSHOT' : ''}"
}
repositories {
maven {
name 'projectLocal'
url "file://${project.file('repo').absolutePath}"
}
}
}