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

  1. Set addClasspath to true in the pom.xml source.
    1. 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.
    2. 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 the artifactID set to maven-war-plugin. A converted EJB project will have the artifactID set to maven-ejb-plugin. The following example shows the <plugin> section with the artifactID maven-war-plugin:
      <plugin>
         <artifactId>maven-war-plugin</artifactId>
         <version>2.2</version>
         <configuration>
            <warSourceDirectory>WebContent</warSourceDirectory>
            <failOnMissingWebXml>false</failOnMissingWebXml>
         </configuration>
      </plugin>
    3. Update the <configuration> section to set addClasspath to true. Add the following code inside the configuration section:
      <archive>
         <manifest>
            <addClasspath>true</addClasspath>
         </manifest>
      </archive>
      The following example shows a completed section for a maven-war-plugin artifact with addClasspath set 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>
  2. 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.
Icon that indicates the type of topic Task topic
Timestamp icon Last updated: July 17, 2017 21:58

File name: add_dep.html