Question

I have an EAR file built by maven and currently I have a commons project which I'd like to put in an EAR\lib, so I used the maven-ear-plugin with the 'bundleDir' tag which works fine, only that now my commons.jar appears in both the lib folder and the EAR root. How do I tell it to put it only in the lib folder?

My pom:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <configuration>
                <outputDirectory>../../outputs/java</outputDirectory>
                <version>5</version>
                <modules>
                    <jarModule>
                        <groupId>com.sample.common</groupId>
                        <artifactId>common</artifactId>
                        <includeInApplicationXml>
                            true
                        </includeInApplicationXml>
                        <bundleDir>/lib</bundleDir>
                    </jarModule>
                    ...
                </modules>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>ear</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

And here is the dependency definition:

<dependency>
        <groupId>com.sample.common</groupId>
        <artifactId>common</artifactId>
        <version>1.0</version>
        <scope>provided</scope>
    </dependency>
Was it helpful?

Solution

If your jar file is not ejb you can simply put it to ear dependency without definition into maven-ear-plugin. Otherwise try to setup scope provided to your jar inside the dependency list. This may help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top