@@ -13,6 +13,7 @@ import org.gradle.api.file.FileCollection
1313import org.gradle.api.tasks.InputFiles
1414import org.gradle.api.tasks.SkipWhenEmpty
1515import org.gradle.api.tasks.TaskAction
16+ import java.io.File
1617import java.io.IOException
1718
1819/* *
@@ -40,32 +41,33 @@ open class CheckGitIgnoreTask : BaseTask(), PlainFilesAware {
4041 } catch (exception: IOException ) {
4142 throw GradleException (" Git repository was not found at path $projectDir " , exception)
4243 }
43- val plainFiles = plainFiles.mapNotNull { it.toRelativeString(projectDir.asFile) }. toHashSet()
44+ val plainFiles = plainFiles.toHashSet()
4445 TreeWalk (git.repository).use { treeWalk -> walkThrough(git, treeWalk, plainFiles) }
4546 failTaskIfAnyFilesLeft(plainFiles)
4647 }
4748
48- private fun walkThrough (git : Git , treeWalk : TreeWalk , plainFiles : MutableCollection <String >) {
49+ private fun walkThrough (git : Git , treeWalk : TreeWalk , plainFiles : MutableCollection <File >) {
4950 val fileTreeIterator = FileTreeIterator (git.repository)
5051 fileTreeIterator.setWalkIgnoredDirectories(true )
5152 treeWalk.addTree(fileTreeIterator)
5253 treeWalk.isRecursive = true
5354 while (treeWalk.next() && plainFiles.isNotEmpty()) {
5455 if (treeWalk.getTree(WorkingTreeIterator ::class .java).isEntryIgnored) {
55- val path = treeWalk.pathString
56- val removed = plainFiles.remove(path )
56+ val file = projectDir.file( treeWalk.pathString).asFile
57+ val removed = plainFiles.remove(file )
5758 if (removed) {
58- logger.info(" $path is ignored" )
59+ logger.info(" $file is ignored" )
5960 }
6061 }
6162 }
6263 }
6364
64- private fun failTaskIfAnyFilesLeft (relativePlainFiles : Collection <String >) {
65+ private fun failTaskIfAnyFilesLeft (relativePlainFiles : Collection <File >) {
6566 if (relativePlainFiles.isNotEmpty()) {
6667 relativePlainFiles.forEach { plainFile ->
68+ val fileForLog = plainFile.relativeToOrNull(projectDir.asFile) ? : plainFile
6769 logger.error(
68- " ${projectDir.file(plainFile)} is not ignored by any ${Constants .DOT_GIT_IGNORE } files of project"
70+ " $fileForLog is not ignored by any ${Constants .DOT_GIT_IGNORE } files of project"
6971 )
7072 }
7173 throw GradleException (" Some plain files are not ignored by git, see log above" )
0 commit comments