2021-11-12 07:48:58 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This task should be used to easily bump the major/minor/patch version of a fabric-api module.
|
|
|
|
* It will automatically bump the versions of dependent modules.
|
|
|
|
*/
|
|
|
|
task bumpVersions(type: BumpVersionTask)
|
|
|
|
|
|
|
|
class BumpVersionTask extends DefaultTask {
|
|
|
|
BumpVersionTask() {
|
|
|
|
group = "publishing"
|
|
|
|
|
|
|
|
outputs.upToDateWhen { false }
|
|
|
|
}
|
|
|
|
|
|
|
|
@TaskAction
|
|
|
|
void runTask() {
|
|
|
|
def scanner = new Scanner(System.in)
|
|
|
|
|
|
|
|
def toUpdate = [:]
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
println "Enter module name to update, or done to continue"
|
|
|
|
|
|
|
|
def input = scanner.nextLine()
|
|
|
|
|
|
|
|
if (input == "done") {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
2022-03-13 10:15:52 -04:00
|
|
|
// Bump all versions. To be used when buildscript changes are made.
|
|
|
|
if (input == "allPatch") {
|
|
|
|
project.getChildProjects().values().forEach {
|
2022-05-01 11:08:25 -04:00
|
|
|
if (it.name == "deprecated") return
|
|
|
|
|
2022-03-13 10:15:52 -04:00
|
|
|
toUpdate.put(it, 2)
|
|
|
|
}
|
|
|
|
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
2022-05-31 08:48:09 -04:00
|
|
|
def subProject = project.childProjects[input] ?: project.childProjects["deprecated"].childProjects[input]
|
2021-11-12 07:48:58 -05:00
|
|
|
|
|
|
|
if (!subProject) {
|
|
|
|
println "Could not find project with name: $input"
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
println "Bump version for ${subProject.name}:"
|
|
|
|
println "0) Bump Major"
|
|
|
|
println "1) Bump Minor"
|
|
|
|
println "2) Bump Patch"
|
|
|
|
|
|
|
|
input = scanner.nextLine()
|
|
|
|
|
|
|
|
if (!(input in ["0", "1", "2"])) {
|
|
|
|
println "Invalid input"
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
toUpdate.put(subProject, input as Integer)
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
def temp = [:]
|
|
|
|
|
|
|
|
toUpdate.keySet().forEach { p ->
|
2022-05-01 11:08:25 -04:00
|
|
|
project.allprojects.each { cp ->
|
|
|
|
if (cp.name == "deprecated" || cp.name == "fabric-api") return
|
|
|
|
|
2021-11-12 07:48:58 -05:00
|
|
|
def config = cp.configurations.api
|
|
|
|
config.allDependencies.forEach { dep ->
|
|
|
|
if (dep.name == p.name) {
|
|
|
|
if (!toUpdate.containsKey(cp)) {
|
|
|
|
println "Bumping patch of ${cp.name} as it depends on ${p.name}"
|
|
|
|
|
|
|
|
temp.put(cp, 2) // Bump patch
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (temp.isEmpty()) {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
toUpdate.putAll(temp)
|
|
|
|
}
|
|
|
|
|
|
|
|
def gpFile = project.file("gradle.properties")
|
|
|
|
def props = project.properties
|
|
|
|
def text = gpFile.text
|
|
|
|
|
|
|
|
toUpdate.forEach { p, i ->
|
|
|
|
def version = props."${p.name}-version"
|
|
|
|
|
|
|
|
if (!version) {
|
|
|
|
throw new NullPointerException("Could not find version for " + p.name)
|
|
|
|
}
|
|
|
|
|
|
|
|
def split = version.split("\\.")
|
|
|
|
split[i] = (split[i] as Integer) + 1
|
2021-11-25 11:39:24 -05:00
|
|
|
for (j in (i + 1) ..< split.length) {
|
|
|
|
split[j] = 0
|
|
|
|
}
|
2021-11-12 07:48:58 -05:00
|
|
|
def newVersion = split.join(".")
|
|
|
|
|
|
|
|
println "${p.name}: $version -> $newVersion"
|
|
|
|
|
|
|
|
text = text.replace(
|
|
|
|
"${p.name}-version=$version",
|
|
|
|
"${p.name}-version=$newVersion"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
gpFile.text = text
|
|
|
|
}
|
|
|
|
}
|