I have the following gradle task that I use to create a debian archive:
val packDeb by tasks.registering(Deb::class) {
mkdir("/var/lib/salam/")
}
But I get the following error when I run ./gradlew build
org.gradle.api.UncheckedIOException: Failed to create directory '/var/lib/salam'
What am I doing wrong here?
The mkdir
method that you are using is not part of the Deb
task (but rather comes from the project
object). The method is called at the time your Gradle project is configured, i.e., Gradle tries to create that directory at the time when Gradle starts up. This most likely fails because the user account with which you run Gradle does not have write permissions under /var/lib
.
To create that directory when installing the DEB package, you could do something like this:
plugins {
id("nebula.deb") version "6.2.0"
}
import com.netflix.gradle.plugins.deb.Deb
val packDeb by tasks.registering(Deb::class) {
into("/")
// TODO assumes that the (non-empty) "salam" dir is prepared in your
// project dir
from("salam") {
into("var/lib/salam")
}
}