-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
131 lines (112 loc) · 4.79 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
import net.darkhax.curseforgegradle.TaskPublishCurseForge
plugins {
id 'com.modrinth.minotaur' version '2.+' apply false
id 'net.darkhax.curseforgegradle' version '1.1.17' apply false
}
interface PlatformInfoExtension {
// Which platform (i.e. Fabric/Forge/Quilt) is this implementation is on?
// In case of projects uses solely VanillaGradle, here we use 'Vanilla'.
Property<String> getPlatform();
// Which Minecraft version is this implementation based on?
Property<String> getMinecraftVersion();
// Which Minecraft version is this implementation compatible with?
ListProperty<String> getSupportedMinecraftVersions();
}
def mainVersion = '1.0.3'
subprojects { Project p ->
apply plugin: 'java'
apply plugin: 'com.modrinth.minotaur' // https://stackoverflow.com/a/50153617
apply plugin: 'net.darkhax.curseforgegradle'
p.extensions.create('platformInfo', PlatformInfoExtension)
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
java.withSourcesJar()
p.archivesBaseName = "ExampleMultiProjectMod"
p.version = mainVersion
p.repositories {
// Enable maven central for all subprojects
mavenCentral()
// Enable sponge maven for all subprojects, for access to Mixin
maven {
name = 'SpongePowered'
url = 'https://repo.spongepowered.org/repository/maven-public/'
content {
includeGroup 'org.spongepowered'
}
}
}
p.tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
}
p.processResources {
// Exclude .cache directory which is generated by DataGen.
exclude '.cache'
}
p.afterEvaluate { Project pAfter ->
if (!pAfter.name.endsWith('base')) {
String baseProject = ':' + pAfter.name.substring(0, pAfter.name.indexOf('-')) + '-base'
pAfter.compileJava {
source(pAfter.project(baseProject).sourceSets.main.allSource)
}
pAfter.sourcesJar {
from project(baseProject).sourceSets.main.allJava
}
pAfter.processResources {
from project(baseProject).sourceSets.main.resources
}
}
def projectExt = pAfter.extensions.platformInfo as PlatformInfoExtension
def useLoom = pAfter.extensions.findByName('loom')
if (useLoom) {
pAfter.loom {
// Uncomment this if you have Mixin configurations
// mixin {
// // Enable legacy Mixin AP properties, so that we can override
// // default refmap file name.
// useLegacyMixinAp = true
// defaultRefmapName = 'examplemod.refmap.json'
// }
}
}
pAfter.archivesBaseName += "-${projectExt.platform.get()}-${projectExt.minecraftVersion.get()}"
pAfter.modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = System.getenv("MODRINTH_PROJECT_ID")
loaders = [ projectExt.platform.get().toLowerCase(Locale.ROOT) ]
gameVersions = projectExt.supportedMinecraftVersions.getOrElse([])
uploadFile = useLoom ? pAfter.remapJar : pAfter.jar
versionNumber = mainVersion
versionType = 'release' // alpha | beta | release
// TODO Declare Dependency
}
if ("Vanilla" == projectExt.platform.get()) {
// Disable modrinth task for base projects
pAfter.tasks.named("modrinth") {
enabled = false
}
} else {
pAfter.tasks.register('curseforge', TaskPublishCurseForge) {
disableVersionDetection()
apiToken = System.getenv("CURSEFORGE_TOKEN")
def projectId = System.getenv("CURSEFORGE_PROJECT_ID")
def mainFile = upload(projectId, useLoom ? pAfter.remapJar : pAfter.jar)
mainFile.addModLoader(projectExt.platform.get())
projectExt.supportedMinecraftVersions.getOrElse([]).each {
mainFile.addGameVersion(it)
}
mainFile.releaseType = 'release'
mainFile.changelog = 'Bug fixes'
}
// TODO Declare Dependency
}
pAfter.jar {
manifest.attributes([
"Specification-Title": "Example-Mod",
"Specification-Vendor": "Whoever comes up with the spec of the mod",
"Specification-Version": "1.0",
"Implementation-Title": "${pAfter.archivesBaseName}",
"Implementation-Version": "${pAfter.version}",
"Implementation-Vendor": "Whoever actually writes the mod"
])
}
}
}