I have the file "license.txt" in the root directory of my project. In the jar-task, I want to add this file to the (root folder of the) JAR file.
I tried
jar {
from '.' include 'license.txt'
}
but this replaces the other content (.class files) instead of adding a file. And I do not want to add the license.txt to the resources folder, because I do not want to change my project structure just because of the build tool.
Who can help? Thank you!
To add a dependency to your project, specify a dependency configuration such as implementation in the dependencies block of your module's build.gradle file.
repositories { flatDir { dirs("lib") } flatDir { dirs("lib1", "lib2") } } This adds repositories which look into one or more directories for finding dependencies. This type of repository does not support any meta-data formats like Ivy XML or Maven POM files.
A FileTree represents a hierarchy of files. It extends FileCollection to add hierarchy query and manipulation methods. You typically use a FileTree to represent files to copy or the contents of an archive. You can obtain a FileTree instance using Project.
To add a single file, you can simply do:
jar {
from "license.txt"
}
Your solution should also work if you scoped your include
to your from
by enclosing it in curly braces.
If you would like to add multiple files, you can do:
jar{
from{
["aaa.txt","bbb.txt"]
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With