Skip to content

Commit b342187

Browse files
authored
allow shorter dependency types (#77)
1 parent e82e47f commit b342187

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

build.gradle

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,12 @@ if (cfApiKey.isPresent() || deploymentDebug.toBoolean()) {
936936
}
937937
String[] parts = dep.split(':')
938938
String type = parts[0], slug = parts[1]
939+
def types = [
940+
'req' : 'requiredDependency', 'required': 'requiredDependency',
941+
'opt' : 'optionalDependency', 'optional': 'optionalDependency',
942+
'embed' : 'embeddedLibrary', 'embedded': 'embeddedLibrary',
943+
'incomp': 'incompatible', 'fail' : 'incompatible']
944+
if (types.containsKey(type)) type = types[type]
939945
if (!(type in ['requiredDependency', 'embeddedLibrary', 'optionalDependency', 'tool', 'incompatible'])) {
940946
throw new Exception('Invalid Curseforge dependency type: ' + type)
941947
}
@@ -978,7 +984,7 @@ if (modrinthApiKey.isPresent() || deploymentDebug.toBoolean()) {
978984
}
979985
String[] parts = dep.split(':')
980986
String[] qual = parts[0].split('-')
981-
addModrinthDep(qual[0], qual[1], parts[1])
987+
addModrinthDep(qual[0], qual.length > 1 ? qual[1] : 'project', parts[1])
982988
}
983989
}
984990
tasks.modrinth.dependsOn(build)
@@ -987,9 +993,17 @@ if (modrinthApiKey.isPresent() || deploymentDebug.toBoolean()) {
987993

988994
def addModrinthDep(String scope, String type, String name) {
989995
com.modrinth.minotaur.dependencies.Dependency dep
996+
def types = [
997+
'req' : 'required',
998+
'opt' : 'optional',
999+
'embed' : 'embedded',
1000+
'incomp': 'incompatible', 'fail': 'incompatible']
1001+
if (types.containsKey(scope)) scope = types[scope]
9901002
if (!(scope in ['required', 'optional', 'incompatible', 'embedded'])) {
9911003
throw new Exception('Invalid modrinth dependency scope: ' + scope)
9921004
}
1005+
types = ['proj': 'project', '': 'project', 'p': 'project', 'ver': 'version', 'v': 'version']
1006+
if (types.containsKey(type)) type = types[type]
9931007
switch (type) {
9941008
case 'project':
9951009
dep = new ModDependency(name, scope)

0 commit comments

Comments
 (0)