Skip to content

Commit

Permalink
Update gradle properties docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish committed Apr 1, 2024
1 parent f9fbbc0 commit bbfaa9e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
42 changes: 26 additions & 16 deletions mdg/gradleproperties.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
# Gradle properties
Mods.groovy gives you access to Gradle properties in your `mods.groovy` file with the `buildProperties['propertyName']` syntax.
This contains the properties from your gradle.properties file and any global ones, so you may want to blacklist them to
avoid leaking private keys.
Mods.groovy lets you expose project properties to your `mods.groovy` file, which can be accessed with the
`buildProperties['propertyName']` syntax. This contains only properties you explicitly expose:
```groovy
modsDotGroovy.gather {
projectProperty 'propertyName'
}
```

## Blacklisting
By default, the Gradle plugin excludes properties whose name contains (case-insensitive):
- pass
- password
- token
- key
- secret
Note that `.gather` is shorthand for configuring the default generated gather tasks; a similar `.convert` shorthand exists
for configuring the generated conversion tasks.

You can change the blacklist with:
## Version Catalogs
Mods.groovy can capture version catalogs and exposes the values to the `mods.groovy` file; they are accessible through the
`libs` property. By default, the `libs` version catalog is captured if it exists. To change which catalogs are captured,
add to the `catalogs` property:
```groovy
modsDotGroovy {
environmentBlacklist = ['private']
catalogs.add 'anotherVersionCatalog'
}
```
All captured version catalogs are merged and exposed in the same `libs` property.

:::caution
This overwrites the default blacklist, so you should copy over the words above if you want to add new entries
rather than replace.
:::
## Environment Information
The `environmentInfo` property exposes the raw information passed into the `mods.groovy` environment; in addition to the
build property and version catalog information, a group and version (defaulting to the project group and version) are passed
in as `environmentInfo.version` and `environmentInfo.group`. The group and version passed in can be configured on the
conversion task:
```groovy
modsDotGroovy.convert {
projectVersion.set '1.0.0'
projectGroup.set 'org.example'
}
```
2 changes: 1 addition & 1 deletion mdgexamples/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
plugins {
id 'org.groovymc.modsdotgroovy' version '2.0.0-beta.10' apply false
id 'org.groovymc.modsdotgroovy' version '2.0.0-beta.21' apply false
}
Empty file modified mdgexamples/gradlew
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions mdgexamples/neoforge/src/main/resources/mods.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ NeoForgeModsDotGroovy.make {
// The version of the mod. You can hardcode this or use '${file.jarVersion}' to substitute it with the
// Implementation-Version of the mod jar
// Alternatively you can pull the version of your Gradle Project through the syntax specified below
version = buildProperties.version
version = environmentInfo.version

// The authors of the mod
authors = ['Myself', 'I']
Expand All @@ -53,7 +53,7 @@ NeoForgeModsDotGroovy.make {
// Declare an optional JEI dependency
mod('jei') {
// This dependency is against any version of JEI with the major component 17
versionRange = v('17.*')
versionRange = '17.*'
type = DependencyType.OPTIONAL
}
}
Expand Down

0 comments on commit bbfaa9e

Please sign in to comment.