|
1 | 1 | import gg.meza.stonecraft.mod |
| 2 | +import me.modmuss50.mpp.ReleaseType |
2 | 3 |
|
| 4 | +val publishType = if (mod.hasProp("build.release_type")) mod.prop("build.release_type") else null |
| 5 | +val isBeta = publishType != null && publishType == "beta" |
| 6 | +val isAlpha = publishType != null && publishType == "alpha" |
3 | 7 | val kotlinVersion: String by rootProject |
4 | 8 |
|
5 | 9 | plugins { |
@@ -35,6 +39,77 @@ modSettings { |
35 | 39 | variableReplacements.putAll(replaces) |
36 | 40 | } |
37 | 41 |
|
| 42 | +publishMods { |
| 43 | + dryRun = false |
| 44 | + |
| 45 | + if ( |
| 46 | + mod.hasProp("build.no_publish") |
| 47 | + && ( |
| 48 | + mod.prop("build.no_publish") == "true" |
| 49 | + || ((mod.prop("build.no_publish") == "neoforge") && mod.isNeoforge) |
| 50 | + || ((mod.prop("build.no_publish") == "fabric") && mod.isFabric) |
| 51 | + || ((mod.prop("build.no_publish") == "forge") && mod.isForge) |
| 52 | + || ((mod.prop("build.no_publish") == "fabriclike") && mod.isFabricLike) |
| 53 | + || ((mod.prop("build.no_publish") == "forgelike") && mod.isForgeLike) |
| 54 | + ) |
| 55 | + ) { |
| 56 | + println("Publishing disabled. Skipping...") |
| 57 | + return@publishMods |
| 58 | + } |
| 59 | + |
| 60 | + val additionalMinecraftVersions = if (mod.hasProp("minecraft_version.additional")) |
| 61 | + mod.prop("minecraft_version.additional").split(',').map { it.trim() } |
| 62 | + else listOf() |
| 63 | + |
| 64 | + changelog = rootProject.file("CHANGELOG.md").readText() |
| 65 | + |
| 66 | + type = when { |
| 67 | + isBeta -> ReleaseType.BETA |
| 68 | + isAlpha -> ReleaseType.ALPHA |
| 69 | + else -> ReleaseType.STABLE |
| 70 | + } |
| 71 | + |
| 72 | + displayName = "[${mod.loader}-${mod.minecraftVersion}] ${mod.name} (v.${mod.version})" |
| 73 | + modLoaders.add(mod.loader) |
| 74 | + |
| 75 | + val modrinthProject: String? = rootProject.properties["modrinth_project"]?.toString() |
| 76 | + val modrinthToken = System.getenv("MODRINTH_TOKEN") |
| 77 | + |
| 78 | + val curseProject: String? = rootProject.properties["curseforge_project"]?.toString() |
| 79 | + val curseToken = System.getenv("CURSE_TOKEN") |
| 80 | + |
| 81 | + if (modrinthToken != null && modrinthProject != null) modrinth { |
| 82 | + projectId = modrinthProject |
| 83 | + accessToken = modrinthToken |
| 84 | + |
| 85 | + if (mod.isFabricLike) |
| 86 | + requires("fabric-api", "fabric-language-kotlin") |
| 87 | + else requires("kotlin-lang-forge") |
| 88 | + |
| 89 | + minecraftVersions.add(mod.minecraftVersion) |
| 90 | + minecraftVersions.addAll(additionalMinecraftVersions) |
| 91 | + } |
| 92 | + |
| 93 | + if (curseToken != null && curseProject != null) curseforge { |
| 94 | + projectId = curseProject |
| 95 | + accessToken = curseToken |
| 96 | + |
| 97 | + if (mod.isFabricLike) |
| 98 | + requires("fabric-api", "fabric-language-kotlin") |
| 99 | + else requires("kotlinlangforge") |
| 100 | + |
| 101 | + if (mod.minecraftVersion.contains("snapshot")) { |
| 102 | + val modifiedVersion = buildString { |
| 103 | + val oldVersion = mod.minecraftVersion |
| 104 | + val splitted = oldVersion.split("-") |
| 105 | + append(splitted[0] + "-snapshot") |
| 106 | + } |
| 107 | + minecraftVersions.add(modifiedVersion) |
| 108 | + } else minecraftVersions.add(mod.minecraftVersion) |
| 109 | + minecraftVersions.addAll(additionalMinecraftVersions) |
| 110 | + } |
| 111 | +} |
| 112 | + |
38 | 113 | fun DependencyHandlerScope.implementMod(dependencyNotation: Any) { |
39 | 114 | if (stonecutter.eval(mod.minecraftVersion, ">=26.1.0")) |
40 | 115 | implementation(dependencyNotation) |
|
0 commit comments