Skip to content

Commit

Permalink
Merge pull request #401 from johnjohndoe/patch-1
Browse files Browse the repository at this point in the history
Enable syntax highlighting
  • Loading branch information
ajoberstar authored Oct 5, 2024
2 parents afbc737 + e9e00ea commit f7ded15
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Apply the `org.ajoberstar.grgit` plugin in any project that needs to access a `G
> [!NOTE]
> This plugin eagerly opens a Grgit instance, which may not be needed depending on the tasks you want to run. If this is not desired, see the next section.
```
``` groovy
plugins {
id 'org.ajoberstar.grgit' version '<version>'
}
Expand All @@ -81,7 +81,7 @@ Apply the `org.ajoberstar.grgit.service` plugin instead of `org.ajoberstar.grgit

This approach ensures you only open a `Grgit` instance when a task is run that uses it.

```
``` groovy
import org.ajoberstar.grgit.gradle.GrgitService
plugins {
Expand Down Expand Up @@ -113,7 +113,7 @@ If you are writing a custom Gradle plugin, you'll want to use one or both of the
- If you need a `Grgit` instance representing the repository the project is in, use `org.ajoberstar.grgit.service` and use the `GrgitServiceExtension` to access the shared `GrgitService`. Wire this into any tasks or whatever needs to use the service via `Property<GrgitService>` for full lazy evaluation benefits.
- If you need a `Grgit` instance that's separate from the project's repository, declare your own `GrgitService` naming it something _not_ prefixed with `grgit*`.

```
``` groovy
Provider<GrgitService> serviceProvider = project.getGradle().getSharedServices().registerIfAbsent("grgit", GrgitService.class, spec -> {
// use getCurrentDirectory() if you need to search upwards from the provided directory
spec.getParameters().getCurrentDirectory().set(project.getLayout().getProjectDirectory());
Expand Down

0 comments on commit f7ded15

Please sign in to comment.