Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you generate module dependencies in MANIFEST.MF for JBoss AS 7 with maven?

In JBoss AS 7, a Web application that depends on libraries contained in the AS, must declare those dependencies in META-INF/MANIFEST.MF like this:

Dependencies: <package-name> 

Example:

Dependencies: org.slf4j 

(This is comparable to Import-Package: for OSGi.) Further information can be found in the articles about migration from older versions, class loading and implicit module dependencies for deployments

The project is built with Maven. All dependencies included in the AS are declared with scope 'provided'.

Now the question

Is there a simple way to create this list of dependencies automatically with Maven?

Only dependencies with declared scope 'provided' should be included, because all others are already included in the WAR.

like image 582
migu Avatar asked Jul 14 '11 08:07

migu


People also ask

How do I add dependencies to manifest file?

Add project dependency classpath. Normally, you will use maven-dependency-plugin to copy project dependencies to somewhere else. Following manifest file will be generated. The project dependencies will be copied to {project}/target/dependency-jars/ .

Where do I put JBoss deployment structure XML in war?

JBoss Deployment Structure File jboss-deployment-structure. xml is a JBoss specific deployment descriptor that can be used to control class loading in a fine grained manner. It should be placed in the top level deployment, in META-INF (or WEB-INF for web deployments).

How do I add a dependency in WildFly?

Installing a module on WildFly / JBoss EAP requires creating a path under the JBOSS_HOME/modules folder. Under this path, you will install the JAR libraries which are part of the module and a module. xml file which describes the module itself and dependencies with other module. Within the module.


2 Answers

Those dependencies are declared by names which maven artifacts don't have any mappings to. You probably could keep groupId in sync with jboss module names but I'm not sure if it's a good idea. And I still can't think of any automated solution.

But there is a place where you can manage the configuration by hand, as described in one of the sources you provided in your question:

   <build>        ...        <plugins>          <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-war-plugin</artifactId>            <configuration>               <archive>                  <manifestEntries>                     <Dependencies>org.slf4j</Dependencies>                  </manifestEntries>                 </archive>            </configuration>          </plugin>           </plugins>     </build> 

I hope someone comes up with a plugin to make it less cumbersome.

like image 125
Mike Minicki Avatar answered Sep 22 '22 13:09

Mike Minicki


This code add automaticaly all of your compile depedencies in your MANIFEST.MF

<plugin>    <groupId>org.apache.maven.plugins</groupId>    <artifactId>maven-war-plugin</artifactId>    <version>2.4</version>    <configuration>       <archive>          <manifest>             <addClasspath>true</addClasspath>          </manifest>       </archive>    </configuration> </plugin> 

more info here : http://maven.apache.org/plugins/maven-war-plugin/examples/war-manifest-guide.html

like image 31
Jérome Pieret Avatar answered Sep 21 '22 13:09

Jérome Pieret