|  | 
| 1 |  | -Pre-requisite | 
|  | 1 | +# Maven Embedded GlassFish Plugin | 
| 2 | 2 | 
 | 
| 3 |  | -To build this project, JDK 11 is required. | 
|  | 3 | +A Maven plugin for managing Embedded GlassFish server instances during the build lifecycle. | 
|  | 4 | + | 
|  | 5 | +## Quick Start | 
|  | 6 | + | 
|  | 7 | +Run your project's main artifact on Embedded GlassFish directly from command line without modifying your `pom.xml`: | 
|  | 8 | + | 
|  | 9 | +```bash | 
|  | 10 | +mvn org.glassfish.embedded:embedded-glassfish-maven-plugin:7.1-SNAPSHOT:run -DglassfishVersion=7.0.25 | 
|  | 11 | +``` | 
|  | 12 | + | 
|  | 13 | +Or add the plugin to your `pom.xml`: | 
|  | 14 | + | 
|  | 15 | +```xml | 
|  | 16 | +<plugin> | 
|  | 17 | +    <groupId>org.glassfish.embedded</groupId> | 
|  | 18 | +    <artifactId>embedded-glassfish-maven-plugin</artifactId> | 
|  | 19 | +    <version>7.1-SNAPSHOT</version> | 
|  | 20 | +    <configuration> | 
|  | 21 | +        <glassfishVersion>7.0.25</glassfishVersion> | 
|  | 22 | +    </configuration> | 
|  | 23 | +</plugin> | 
|  | 24 | +``` | 
|  | 25 | + | 
|  | 26 | +Start the server with your application and wait until it stops: | 
|  | 27 | +```bash | 
|  | 28 | +mvn embedded-glassfish:run | 
|  | 29 | +``` | 
|  | 30 | + | 
|  | 31 | +## Prerequisites | 
|  | 32 | + | 
|  | 33 | +- JDK 11 or higher | 
|  | 34 | +- Maven 3.6.3 or higher | 
|  | 35 | + | 
|  | 36 | +## Basic Usage | 
|  | 37 | + | 
|  | 38 | +### Command Line | 
|  | 39 | + | 
|  | 40 | +Start server in background: | 
|  | 41 | +```bash | 
|  | 42 | +mvn embedded-glassfish:start | 
|  | 43 | +``` | 
|  | 44 | + | 
|  | 45 | +Deploy application: | 
|  | 46 | +```bash | 
|  | 47 | +mvn embedded-glassfish:deploy | 
|  | 48 | +``` | 
|  | 49 | + | 
|  | 50 | +Stop server: | 
|  | 51 | +```bash | 
|  | 52 | +mvn embedded-glassfish:stop | 
|  | 53 | +``` | 
|  | 54 | + | 
|  | 55 | +### Integration Testing | 
|  | 56 | + | 
|  | 57 | +```xml | 
|  | 58 | +<plugin> | 
|  | 59 | +    <groupId>org.glassfish.embedded</groupId> | 
|  | 60 | +    <artifactId>embedded-glassfish-maven-plugin</artifactId> | 
|  | 61 | +    <version>7.1-SNAPSHOT</version> | 
|  | 62 | +    <executions> | 
|  | 63 | +        <execution> | 
|  | 64 | +            <id>start-server</id> | 
|  | 65 | +            <phase>pre-integration-test</phase> | 
|  | 66 | +            <goals> | 
|  | 67 | +                <goal>start</goal> | 
|  | 68 | +                <goal>deploy</goal> | 
|  | 69 | +            </goals> | 
|  | 70 | +        </execution> | 
|  | 71 | +        <execution> | 
|  | 72 | +            <id>stop-server</id> | 
|  | 73 | +            <phase>post-integration-test</phase> | 
|  | 74 | +            <goals> | 
|  | 75 | +                <goal>undeploy</goal> | 
|  | 76 | +                <goal>stop</goal> | 
|  | 77 | +            </goals> | 
|  | 78 | +        </execution> | 
|  | 79 | +    </executions> | 
|  | 80 | +</plugin> | 
|  | 81 | +``` | 
|  | 82 | + | 
|  | 83 | +## Goals Overview | 
|  | 84 | + | 
|  | 85 | +| Goal | Description | Default Phase | | 
|  | 86 | +|------|-------------|---------------| | 
|  | 87 | +| [`start`](#start) | Starts an Embedded GlassFish server | pre-integration-test | | 
|  | 88 | +| [`stop`](#stop) | Stops the Embedded GlassFish server | post-integration-test | | 
|  | 89 | +| [`deploy`](#deploy) | Deploys an application to the server | pre-integration-test | | 
|  | 90 | +| [`undeploy`](#undeploy) | Undeploys an application from the server | post-integration-test | | 
|  | 91 | +| [`run`](#run) | Starts server and keeps it running | none | | 
|  | 92 | +| [`admin`](#admin) | Executes admin commands | none | | 
|  | 93 | + | 
|  | 94 | +## Configuration | 
|  | 95 | + | 
|  | 96 | +### Basic Configuration | 
|  | 97 | + | 
|  | 98 | +```xml | 
|  | 99 | +<plugin> | 
|  | 100 | +    <groupId>org.glassfish.embedded</groupId> | 
|  | 101 | +    <artifactId>embedded-glassfish-maven-plugin</artifactId> | 
|  | 102 | +    <version>7.1-SNAPSHOT</version> | 
|  | 103 | +    <configuration> | 
|  | 104 | +        <port>8080</port> | 
|  | 105 | +        <app>${project.build.directory}/${project.build.finalName}.war</app> | 
|  | 106 | +    </configuration> | 
|  | 107 | +</plugin> | 
|  | 108 | +``` | 
|  | 109 | + | 
|  | 110 | +- `port` - HTTP port number for the server (default: 8080) | 
|  | 111 | +- `app` - Path to the application artifact to deploy (default: main artifact) | 
|  | 112 | + | 
|  | 113 | +### Automatic Artifact Deployment | 
|  | 114 | + | 
|  | 115 | +The plugin automatically detects and deploys your project's main artifact without requiring explicit configuration: | 
|  | 116 | + | 
|  | 117 | +```xml | 
|  | 118 | +<plugin> | 
|  | 119 | +    <groupId>org.glassfish.embedded</groupId> | 
|  | 120 | +    <artifactId>embedded-glassfish-maven-plugin</artifactId> | 
|  | 121 | +    <version>7.1-SNAPSHOT</version> | 
|  | 122 | +    <configuration> | 
|  | 123 | +        <!-- Main artifact automatically deployed if no <app> parameter specified --> | 
|  | 124 | +    </configuration> | 
|  | 125 | +</plugin> | 
|  | 126 | +``` | 
|  | 127 | + | 
|  | 128 | +**Note:** Currently assumes WAR packaging. For other artifact types, specify the `app` parameter explicitly. | 
|  | 129 | + | 
|  | 130 | +### Admin Commands | 
|  | 131 | + | 
|  | 132 | +Execute administrative commands on the running server: | 
|  | 133 | + | 
|  | 134 | +```xml | 
|  | 135 | +<plugin> | 
|  | 136 | +    <groupId>org.glassfish.embedded</groupId> | 
|  | 137 | +    <artifactId>embedded-glassfish-maven-plugin</artifactId> | 
|  | 138 | +    <version>7.1-SNAPSHOT</version> | 
|  | 139 | +    <configuration> | 
|  | 140 | +        <commands> | 
|  | 141 | +            <command>set configs.config.server-config.network-config.protocols.protocol.http-listener.http.websockets-support-enabled=true</command> | 
|  | 142 | +            <command>create-jdbc-resource --connectionpoolid mypool jdbc/myresource</command> | 
|  | 143 | +        </commands> | 
|  | 144 | +    </configuration> | 
|  | 145 | +</plugin> | 
|  | 146 | +``` | 
|  | 147 | + | 
|  | 148 | +Command line usage: | 
|  | 149 | +```bash | 
|  | 150 | +mvn embedded-glassfish:admin -Dcommands="set server.monitoring-service.module-monitoring-levels.web-container=HIGH" | 
|  | 151 | +``` | 
|  | 152 | + | 
|  | 153 | +## Configuration Reference | 
|  | 154 | + | 
|  | 155 | +### Server Configuration | 
|  | 156 | +- `configFile` - Custom domain configuration file | 
|  | 157 | +- `glassfishVersion` - GlassFish version to use | 
|  | 158 | +- `port` - HTTP port number (default: 8080) | 
|  | 159 | +- `ports` - Map of port configurations | 
|  | 160 | +- `serverID` - Server identifier (default: "maven") | 
|  | 161 | + | 
|  | 162 | +### Application Deployment | 
|  | 163 | +- `app` - Path to application artifact to deploy (defaults to `${project.build.directory}/${project.build.finalName}.war`) | 
|  | 164 | +- `contextRoot` - Application context root | 
|  | 165 | +- `name` - Application name (default: "myapp") | 
|  | 166 | + | 
|  | 167 | +### Advanced Configuration | 
|  | 168 | +- `bootstrapProperties` - Bootstrap properties | 
|  | 169 | +- `glassfishProperties` - GlassFish server properties | 
|  | 170 | +- `instanceRoot` - Server instance root directory | 
|  | 171 | + | 
|  | 172 | +## Goal Reference | 
|  | 173 | + | 
|  | 174 | +### start | 
|  | 175 | +Starts an Embedded GlassFish server with the configured parameters. | 
|  | 176 | + | 
|  | 177 | +**Default Phase:** pre-integration-test | 
|  | 178 | + | 
|  | 179 | +**Configuration:** | 
|  | 180 | +- Uses all server configuration parameters (serverID, port, glassfishProperties, etc.) | 
|  | 181 | + | 
|  | 182 | +**Example:** | 
|  | 183 | +```bash | 
|  | 184 | +mvn embedded-glassfish:start | 
|  | 185 | +``` | 
|  | 186 | + | 
|  | 187 | +### stop | 
|  | 188 | +Stops the Embedded GlassFish server and cleans up resources. | 
|  | 189 | + | 
|  | 190 | +**Default Phase:** post-integration-test | 
|  | 191 | + | 
|  | 192 | +**Configuration:** | 
|  | 193 | +- `serverID` - Server identifier to stop (default: "maven") | 
|  | 194 | + | 
|  | 195 | +**Example:** | 
|  | 196 | +```bash | 
|  | 197 | +mvn embedded-glassfish:stop | 
|  | 198 | +``` | 
|  | 199 | + | 
|  | 200 | +### deploy | 
|  | 201 | +Deploys an application to the running Embedded GlassFish server. | 
|  | 202 | + | 
|  | 203 | +**Default Phase:** pre-integration-test | 
|  | 204 | + | 
|  | 205 | +**Configuration:** | 
|  | 206 | +- `app` - Application path (auto-detects if not specified) | 
|  | 207 | +- `name` - Application name (default: "myapp") | 
|  | 208 | +- `contextRoot` - Web application context root | 
|  | 209 | +- `deploymentParams` - Additional deployment parameters | 
|  | 210 | + | 
|  | 211 | +**Example:** | 
|  | 212 | +```bash | 
|  | 213 | +mvn embedded-glassfish:deploy -Dapp=target/myapp.war | 
|  | 214 | +``` | 
|  | 215 | + | 
|  | 216 | +### undeploy | 
|  | 217 | +Undeploys an application from the Embedded GlassFish server. | 
|  | 218 | + | 
|  | 219 | +**Default Phase:** post-integration-test | 
|  | 220 | + | 
|  | 221 | +**Configuration:** | 
|  | 222 | +- `name` - Application name to undeploy (default: "myapp") | 
|  | 223 | +- `undeploymentParams` - Additional undeployment parameters | 
|  | 224 | + | 
|  | 225 | +**Example:** | 
|  | 226 | +```bash | 
|  | 227 | +mvn embedded-glassfish:undeploy -Dname=myapp | 
|  | 228 | +``` | 
|  | 229 | + | 
|  | 230 | +### run | 
|  | 231 | +Starts the server, deploys applications, and runs interactively. Allows redeployment by pressing Enter or exit by typing 'X'. | 
|  | 232 | + | 
|  | 233 | +**Default Phase:** none (manual execution) | 
|  | 234 | + | 
|  | 235 | +**Configuration:** | 
|  | 236 | +- Combines all server and deployment configurations | 
|  | 237 | +- Executes all configured admin and deploy goals | 
|  | 238 | + | 
|  | 239 | +**Example:** | 
|  | 240 | +```bash | 
|  | 241 | +mvn embedded-glassfish:run | 
|  | 242 | +``` | 
|  | 243 | + | 
|  | 244 | +### admin | 
|  | 245 | +Executes administrative commands on the running server. | 
|  | 246 | + | 
|  | 247 | +**Default Phase:** pre-integration-test | 
|  | 248 | + | 
|  | 249 | +**Configuration:** | 
|  | 250 | +- `commands` - Array of admin commands to execute | 
|  | 251 | + | 
|  | 252 | +**Example:** | 
|  | 253 | +```bash | 
|  | 254 | +mvn embedded-glassfish:admin -Dcommands="create-jdbc-resource --connectionpoolid mypool jdbc/myresource" | 
|  | 255 | +``` | 
|  | 256 | + | 
|  | 257 | +## License | 
|  | 258 | + | 
|  | 259 | +Eclipse Public License v. 2.0 | 
0 commit comments