I’ve seen these and read through them…
… they don’t seem to answer my question.
I have a “production” logback configuration file logback.xml under src/main/resources… but that directory also contains the “testing” logback configuration file logback-test.xml (which logback looks for first).
When creating an executable jar I want to delete the “testing” xml file.
I tried this
jar {
manifest {
// PS this is the correct line for Shadow Plugin...
attributes 'Class-Path': '/libs/a.jar'
attributes 'Main-Class': 'core.MyMainClass'
}
exclude("**/resources/*test*")
}
and I tried this
jar {
manifest {
attributes 'Class-Path': '/libs/a.jar'
attributes 'Main-Class': 'core.MyMainClass'
}
doLast {
exclude("**/resources/*test*")
}
}
… what am I doing wrong?
I find [here][1] that I was probably making life difficult for myself in putting these xmls under /src/main/resources … so I created a new directory under src, /logback, and put the files in there instead. I added this to the classpath (as logback says that’s where it looks for these files) by doing this:
test {
classpath += files( 'src/logback' )
}
Interestingly, as well as meaning that logging during testing happens OK, this is enough to get the resulting executable jar to use logback OK when run.
Unfortunately, configuring the “shadowJar” task
like this
shadowJar {
baseName = 'DocumentIndexer'
classifier = null
version = project.version
exclude("logback/*test*")
}
or configuring “jar” task
like this:
jar {
manifest {
attributes 'Class-Path': '/libs/a.jar'
attributes 'Main-Class': 'core.ConsoleIOHandler'
}
exclude("logback/*test*")
}
… just refuses to work: the file logback-test.xml is still there in the jar.
[1]: How to exclude src/main/resources files from the final WAR? - #2 by jjustinic