-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the plugin, improve the logging for the git provider
- Loading branch information
Showing
3 changed files
with
118 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/groovy/wooga/gradle/version/internal/GitBuildService.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package wooga.gradle.version.internal | ||
|
||
import org.ajoberstar.grgit.Grgit | ||
import org.gradle.api.services.BuildService | ||
import org.gradle.api.services.BuildServiceParameters | ||
|
||
/** | ||
* Implemented from https://docs.gradle.org/current/userguide/build_services.html#build_services | ||
*/ | ||
abstract class GitBuildService implements BuildService<BuildServiceParameters.None>, AutoCloseable { | ||
|
||
List<Grgit> instances = [] | ||
|
||
GitBuildService() { | ||
} | ||
|
||
/** | ||
* Opens the repository at the given directory path. When the gradle build has finished, | ||
* will automatically close it | ||
* @param directory The file path to the git repository | ||
* @return A managed git repository | ||
*/ | ||
Grgit getRepository(String directory) { | ||
Grgit git = Grgit.open(dir: directory) | ||
instances.add(git) | ||
return git | ||
} | ||
|
||
@Override | ||
void close() throws Exception { | ||
for(instance in instances) { | ||
System.out.println("Closing Git repository: ${instance.repository.rootDir}") | ||
instance.close() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters