Wanted to have a link here, since it takes me a while to find it: http://maven.apache.org/plugins/maven-eclipse-plugin/examples/attach-library-sources.html.
Archive for November, 2008
How to add sources to Eclipse/Idea project generated by Maven
Friday, November 21st, 2008Ive released configuration manager 1.6
Friday, November 21st, 2008Configuration Manager 1.6 provides easy API for integrating it into your code (literally 2 lines and a small xml file), and easy Unit testing of the code that is dependent on configuration manager. Visit http://configmanager.sourceforge.net/ for more details.
Maven – fixing classpath issues for tests
Monday, November 10th, 2008We had problems with tests not finding files that we usually package outside the jar. One of such files was log4j.xml and other files were configuration files for spring framework. We need to pass full path to the log4j file, so that we dont have to rely on class path priorities to look it up. Given that log4j.xml is such a widely used file, it is probable that one of the dependent jar would have a copy in the archive so we can pick up the wrong file by mistake. On the other hand, we want to have our spring framework configuration files in the class path, but outside the jar. This way we can modify the configuration on the fly if we need to. So to setup integration test case, we needed to get the full path to the log4j.xml file and adding a directory to the class path for test only.
Here is how to do that:
public static String getFullPath(Class c, String name){
ClassLoader cl = c.getClassLoader();
URL url = cl.getResource(name);
return url != null ? url.getPath() : null;
}
and for adding class path:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>./src/main/config/</additionalClasspathElement>
<additionalClasspathElement>./mymodule/src/main/config/</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>