Logback child modules does not take config file of parent modules - maven-3

I have a multi-module project. I want all sub-modules to share same logging config for logback. However placing logback.xml in src/main/resources is not picked up by child modules.
Placing in root directory also does not get picked up by sub-modules
Only when I place logback.xml in resources directory of specific module, logback picks up the custom confifurations.
This is a headache to maintain multiple config files per module especially when I want to play around the config files and experiment for myself.
How can I achieve this?

Related

Building a non-uberjar Docker image with leiningen

I have a clojure project that depends on a Java library, that does not work, when it gets included in an uberjar. (It needs different XML descriptors using the same filename in different JAR files.)
Everything I find on using Docker with leiningen depends on building and packaging a uberjar. That's also how I built all clojure Docker images so far.
Is there any leiningen plugin out there, that understands to package a Docker image using several jar files like io.fabric8/docker-maven-plugin does?
Whenever packaging (uberjar, war) the big file that is created contains .class files and a directory structure. Where are these XML files supposed to be (class)loaded from? You can experiment with packing manually. After all it (whether uberjar, war or jar) is just a zip file.
When you know exactly the layout you need SBT is flexible enough to insure you can package from the many input jar files. Unfortunately lein plugins will do things like always overwrite duplicates, and you can't control the packaging behaviour. I can't remember exactly the inflexibilities, but I couldn't control how the packaging process went, what decisions were made.
For doing it manually I use a Linux something called Archive Manager, which I found to be much better than what I used when on Windows. Doing it manually may be all you need. The downside of SBT of course being that you have to learn it, which includes a bit of Scala.
It needs different XML descriptors using the same filename in different JAR files.
Just thinking about this, is it that you need to append the contents of each file that is in a different jar into the one file that is in the uberjar? You can try it out. If it works and you need to package up often enough that manually creating and renaming a zip file every time becomes a pain, then I believe that SBT will be your best bet.
I have to package my container with the original jar file and then reference this jar in the classpath when starting the application
The classloader loads classes rather than jars. It is the container's job to unpackage all the things you give it, such as .class files, (uber)jars, wars. Any program that dynamically loads from the classpath is loading either classes or resources (things like .xml files). I suppose a .jar file could be a resource, in which case you would put the jar file in the uberjar. So it is still possible to package it up.

How to add a “non-mavenized” jar dependency to a grails project (Grails 3.x)

I'm trying to find documentation and code samples on how to add a local / non-maven jar file to my Grails 3.x project?
I found the separate thread How to add a non-maven jar to grails - but that's only to grails 2.3, and the file structure and configuration has undergone a big overhaul in 3.x.
Any help and (especially) code samples would be wonderful! The .jar is in the local project directory, and I intend to package with the .war for deployment.
Additionally, once i add the dependency, should i just be able to call it's methods from the controller & service files? or do i need to include them in those as well?
thx!
Grails 3 uses Gradle, so there's nothing Grails specific about including a local jar. It's as easy as adding a file dependency to the dependencies block of your build.gradle file.
Per the Gradle documentation on File Dependencies:
To add some files as a dependency for a configuration, you simply pass a file collection as a dependency:
dependencies {
...
compile files('libs/a.jar', 'libs/b.jar')
// or
compile fileTree(dir: 'libs', include: '*.jar')
}
The above example shows two ways to include jars that exist in a local libs/ directory; you can do either/or. The jar(s) can be anywhere on the filesystem, just make sure you point to the correct path.
To use the classes from the dependency in your application, you'll include them in your services, controllers and all other classes like you normally would. Say libs/a.jar has a class org.example.Something, you'd add an import to the top of your Grails class like so:
import org.example.Something

How to add custom Grails plugin artefact directory

I have a Grails application and a custom plugin with separate code included in the main application in BuildConfig.groovy using grails.plugin.location.'my-plugin' = '../my-plugin'. Now I'm looking for a way to customize what artefact directories will be exported in the plugin. I want to place a custom resource file (e.g. SQL script) into src/resources directory of the plugin and I need to see the file on classpath of the main application. I know files in grails-app/conf and other directories get included along with the plugin source, but can the convention of resource directories be altered?

How to rename a file for a specific maven build profile

I've got changes to my web.xml config file that need to stay local-only since Google-App-Engine chokes on them when we try to use them, and they're really only needed for development purposes.
How can I make maven copy my src/main/webapp/WEB-INF/web_local.xml to be web.xml in the target WEB-INF directory?
I looked into maven-assembly-plugin, but that didn't provide a way to give a name to the ouput file (plus it seemed specifically for building .jar files).
You can use webXml property of the maven-war-plugin plugin configuration to point to custom web.xml

Shared variables in multi directory qmake

I have multiple qmake .pro files which are called from a root .pro file with a subdirs template.
What is the best way to change a setting for the whole build system (eg. release to debug).
Currently I can only do this by changing each sub .pro file, or using an external script to change each .pro file.
I was hoping there was a way to share qmake variables between the subdirs .pro file and the others.
The only way I know of doing this is through an include file: define all your variables in a vars.pri file at the root of your project and use include() in the .pro files to access the shared variable.
Qt Creator takes care of the issue quite nicely. When you compile a subdir project with a config all the child projects gets compiled with the config.
And for the all project tree a single shadow-build directory is used.

Resources