Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify common resources in a multi-module maven project

Is there any way to share resources between modules of a parent project in Maven? For example, I would like to specify one log4j.properties file for all the modules in a multi-module Maven project.

Generally, I use Eclipse IDE to create the parent project by choosing a general project and then convert it to a Maven project by specifying a packaging of pom. This creates a "clean" project structure without src and etc. folders. I wonder where such a shared resource should be put in this case.

EDIT1: I would like to put the common resources in the parent project.

like image 844
jilt3d Avatar asked Jul 05 '13 15:07

jilt3d


2 Answers

I'd create one additional "base" module (project), packaging "jar", that contains the common resources in src/main/resources. Then I'd make the other modules depend on that project. Now they see the common resources on their classpaths.

like image 126
Andreas Dolk Avatar answered Sep 22 '22 22:09

Andreas Dolk


Antoher possibility is to use a remote resource bundle. You would be able to configure it in the parent project. In this example I wanted to copy some files just for tests. If you use this you will need to create the bundle in another project.

    <plugin>               <groupId>org.apache.maven.plugins</groupId>                  <artifactId>maven-remote-resources-plugin</artifactId>         <version>1.5</version>         <configuration>             <resourceBundles>                 <resourceBundle>es.sca:myBundle:1.0.0</resourceBundle>             </resourceBundles>             <attachToMain>false</attachToMain>             <attachToTest>true</attachToTest>             <appendedResourcesDirectory>${basedir}/src/test/resources</appendedResourcesDirectory>         </configuration>                     <executions>             <execution>                 <goals>                     <goal>process</goal>                 </goals>             </execution>         </executions>                        </plugin>                  
like image 39
borjab Avatar answered Sep 24 '22 22:09

borjab