yan
yan

Reputation: 2982

How to include .gitignore in gradle zip task?

I have the following gradle (kotlin) code:

val zipFiles = fileTree("src/plugin/resources") {
    include("skeletons/common/.gitignore")
    include("skeletons/common/README.md")
}

// Creates the zip file loaded at runtime (we store it under buildDir/assets)
val zipTask = tasks.create<Zip>("zip") {
    from(zipFiles)
    archiveFileName.set(pluginZipFilename)
    destinationDirectory.set(File(buildDir, "assets"))
}

No matter what I do, the .gitignore file is ignored and does not make it in the zip file. How can I include it?

Thanks

Upvotes: 0

Views: 331

Answers (1)

yan
yan

Reputation: 2982

I found the answer in the gradle documentation:

gradle uses a (non published) list of default excludes and in order to change it you have to edit the settings.gradle.kts file this way:

import org.apache.tools.ant.DirectoryScanner

DirectoryScanner.removeDefaultExclude("**/.gitignore")

Note that it becomes global for the entire project and there does not seem to be a way to apply it to a particular file tree.

Upvotes: 2

Related Questions