Alternative to `libsDir` (2)

We have an old project that uses gradle 4.x and the property libsDir.

Similiar issue and same question like in this old issue Alternative to `libsDir` that was never answered.

Anybody know what the alternative is? I have found nothing in the documentation, nothing in de source code, nothing in the commit that deprecated it .

our task looks like this →

task jarWithoutVersion(type: Copy) {
from jar
into “$libsDir”
rename ‘(OurLib).+(.jar)’, ‘$1$2’

into base.libsDirectory

Btw. do you really need both jars?
Otherwise you can also simply change the name for the jar task.

And even if, you should not use a Copy task there.
The task would have the complete libs directory as output and thus is unclean.
That is bad as it overlaps with output from other tasks and has files as output that are not really outputs of the task and it depends on when the task is called which files count as outputs.
This hurts up-to-date checks (and if the task were cacheable would produce wrong cache entries).
Better use copy { ... } and configure the one file you have as input and the one file you have as output properly, so that up-to-date checks work properly.

thx, the mistake was done some times ago by with migration from gradle 4V to 7V →

  • into “$libsDir”
  • into “$libsDirectory”

It is only used for development, there we use several application servers with different versions and configurations.
Whenever we install a new one, we just link from the appserver lib directory to the libs of the build.

Well, all I said still applies and you should probably also not toStringify it, but use the provider properly as I showed.
Completely something like

tasks.register('jarWithoutVersion') {
    inputs.file jar
    outputs.file base.libsDirectory.file('OurLib.jar')
    doLast {
        copy {
            from jar
            into base.libsDirectory
            rename { 'OurLib.jar' }