Skip to content

Commit

Permalink
stuff idk
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysdh540 committed Oct 7, 2024
1 parent f555598 commit f6220b2
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ subprojects {
relocate("dev.rdh.createunlimited.$platform", "dev.rdh.createunlimited")
}

val remapPlatformJar = tasks.register<RemapJarTaskImpl>("remapPlatformJar", unimined.minecrafts[sourceSets["main"]])
val remapPlatformJar = tasks.register<RemapJarTaskImpl>("remapPlatformJar", unimined.minecrafts[sourceSets["main"]]!!)
remapPlatformJar.configure {
dependsOn(shadowJar)
inputFile.set(shadowJar.archiveFile)
Expand Down Expand Up @@ -395,4 +395,4 @@ tasks.register("nukeGradleCaches") {
}
}

operator fun String.invoke(): String = rootProject.ext[this] as? String ?: error("No property \"$this\"")
operator fun String.invoke() = rootProject.ext[this] as? String ?: error("No property \"$this\"")
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {
plugin(id = "xyz.wagyourtail.unimined.expect-platform", version = "expectplatform_version"())
}

operator fun String.invoke(): String = gradleProperties.getProperty(this) ?: error("No property \"$this\"")
operator fun String.invoke() = gradleProperties.getProperty(this) ?: error("No property \"$this\"")

fun DependencyHandler.plugin(id: String, version: String) =
implementation(group = id, name = "$id.gradle.plugin", version = version)
22 changes: 13 additions & 9 deletions buildSrc/src/main/kotlin/git.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import org.gradle.api.Project
import org.jetbrains.annotations.ApiStatus
import java.io.File

val Project.git
get() = Git(rootProject.rootDir)
val Project.git: Git
get() = project.extensions.let {
it.findByType(Git::class.java) ?: it.create("git", Git::class.java, project.rootDir)
}

class Git(val repository: File) {
@ApiStatus.NonExtendable
abstract class Git(val repository: File) {
fun exists() = repository.resolve(".git").isDirectory()

// does the current git repository have uncommitted changes?
Expand All @@ -13,22 +17,22 @@ class Git(val repository: File) {
// last commit hash
fun hash(long: Boolean = false) =
if(long)
git("rev-parse", "HEAD").trim()
git("rev-parse", "HEAD")
else
git("rev-parse", "--short", "HEAD").trim()
git("rev-parse", "--short", "HEAD")

// current branch
fun currentBranch() = git("rev-parse", "--abbrev-ref", "HEAD").trim()
fun currentBranch() = git("rev-parse", "--abbrev-ref", "HEAD")

// latest tag
fun tag() = git("describe", "--tags", "--abbrev=0").trim()
fun tag() = git("describe", "--tags", "--abbrev=0")

fun getUncommitedChanges() = git("diff", "--name-only").trim()
fun getUncommitedChanges() = git("diff", "--name-only")

private fun git(vararg args: String): String {
val process = ProcessBuilder("git", *args)
.directory(repository)
.start()
return process.inputStream.bufferedReader().readText()
return process.inputStream.bufferedReader().readText().trim()
}
}
2 changes: 1 addition & 1 deletion fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ dependencies {
}
}

operator fun String.invoke(): String = rootProject.ext[this] as? String ?: error("No property \"$this\"")
operator fun String.invoke() = rootProject.ext[this] as? String ?: error("No property \"$this\"")
2 changes: 1 addition & 1 deletion forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ dependencies {
modImplementation("com.jozufozu.flywheel:flywheel-forge-${"flywheel_mc_version"()}:${"flywheel_version"()}")
}

operator fun String.invoke(): String = rootProject.ext[this] as? String ?: error("No property \"$this\"")
operator fun String.invoke() = rootProject.ext[this] as? String ?: error("No property \"$this\"")
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mixin.debug = true
git_max_changes = 10

# gradle plugin versions
unimined_version = 1.3.4
unimined_version = 1.3.9
idea_ext_version = 1.1.8
expectplatform_version = 1.0.5
proguard_version = 7.5.0
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down

0 comments on commit f6220b2

Please sign in to comment.