Skip to content

Commit

Permalink
Update readme, fix CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
hbmartin committed Aug 20, 2023
1 parent 5b359ee commit ebe12df
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 49 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/pre-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,3 @@ jobs:
uses: gradle/gradle-build-action@v2
- name: Run Gradle tasks
run: ./gradlew preMerge --continue

# We do a run of the new task `templateExample` created by the plugin
- name: Run the plugin
run: ./gradlew templateExample --message="Test Run" --tag=CI
if: success()
# And we verify that the output of the file is correct.
- name: Verify the plugin output
run: grep -Fxq "[CI] Test Run" ./example/build/template-example.txt
if: success()
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 29 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,56 @@

## How to use

1. Apply plugin to root project
2. Either set environment variable `export ORG_GRADLE_PROJECT_caffeinate="true"` or run gradle with the argument `-Pcaffeinate=true`

Once created don't forget to update the:
- [gradle.properties](plugin-build/gradle.properties)
- Plugin Usages (search for [com.ncorti.kotlin.gradle.template](https://github.com/cortinico/kotlin-gradle-plugin-template/search?q=com.ncorti.kotlin.gradle.template&unscoped_q=com.ncorti.kotlin.gradle.template) in the repo and replace it with your ID).

### `preMerge` task

A `preMerge` task on the top level build is already provided in the template. This allows you to run all the `check` tasks both in the top level and in the included build.
1. Apply plugin to root project. Ensure you have `gradlePluginPortal()` in your `repositories` block. Choose 1 of the 3 options (apply to root project):

You can easily invoke it with:
Version catalog:

```toml
[versions]
caffeinate = "0.0.1"
[caffeinate]
detekt = { id = "me.haroldmartin.gradle.caffeinate", version.ref = "caffeinate" }
```
./gradlew preMerge
```

If you need to invoke a task inside the included build with:

```kotlin
plugins {
alias(libs.plugins.caffeinate)
}
```
./gradlew -p plugin-build <task-name>
```


### Dependency substitution
Kotlin:

Please note that the project relies on module name/group in order for [dependency substitution](https://docs.gradle.org/current/userguide/resolution_rules.html#sec:dependency_substitution_rules) to work properly. If you change only the plugin ID everything will work as expected. If you change module name/group, things might break and you probably have to specify a [substitution rule](https://docs.gradle.org/current/userguide/resolution_rules.html#sub:project_to_module_substitution).


## Publishing 🚀
```kotlin
plugins {
id("me.haroldmartin.gradle.caffeinate") version "0.0.1"
}
```

This template is ready to let you publish to [Gradle Portal](https://plugins.gradle.org/).
Groovy:

The [![Publish Plugin to Portal](https://github.com/cortinico/kotlin-gradle-plugin-template/workflows/Publish%20Plugin%20to%20Portal/badge.svg?branch=1.0.0)](https://github.com/cortinico/kotlin-gradle-plugin-template/actions?query=workflow%3A%22Publish+Plugin+to+Portal%22) Github Action will take care of the publishing whenever you **push a tag**.
```groovy
plugins {
id "me.haroldmartin.gradle.caffeinate" version "0.0.1"
}
```

Please note that you need to configure two secrets: `GRADLE_PUBLISH_KEY` and `GRADLE_PUBLISH_SECRET` with the credetials you can get from your profile on the Gradle Portal.
2. Either set environment variable `export ORG_GRADLE_PROJECT_caffeinate="true"` or run gradle with the argument `-Pcaffeinate=true`

## Development Environment 🛠

- Based on [kotlin-gradle-plugin-template](https://github.com/cortinico/kotlin-gradle-plugin-template)
- 100% Kotlin including Gradle DSL.
- Plugin build setup with **composite build**.
- Plugin build setup with [Gradle composite build](https://docs.gradle.org/current/userguide/composite_builds.html).
- Dependency versions managed via Gradle Versions Catalog (`libs.versions.toml`).
- CI Setup with GitHub Actions.
- Kotlin Static Analysis via `ktlint` and `detekt`.
- This is using a [Gradle composite build](https://docs.gradle.org/current/userguide/composite_builds.html) to build, test and publish the plugin.
-

## CI ⚙️

This template is using [**GitHub Actions**](https://github.com/cortinico/kotlin-android-template/actions) as CI. You don't need to setup any external service and you should have a running CI once you start using this template.

There are currently the following workflows available:
- [Validate Gradle Wrapper](.github/workflows/gradle-wrapper-validation.yml) - Will check that the gradle wrapper has a valid checksum
- [Pre Merge Checks](.github/workflows/pre-merge.yaml) - Will run the `preMerge` tasks as well as trying to run the Gradle plugin.
- [Publish to Plugin Portal](.github/workflows/publish-plugin.yaml) - Will run the `publishPlugin` task when pushing a new tag.
- This is using GitHub action to build, test and publish the plugin.
- `preMerge` task to run all the checks before pushing.

## Contributing 🤝

Feel free to open an issue or submit a pull request for any bugs/improvements.
* [PRs](https://github.com/hbmartin/gradle-plugin-caffeinate/pulls) and [bug reports or feature requests](https://github.com/hbmartin/gradle-plugin-caffeinate/issues) are all welcome!
* Treat other people with helpfulness, gratitude, and consideration! See the [JetBrains CoC](https://confluence.jetbrains.com/display/ALL/JetBrains+Open+Source+and+Community+Code+of+Conduct)

## License 📄

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ gradleEnterprise {
}
}

rootProject.name = "kotlin-gradle-plugin-template"
rootProject.name = "gradle-plugin-caffeinate"

include(":example")
includeBuild("plugin-build")

0 comments on commit ebe12df

Please sign in to comment.