Plugin ear & ejbModule avec classifier.
Bonjour.
Pour faire simple (enfin essayer), j'ai un projet maven2 multi modules.
Un module ejb et un module app. Le jar généré dans le module ejb doit contenir les dépendances. Le module app génère l'ear.
Le pom du parent
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| <project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>be.tuto</groupId>
<artifactId>cendo2015</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>cendo2015</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
</dependencies>
</dependencyManagement>
<modules>
<module>modules/ejb</module>
<module>modules/app</module>
</modules> |
Le pom du module ejb
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| <?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>be.tuto</groupId>
<artifactId>cendo2015</artifactId>
<version>1.0</version>
</parent>
<artifactId>cendo2015-ejb</artifactId>
<packaging>ejb</packaging>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
<groupId>be.tuto</groupId>
<artifactId>test2015</artifactId>
<type>jar</type>
<version>1.0</version>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<ejbVersion>3.0</ejbVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>create-my-bundle</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build> |
et celui du module app
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>be.tuto</groupId>
<artifactId>cendo2015</artifactId>
<version>1.0</version>
</parent>
<artifactId>cendo2015-app</artifactId>
<name>${project.artifactId}</name>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>be.tuto</groupId>
<artifactId>cendo2015-ejb</artifactId>
<type>ejb</type>
<version>1.0</version>
<classifier>jar-with-dependencies</classifier>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<modules>
<ejbModule>
<groupId>be.tuto</groupId>
<artifactId>cendo2015-ejb</artifactId>
<classifier>jar-with-dependencies</classifier>
</ejbModule>
</modules>
</configuration>
</plugin>
</plugins>
</build> |
Si je fais un mvn clean package, ça ne marche pas.
Le jar avec les dépendances est bien créé et installé dans mon repository.
Code:
1 2 3 4 5 6
| [INFO] Building jar: ...\cendo2015\modules\ejb\target\cendo2015-ejb-1.0.jar
[INFO] [assembly:single {execution: default}]
[INFO] Building jar: ...\cendo2015\modules\ejb\target\cendo2015-ejb-1.0-jar-with-dependencies.jar
[INFO] [install:install {execution: default-install}]
[INFO] Installing ...\cendo2015\modules\ejb\target\cendo2015-ejb-1.0.jar to ...\.m2\repository\be\tuto\cendo2015-ejb\1.0\cendo2015-ejb-1.0.jar
[INFO] Installing ...\cendo2015\modules\ejb\target\cendo2015-ejb-1.0-jar-with-dependencies.jar to ...\.m2\repository\be\tuto\cendo2015-ejb\1.0\cendo2015-ejb-1.0-jar-with-dependencies.jar |
Mais build failure pour le module app
Code:
1 2 3 4 5
| [INFO] [ear:generate-application-xml {execution: default-generate-application-xml}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Artifact[ejb:be.tuto:cendo2015-ejb:jar-with-dependencies] is not a dependency of the project. |
Le truc bizzare c'est qu'il ne m'indique pas la version 1.0
Et ensuite, sans rien toucher je me place dans le module app et je fais un mvn clean package et ... ça marche !
Code:
1 2
| [INFO] [ear:ear {execution: default-ear}]
[INFO] Copying artifact [ejb:be.tuto:cendo2015-ejb:jar-with-dependencies:1.0] to [cendo2015-ejb-1.0-jar-with-dependencies.jar] |
Je ne comprends pas ce qui pose problème. Un bug du plugin ?
Merci pour votre aide.