Is there any way to tell maven the deploy order of ear files?
I have the following project structure:
app
|- pom.xml
|
|- commons (jar)
| |-pom.xml
|
|- integration (pom)
| |-pom.xm
| |
| ...
| |
| |-elasticsearch-search-service (pom)
| |-pom.xml
| |
| |-elasticsearch-search-service-bean (jar)
| | |-pom.xml
| |
| |-elasticsearch-search-service-ear (ear)
| |-pom.xml
|
|- services (pom)
|-pom.xml
|
|-search-service (jar)
| |-pom.xml
|
...
|
|-restapi-web (war)
| |-pom.xml
|
|-services-ear(ear)
|-pom.xml
The commons.jar is packaged under the lib folder in each ears. The services.ear calls ejb services from the elasticsearch-search-service-bean.jar so elasticsearch-search-service-ear must be deployed before services-ear.
When I run maven then it tries to deploy services-ear at first and of course it fails with No bean named elasticsearch-search-service-bean/SearchServiceBean is defined: not found in JNDI environment.
Everything is working fine when I deploy ears manually in a proper order.
I added a dependency into the service-ear project like this, but it does not work and the ear is not deployed before the others:
<dependency>
<groupId>...</groupId>
<artifactId>elasticsearch-search-service-bean</artifactId>
<version>...</version>
<scope>provided</scope>
</dependency>
If I try to add elasticsearch-search-service-ear dependency into the service-ear project than the deploy order is fine but I get this exception:
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project ...:services-ear:ear:1.0: Failure to find ...:elasticsearch-search-service-ear:jar:1.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
How I can tell to maven that start deploying the elasticsearch-search-service-ear before the other ears?
Finally I have found the solution.
The only one way to tell to maven the deploy order is to define dependencies between poms.
So if I want to deploy elasticsearch-search-service-ear before services-ear than I need to add a new dependency into services-ear.
<!-- elasticsearch-search-service.ear needs to be deployed before services.ear -->
<dependency>
<groupId>...</groupId>
<artifactId>elasticsearch-search-service-ear</artifactId>
<version>...</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
The two important settings here are:
I hope it helps to anyone who is in the same situation.