diff --git a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt index 73f5f266..ebcd4044 100644 --- a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt +++ b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt @@ -2,12 +2,10 @@ package org.jlleitschuh.gradle.ktlint import org.eclipse.jgit.lib.RepositoryBuilder import org.gradle.api.DefaultTask -import org.gradle.api.file.DirectoryProperty import org.gradle.api.file.ProjectLayout import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.Property import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputDirectory import org.gradle.api.tasks.TaskAction import org.intellij.lang.annotations.Language import org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask @@ -150,19 +148,13 @@ open class KtlintInstallGitHookTask @Inject constructor( @get:Input internal val hookName: Property = objectFactory.property(String::class.java) - @get:InputDirectory - internal val projectDir: DirectoryProperty = objectFactory.directoryProperty().apply { - set(projectLayout.projectDirectory) - } + private val projectDir = projectLayout.projectDirectory.asFile - @get:InputDirectory - internal val rootDirectory: DirectoryProperty = objectFactory.directoryProperty().apply { - set(project.rootDir) - } + private val rootDirectory = project.rootDir @TaskAction fun installHook() { - val repo = RepositoryBuilder().findGitDir(projectDir.get().asFile).setMustExist(false).build() + val repo = RepositoryBuilder().findGitDir(projectDir).setMustExist(false).build() if (!repo.objectDatabase.exists()) { logger.warn("No git folder was found!") return @@ -181,7 +173,7 @@ open class KtlintInstallGitHookTask @Inject constructor( gitHookFile.createNewFile() gitHookFile.setExecutable(true) } - val gradleRootDirPrefix = rootDirectory.get().asFile.relativeTo(repo.workTree).path + val gradleRootDirPrefix = rootDirectory.relativeTo(repo.workTree).path if (gitHookFile.length() == 0L) { gitHookFile.writeText(