Skip to content

Commit

Permalink
simplify dependency setup for publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Erdragh committed Oct 11, 2023
1 parent 60ad8c5 commit 322348e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
12 changes: 8 additions & 4 deletions gradle/publishing/curseforge.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ curseforge {
addGameVersion(minecraft_version)

relations {
requiredDependency("fabric-api")
requiredDependency("fabric-language-kotlin")
requiredDependency("forge-config-api-port-fabric")
optionalDependency("roughly-enough-items")
for (dependency in (depends as List<String>)) {
var optionalDep = dependency.endsWith("?")
if (optionalDep) {
optionalDependency(dependency.replace("?", ""))
} else {
requiredDependency(dependency)
}
}
}

// https://github.com/mraliscoder/plasmo-voice/blob/41243bc77589d975acde5385dd86414b1c92a2a8/fabric/build.gradle.kts#L173
Expand Down
12 changes: 8 additions & 4 deletions gradle/publishing/modrinth.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ modrinth {
gameVersions = [ minecraft_version ]
loaders = ["fabric"]
dependencies {
required.project "fabric-api"
required.project "fabric-language-kotlin"
required.project "forge-config-api-port"
optional.project "rei"
for (dependency in (depends as List<String>)) {
var optionalDep = dependency.endsWith("?")
if (optionalDep) {
optional.project(dependency.replace("?", ""))
} else {
required.project(dependency)
}
}
}
}

Expand Down
13 changes: 13 additions & 0 deletions gradle/publishing/publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ext /*-ra properties*/ {
Properties properties = new Properties()
properties.load(new FileInputStream(file("gradle/publishing/publishing.properties")))

depends = ((String) properties.get("dependencies"))?.split("; *")

properties.forEach ((k, v) -> set(k, v))

version_valid = versionValidForPublishing(version)
Expand All @@ -30,6 +32,17 @@ tasks.register("printVersion") {
println(version)
}

tasks.register("printDependencies") {
for (dependency in (depends as List<String>)) {
var optionalDep = dependency.endsWith("?")
if (optionalDep) {
println("optional: " + dependency);
} else {
println("required: " + dependency);
}
}
}

static String makeName(String version, String minecraftVersion, String displayName) {
String projectVersion = "v" + version.split("-build")[0].replace("-", ".")
String rawPatch = System.getenv("PATCH_NUMBER")
Expand Down
1 change: 1 addition & 0 deletions gradle/publishing/publishing.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ modrinth_id = 4Q5DgkRU
curseforge_id = 833210
release_type = release
changelog_file = CHANGELOG.md
dependencies = ad-astra;fabric-api;forge-config-api-port

0 comments on commit 322348e

Please sign in to comment.