Skip to content

Commit bac6ce0

Browse files
author
TheSnoozer
committed
Avoid injecting a project in GitCommitIdPluginGenerationTask
A build with gradle 5.4.1 is failing with ``` * What went wrong: A problem occurred evaluating root project 'git-commit-id-gradle-debugging.NiPqb7ARWM'. > Failed to apply plugin [id 'io.github.git-commit-id.git-commit-id-gradle-plugin'] > Could not create task ':gitCommitIdGenerationTask'. > No service of type Project available in ProjectScopeServices. ``` This is likely due to the fact that the GitCommitIdPluginGenerationTask is trying to inject a project. However I believe this is not even needed. Why? The expectation is that lazy properties are only supported with gradle 5.1 so we can treat it as minimal supported version. As per https://docs.gradle.org/5.1/javadoc/org/gradle/api/DefaultTask.html the DefaultTask inherits a Task. And as per https://docs.gradle.org/5.1/javadoc/org/gradle/api/Task.html#getProject() a task already has the ability to get the project. Hence there should be no need to inject a project into a GitCommitIdPluginGenerationTask / DefaultTask / Task.
1 parent a6f1cf9 commit bac6ce0

1 file changed

Lines changed: 0 additions & 13 deletions

File tree

src/main/java/io/github/git/commit/id/gradle/plugin/GitCommitIdPluginGenerationTask.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
import java.util.function.Supplier;
2828
import javax.annotation.Nonnull;
2929
import javax.annotation.Nullable;
30-
import javax.inject.Inject;
3130
import org.gradle.api.DefaultTask;
32-
import org.gradle.api.Project;
3331
import org.gradle.api.file.DirectoryProperty;
3432
import org.gradle.api.file.RegularFileProperty;
3533
import org.gradle.api.tasks.CacheableTask;
@@ -54,17 +52,6 @@
5452
*/
5553
@CacheableTask
5654
public class GitCommitIdPluginGenerationTask extends DefaultTask {
57-
/**
58-
* The project for which the task is running, or for which we want to generate
59-
* "git" information.
60-
*
61-
* @return The project
62-
*/
63-
@Inject
64-
public Project getProject() {
65-
throw new IllegalStateException();
66-
}
67-
6855
/**
6956
* The {@link GitCommitIdPluginExtension} that serves as configuration of the plugin / task.
7057
*

0 commit comments

Comments
 (0)