Revised Question (old question below):
Problem: When building and running a Jenkins plugin project in NetBeans using Maven, Java class loader used by log4j does not find some files (like configuration file, a custom appender, JDBC driver). They need to be copied to another location under target
, and then they are found.
The solution I think I want is this: I want to give maven an extra command line argument(s), configured in NetBeans. This should make maven do extra step after building and before running anything. The step can either be the file copying (specified in pom.xml or by the command arguments), or it can be running a script (specified in pom.xml or by the command line arguments).
What to add to pom.xml? Some maven plugin?
Old Question (for reference)
I have a maven project for "my-jenkins-plugin". I need to use log4j with it. I currently have log4j.xml at this path:
./src/main/resources/log4j.xml
When I do clean&build in Netbeans, it gets copied to these places:
./target/classes/log4j.xml
./target/generated-classes/emma/classes/log4j.xml
./target/my-jenkins-plugin/WEB-INF/classes/log4j.xml
However, log4j does not find the file from any of these locations. I need to manually copy it to this location:
./target/work/webapp/WEB-INF/classes/log4j.xml
And then it works as expected.
More details: Maven 2, Netbeans 7.2. It's standard Jenkins plugin, project originally created with mvn hpi:create
, and Netbeans uses Jetty to run Jenkins. Classpath used when running under NetBeans is java.class.path=C:\work\maven\boot\classworlds-1.1.jar
(which is an existing jar) and I haven't found a way to add anything to this classpath, but if I add log4j.xml to root of that jar file, it is also found and works (obviously this is not a satisfactory solution). I know if log4j works or not simply by looking at console output, either it's correct log lines, or the dreaded log4j:WARN No appenders could be found for logger (TestLog). log4j:WARN Please initialize the log4j system properly.
error and nothing else.
Question: How can I have either
- the log4j.xml found in the first set of locations,
- or log4j.xml found in a location outside target dir, like C:\log4j\log4j.xml
- or make maven and/or netbeans to copy log4j.xml to a location where it is found now
- or any other nice way to let me give my plugin log4j.xml after clean&build automatically, when debugging with NB?