Hello
I’m trying to do that after the build task, some.bat file is copied to the build directory with this code:
tasks.register<Copy>("copyMainBat") {
from("src/main/runners/some.bat")
into(layout.buildDirectory.get())
}
tasks.build {
dependsOn("copyMainBat")
}
But it’s not working:
If i do
tasks.processResources{
dependsOn("copyMainBat")
}
instead of
tasks.build {
dependsOn("copyMainBat")
}
or
into(layout.buildDirectory.get().dir("bin"))
instead of
into(layout.buildDirectory.get())
it’s working fine but why can’t i just copy file to build directory with build task depending on custom task? I just don’t understand how processResources and jar tasks prevent copying directly into build dir
By the way, this working fine as well:
tasks.build {
inputs.file("some.bat")
.withPropertyName("inputBatFile")
outputs.dir(layout.buildDirectory.get())
.withPropertyName("outputDir")
doLast {
copy {
from("src/main/runners/some.bat")
into(layout.buildDirectory.get())
}
}
}
but this is not good practice, is it?