https://github.com/hbmartin/gradle-plugin-homebrew
A Gradle plugin to generate homebrew formula for running a jar
https://github.com/hbmartin/gradle-plugin-homebrew
Last synced: 6 months ago
JSON representation
A Gradle plugin to generate homebrew formula for running a jar
- Host: GitHub
- URL: https://github.com/hbmartin/gradle-plugin-homebrew
- Owner: hbmartin
- License: mit
- Created: 2024-08-22T18:22:36.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-28T14:15:09.000Z (about 1 year ago)
- Last Synced: 2025-03-29T21:51:07.559Z (6 months ago)
- Language: Kotlin
- Homepage: https://plugins.gradle.org/plugin/me.haroldmartin.homebrew.plugin
- Size: 50.8 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gradle-plugin-homebrew 🐘🍻
[](https://plugins.gradle.org/plugin/me.haroldmartin.homebrew.plugin)
[](https://github.com/hbmartin/gradle-plugin-homebrew/actions?query=workflow%3A%22Pre+Merge+Checks%22)
[](LICENSE)
[](https://sonarcloud.io/summary/new_code?id=hbmartin_gradle-plugin-homebrew)
[](https://www.codefactor.io/repository/github/hbmartin/gradle-plugin-homebrew)This is a Gradle plugin to automate the creation of a Homebrew formula for your published JARs as CLIs. It hooks into your publishing task requiring minimal configuration on your part.
## How to use 🚀
### Installation
In the project where your CLI JAR is published, add the following:
**Version catalog:**
```toml
[versions]
homebrew = "0.2.0"
[plugins]
homebrew = { id = "me.haroldmartin.homebrew.plugin", version.ref = "homebrew" }
``````kotlin
plugins {
...
alias(libs.plugins.homebrew)
}
```**Direct:**
```kotlin
plugins {
...
id("me.haroldmartin.homebrew.plugin") version "0.2.0"
}
```### Configuration
After applying the plugin, you need to configure the following properties:
```kotlin
homebrew {
// Required
homepage = "https://github.com/..."
cliName = "cool-tool" // The name of the CLI
desc = "Just trying this gradle plugin..."// Optional
// The homebrew package to require for the JDK, defaults to "openjdk"
jdk = "openjdk"
// Identifier from https://spdx.org/licenses/
license = "MIT"
// Additional homebrew packages to depends_on
dependencies = listOf("zsh")
// Custom test cases, map of arguments to expected output
tests = mapOf("-h" to "Usage: cool-tool [blah] [blah]")
// Defaults to "/build/Formula/.rb"
outputFile = file("custom/path/formula.rb")
}
```### Publishing and Generating
Now run your publishing task e.g. `./gradlew :cli:publishToMavenCentral` and the Homebrew formula will be generated in the specified output file with the Maven URL populated.### Pushing to Homebrew Tap
To push your formula to a Homebrew tap repo from a GitHub action, you can use the following.
Note that you must create a PAT with content access permissions for your tap repo and add it as a secret to your project's GitHub repo.
```yaml
- name: Checkout homebrew repo
uses: actions/checkout@v4
with:
repository: /
token: ${{ secrets.PAT_HOMEBREW }}
path:
- name: Commit and push to homebrew repo
run: |
cd
cp ..//build/Formula/.rb Formula/.rb
git config user.name
git config user.email
git add Formula/.rb
git commit -m "Update homebrew- to ${{ github.event.release.tag_name }}"
git push origin head
```## Limitations
* Does not support snapshots
## Contributing 🤝
Feel free to open a issue or submit a pull request for any bugs/improvements.
## License 📄
This template is licensed under the MIT License - see the [License](LICENSE) file for details.
Please note that the generated template is offering to start with a MIT license but you can change it to whatever you wish, as long as you attribute under the MIT terms that you're using the template.