Changes in the Maven Embedded GlassFish plugin
- by Romain Grecourt
The plugin changed its Maven coordinates (a.k.a GAV) over time:
version <= 3.1.1
available under org.glassfish:maven-glassfish-embedded-plugin
version >= 3.1.2
available under org.glassfish.embedded:maven-glassfish-embedded-plugin
The goal “glassfish-embedded:run” has changed its way of reading the deployment configuration in the latest version: 4.0.Projects using previous versions of the plugin will stop working with this goal.
Here is an example of the “old behavior”:
1
2
3
4
5
6
7
8
9
10
11
12
<plugin>
<groupId>org.glassfish.embedded</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.1.2.2</version>
<configuration>
<app>target/${project.build.finalName}.war</app>
<contextRoot>/</contextRoot>
<goalPrefix>embedded-glassfish</goalPrefix>
<autoDelete>true</autoDelete>
<port>8080</port>
</configuration>
</plugin>
The new behavior is as follow:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<plugin>
<groupId>org.glassfish.embedded</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>4.0</version>
<configuration>
<goalPrefix>embedded-glassfish</goalPrefix>
<autoDelete>true</autoDelete>
<port>8080</port>
</configuration>
<executions>
<execution>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<app>target/${project.build.finalName}.war</app>
<contextRoot>/</contextRoot>
</configuration>
</execution>
</executions>
</plugin>
The new version looks for execution of the deploy goal and the associated configuration, when running the goal ‘run’.
Both would allow you to run the latest version of the glassfish-embedded jar, you’d only need to add it as a plugin dependency:
1
2
3
4
5
6
7
8
9
10
<plugin>
[...]
<dependencies>
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>4.0</version>
</dependency>
</dependencies>
</plugin>