Skip to content

Commit

Permalink
use a provider for git branch
Browse files Browse the repository at this point in the history
  • Loading branch information
TropheusJ committed Feb 20, 2024
1 parent e13bd40 commit 34abe7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import io.github.fabricators_of_create.porting_lib_build.PortingLibBuildPlugin
//file:noinspection GroovyAccessibility
plugins {
id "fabric-loom"
id "org.ajoberstar.grgit" version "4.1.1"
id "maven-publish"
}

Expand All @@ -14,6 +13,12 @@ targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = "porting_lib"

String branch = providers.exec {
it.setCommandLine("git", "branch", "--show-current")
}.standardOutput.asText.map {
it.contains("not a git repository") ? "unknown" : it
}.get().trim()

dependencies {
subprojects.forEach {
api(include(project(path: ":$it.name", configuration: "namedElements")))
Expand All @@ -33,13 +38,7 @@ allprojects {

group = "io.github.fabricators_of_create.Porting-Lib"

version = project.mod_version

if (grgit != null) {
version += "+${grgit.getBranch().current().name}"
} else {
version += "+custom_unknown"
}
version = mod_version + "+" + branch

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void addModuleDependency(String name) {
loom.mods(mods -> mods.register("porting_lib_" + name, settings -> {
Project depProject = project.project(":" + name);
SourceSetContainer sourceSets = depProject.getExtensions().getByType(SourceSetContainer.class);
settings.sourceSet(sourceSets.getByName("main"));
settings.sourceSet(sourceSets.getByName("main"), depProject);
}));
}

Expand Down

0 comments on commit 34abe7a

Please sign in to comment.