Adding dependencies to other modules
You can add dependencies to other modules by setting the addClasspath element to true in the pom.xml file or by using the POM editor.
About this task
Important: Applicable to Liberty, WebSphere® Application Server traditional
Procedure
-
Set
addClasspathto true in the pom.xml source.-
Open the pom.xml file and access
the source view.
To access the source view, right-click the pom.xml file in the project and select Open With > Maven POM Editor. Click the pom.xml tab.
-
Find the correct
<plugin>section to update.Look for the<plugin><artifactID>section that corresponds to your project type. For example, a web project that was converted to a Maven project has theartifactIDset tomaven-war-plugin. A converted EJB project will have theartifactIDset tomaven-ejb-plugin.The following example shows the<plugin>section with theartifactIDmaven-war-plugin:<plugin> <artifactId>maven-war-plugin</artifactId> <version>2.2</version> <configuration> <warSourceDirectory>WebContent</warSourceDirectory> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> -
Update the
<configuration>section to setaddClasspathto true.Add the following code inside the configuration section:
The following example shows a completed section for a<archive> <manifest> <addClasspath>true</addClasspath> </manifest> </archive>maven-war-pluginartifact withaddClasspathset to true.<plugin> <artifactId>maven-war-plugin</artifactId> <version>2.2</version> <configuration> <warSourceDirectory>WebContent</warSourceDirectory> <failOnMissingWebXml>false</failOnMissingWebXml> <archive> <manifest> <addClasspath>true</addClasspath> </manifest> </archive> </configuration> </plugin>
-
Open the pom.xml file and access
the source view.
-
Use the Dependencies tab of the POM editor to add the dependency.
Click the Dependencies tab. Click Add to access the select dependency dialog. Enter the values for the module that you want to add as a dependency. Click OK when finished.Note: When a dependency is added to a web project, the dependency is included by default in WEB-INF/lib location. If the maven-war-plugin is configured to add the class path to the MANIFEST.MF file, then every dependency is included in both the MANIFEST.MF file and the WEB-INF/lib location. If you want the dependency to be included only in the MANIFEST.MF file, mark the dependency as optional. To mark a dependency as optional, in the Dependencies tab, select the dependency, click the Properties button. In the properties, check the Optional box and click OK.