Skip to content

Commit

Permalink
Share common mod properties between subprojects that use Minecraft
Browse files Browse the repository at this point in the history
  • Loading branch information
Pixaurora committed Jul 19, 2024
1 parent 32630da commit e13d16a
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ public ProjectProperties(Project project) {
}

public Optional<Object> optionalProperty(Property property) {
Optional<Project> parent = Optional.ofNullable(this.project.getParent());

// This is a work-around for https://github.com/gradle/gradle/issues/29600
if (project.getName().charAt(1) == '1' && parent.isPresent()) {
Optional<Object> parentProperty = Optional.ofNullable(parent.get().getProperties().get(property.key()));

if (parentProperty.isPresent()) {
return parentProperty;
}
}

return Optional.ofNullable(project.getProperties().get(property.key()));
}

Expand Down
3 changes: 3 additions & 0 deletions kitten-square/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Shared Mod Properties
base_mod_name = kitten
sub_mod_name = square
2 changes: 0 additions & 2 deletions kitten-square/r1.17.0/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Mod properties
base_mod_name = kitten
sub_mod_name = square

minecraft_version_min = 1.17.0

Expand Down
2 changes: 0 additions & 2 deletions kitten-square/r1.20.4/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Mod properties
base_mod_name = kitten
sub_mod_name = square

minecraft_version_min = 1.20.4

Expand Down
2 changes: 0 additions & 2 deletions kitten-square/r1.21.0/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Mod properties
base_mod_name = kitten
sub_mod_name = square

minecraft_version_min = 1.21.0

Expand Down
3 changes: 3 additions & 0 deletions kitten-star/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Shared mod properties
base_mod_name = kitten
sub_mod_name = star
2 changes: 0 additions & 2 deletions kitten-star/r1.17.0/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Mod properties
base_mod_name = kitten
sub_mod_name = star

minecraft_version_min = 1.17.0

Expand Down
2 changes: 0 additions & 2 deletions kitten-star/r1.20.4/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Mod properties
base_mod_name = kitten
sub_mod_name = star

minecraft_version_min = 1.20.4

Expand Down

0 comments on commit e13d16a

Please sign in to comment.