-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
135 lines (121 loc) · 4.75 KB
/
build.gradle
File metadata and controls
135 lines (121 loc) · 4.75 KB
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
buildscript {
repositories {
mavenLocal()
jcenter()
maven { url = "https://maven.minecraftforge.net/" }
maven { url = "https://repo.spongepowered.org/maven" }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.+'
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}
}
plugins {
id 'java'
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'eclipse'
group = 'net.foxmcloud.realisticsleep'
archivesBaseName = 'RealisticSleep'
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
sourceSets.main.resources.srcDirs += "src/generated/resources"
file('build.properties').withReader {
def prop = new Properties()
prop.load(it)
project.ext.config = new ConfigSlurper().parse prop
}
config.mod_version = "${config.mod_version}.${config.build_number}"
version = "${config.mc_version}-${config.mod_version}"
config.forge_version = "${config.forge_major_version}.${config.forge_minor_version}"
println "Starting build of ${archivesBaseName}, Version: ${config.mod_version}"
println "Using Forge: ${config.forge_version}, for Minecraft: ${config.mc_version}, with official mappings"
minecraft {
mappings channel: 'official', version: config.mc_version
accessTransformer = file("src/main/resources/META-INF/accesstransformer.cfg")
runs {
client {
workingDirectory file('run')
mods { realisticsleep { source sourceSets.main } }
}
server {
workingDirectory file('run')
mods { realisticsleep { source sourceSets.main } }
}
data {
workingDirectory file('run')
args '--mod', 'realisticsleep', '--all', '--output', file("src/generated/resources")
mods { realisticsleep { source sourceSets.main } }
}
}
}
repositories {
mavenLocal()
maven { url = "https://maven.covers1624.net/" }
}
dependencies {
minecraft "net.minecraftforge:forge:${config.mc_version}-${config.forge_version}"
implementation fg.deobf("codechicken:CodeChickenLib:${config.mc_version}-${config.ccl_version}:universal")
}
processResources { task ->
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from(sourceSets.main.resources.srcDirs) { spec ->
spec.include 'META-INF/mods.toml'
task.doFirst {
spec.expand 'version': config.mod_version,
'mc_version': config.mc_version,
'forge_major_version': config.forge_major_version,
'ccl_version': config.ccl_version
}
}
}
jar {
finalizedBy 'reobfJar'
classifier = 'universal'
from file("LICENSE")
manifest {
attributes 'Specification-Title': archivesBaseName
attributes 'Specification-Vendor': 'FoxMcloud5655'
attributes 'Specification-Version': "1"
attributes 'Implementation-Title': archivesBaseName
attributes 'Implementation-Vendor': 'FoxMcloud5655'
attributes 'Implementation-Version': version
attributes 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
//attributes 'MixinConfigs': 'mixins.realisticsleep.json'
}
}
task srcJar(type: Jar) {
build.dependsOn it
from sourceSets.main.allSource
classifier = 'sources'
from file("LICENSE")
}
/**
* Polls the 'compile' configuration for a dependency with the given module name
* and resolves, and returns its version. E.g: '1.2.+' will resolve to '1.2.3.4'
*
* @param module The module to search for.
* @param chop If the string should be chopped on the last '-' in its string.
* @param configuration The name of the configuration to search.
* @param errorMissing If an error should be thrown if it can't be found.
* @return The version string, '0' if 'errorMissing' is false and nothing was found.
*/
def resolve(module, chop = true, configuration = 'compile', errorMissing = true) {
//Copy and lenient resolve the configuration, Forge cant be resolved at this time so lenient is required.
def filtered = configurations.getByName(configuration).copy().incoming.artifactView({ it.lenient = true }).artifacts
.findAll { it.id.componentIdentifier.module == module }
.collect { it.id.componentIdentifier.version }
if (filtered.size() > 1) {
println "WARNING: Found ${filtered.size()} Dependencies with ModuleName '${module}' in configuration '${configuration.name}'"
}
if (errorMissing && filtered.isEmpty()) {
throw new RuntimeException("Failed resolve dependency version for '${module}'")
}
if (filtered.isEmpty()) return "0"
def version = filtered.first() as String
if (chop) {
def idx = version.lastIndexOf('-')
return version.substring(idx + 1)
}
return version
}