Skip to content

Commit

Permalink
Add maven central config and fix service plugin id
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoberstar committed Feb 10, 2022
1 parent 6921ab4 commit 0de6903
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ tasks.register("describe") {

## More Performant Usage in Gradle

Apply the `org.ajoberstar.grgit-service` plugin instead of `org.ajoberstar.grgit` to avoid eagerly resolving the `Grgit` instance. This works best with custom tasks that accept a `Property<GrgitService>`.
Apply the `org.ajoberstar.grgit.service` plugin instead of `org.ajoberstar.grgit` to avoid eagerly resolving the `Grgit` instance. This works best with custom tasks that accept a `Property<GrgitService>`.

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

```
import org.ajoberstar.grgit.gradle.GrgitService
plugins {
id 'org.ajoberstar.grgit-service' version '<version>'
id 'org.ajoberstar.grgit.service' version '<version>'
}
tasks.register("describe", DescribeTask) {
Expand All @@ -106,7 +106,7 @@ class DescribeTask extends DefaultTask {

If you are writing a custom Gradle plugin, you'll want to use one or both of the following approaches:

- 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 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*`.

```
Expand Down
7 changes: 7 additions & 0 deletions grgit-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ plugins {
group = "org.ajoberstar.grgit"
description = "The Groovy way to use Git"

mavenCentral {
developerName.set("Andrew Oberstar")
developerEmail.set("ajoberstar@gmail.com")
githubOwner.set("ajoberstar")
githubRepository.set("grgit")
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
Expand Down
9 changes: 8 additions & 1 deletion grgit-gradle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ plugins {
group = "org.ajoberstar.grgit"
description = "The Groovy way to use Git"

mavenCentral {
developerName.set("Andrew Oberstar")
developerEmail.set("ajoberstar@gmail.com")
githubOwner.set("ajoberstar")
githubRepository.set("grgit")
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
Expand Down Expand Up @@ -65,7 +72,7 @@ gradlePlugin {
implementationClass = "org.ajoberstar.grgit.gradle.GrgitPlugin"
}
create("grgitServicePlugin") {
id = "org.ajoberstar.grgit-service"
id = "org.ajoberstar.grgit.service"
displayName = "The Groovy way to use Git (BuildService edition)"
description = "The Groovy way to use Git (BuildService edition)"
implementationClass = "org.ajoberstar.grgit.gradle.GrgitServicePlugin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GrgitServicePluginCompatTest extends Specification {
import org.ajoberstar.grgit.gradle.GrgitService
plugins {
id 'org.ajoberstar.grgit-service'
id 'org.ajoberstar.grgit.service'
}
tasks.register("doStuff", DoStuffTask.class) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Plugin adding a {@code grgit} property to all projects that searches for a Git repo from the
* project's directory.
*
*
* @since 2.0.0
*/
public class GrgitPlugin implements Plugin<Project> {
Expand All @@ -17,7 +17,7 @@ public void apply(Project project) {
project.getPluginManager().apply(GrgitServicePlugin.class);
var serviceExtension = project.getExtensions().getByType(GrgitServiceExtension.class);
try {
project.getLogger().info("The org.ajoberstar.grgit plugin eagerly opens a Grgit instance. Use org.ajoberstar.grgit-service for better performance.");
project.getLogger().info("The org.ajoberstar.grgit plugin eagerly opens a Grgit instance. Use org.ajoberstar.grgit.service for better performance.");
project.getExtensions().add(Grgit.class, "grgit", serviceExtension.getService().get().getGrgit());
} catch (Exception e) {
project.getLogger().debug("Failed to open Grgit instance", e);
Expand Down

0 comments on commit 0de6903

Please sign in to comment.