@@ -189,79 +189,81 @@ public ProtocolDescription getDefaultProtocol() {
189
189
190
190
@ Override
191
191
public ProtocolMetaData deploy (Archive <?> archive ) throws DeploymentException {
192
- // Because helidon doesn't have a dynamic war deployment model, we need to actually start the server here.
193
- RunContext context = new RunContext ();
194
- contexts .put (archive .getId (), context );
192
+ if (containerConfig .isMultipleDeployments () || (!containerConfig .isMultipleDeployments () && contexts .isEmpty ())) {
193
+ // Because helidon doesn't have a dynamic war deployment model, we need to actually start the server here.
194
+ RunContext context = new RunContext ();
195
+ contexts .put (archive .getId (), context );
195
196
196
- // Is it a JavaArchive?
197
- boolean isJavaArchive = archive instanceof JavaArchive ;
197
+ // Is it a JavaArchive?
198
+ boolean isJavaArchive = archive instanceof JavaArchive ;
198
199
199
- try {
200
- // Create the temporary deployment directory.
201
- if (containerConfig .getUseRelativePath ()) {
202
- context .deployDir = Paths .get ("target/helidon-arquillian-test" );
203
- } else {
204
- context .deployDir = Files .createTempDirectory ("helidon-arquillian-test" );
205
- }
206
- LOGGER .log (Level .INFO , "Running Arquillian tests in directory: " + context .deployDir .toAbsolutePath ());
200
+ try {
201
+ // Create the temporary deployment directory.
202
+ if (containerConfig .getUseRelativePath ()) {
203
+ context .deployDir = Paths .get ("target/helidon-arquillian-test" );
204
+ } else {
205
+ context .deployDir = Files .createTempDirectory ("helidon-arquillian-test" );
206
+ }
207
+ LOGGER .log (Level .INFO , "Running Arquillian tests in directory: " + context .deployDir .toAbsolutePath ());
207
208
208
- copyArchiveToDeployDir (archive , context .deployDir );
209
+ copyArchiveToDeployDir (archive , context .deployDir );
209
210
210
- for (Archive <?> additionalArchive : additionalArchives ) {
211
- copyArchiveToDeployDir (additionalArchive , context .deployDir );
212
- }
211
+ for (Archive <?> additionalArchive : additionalArchives ) {
212
+ copyArchiveToDeployDir (additionalArchive , context .deployDir );
213
+ }
213
214
214
- List <Path > classPath = new ArrayList <>();
215
+ List <Path > classPath = new ArrayList <>();
215
216
216
- Path rootDir = context .deployDir .resolve ("" );
217
- if (isJavaArchive ) {
218
- ensureBeansXml (rootDir , null );
219
- classPath .add (rootDir );
220
- } else {
221
- // Prepare the launcher files
222
- Path webInfDir = context .deployDir .resolve ("WEB-INF" );
223
- Path classesDir = webInfDir .resolve ("classes" );
224
- Path libDir = webInfDir .resolve ("lib" );
225
- ensureBeansXml (classesDir , webInfDir );
226
- addServerClasspath (classPath , classesDir , libDir , rootDir );
227
- if (containerConfig .isInWebContainer ()) {
228
- if (containerConfig .isIncludeWarContextPath ()) {
229
- context .rootContext = archive .getName ().split ("\\ ." )[0 ];
230
- }
231
- if (!loadApplicationFromWebXml (context , webInfDir )) {
232
- // Search Application in classes
233
- loadApplicationFromClasses (context , archive );
217
+ Path rootDir = context .deployDir .resolve ("" );
218
+ if (isJavaArchive ) {
219
+ ensureBeansXml (rootDir , null );
220
+ classPath .add (rootDir );
221
+ } else {
222
+ // Prepare the launcher files
223
+ Path webInfDir = context .deployDir .resolve ("WEB-INF" );
224
+ Path classesDir = webInfDir .resolve ("classes" );
225
+ Path libDir = webInfDir .resolve ("lib" );
226
+ ensureBeansXml (classesDir , webInfDir );
227
+ addServerClasspath (classPath , classesDir , libDir , rootDir );
228
+ if (containerConfig .isInWebContainer ()) {
229
+ if (containerConfig .isIncludeWarContextPath ()) {
230
+ context .rootContext = archive .getName ().split ("\\ ." )[0 ];
231
+ }
232
+ if (!loadApplicationFromWebXml (context , webInfDir )) {
233
+ // Search Application in classes
234
+ loadApplicationFromClasses (context , archive );
235
+ }
234
236
}
235
237
}
236
- }
237
238
238
- startServer (context , classPath .toArray (new Path [0 ]));
239
- } catch (IOException | SAXException | ParserConfigurationException e ) {
240
- LOGGER .log (Level .INFO , "Failed to start container" , e );
241
- throw new DeploymentException ("Failed to copy the archive assets into the deployment directory" , e );
242
- } catch (InvocationTargetException e ) {
239
+ startServer (context , classPath .toArray (new Path [0 ]));
240
+ } catch (IOException | SAXException | ParserConfigurationException e ) {
241
+ LOGGER .log (Level .INFO , "Failed to start container" , e );
242
+ throw new DeploymentException ("Failed to copy the archive assets into the deployment directory" , e );
243
+ } catch (InvocationTargetException e ) {
243
244
244
- try {
245
- context .runnerClass
246
- .getDeclaredMethod ("abortedCleanup" )
247
- .invoke (context .runner );
248
- } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException ex ) {
249
- ex .printStackTrace ();
250
- }
245
+ try {
246
+ context .runnerClass
247
+ .getDeclaredMethod ("abortedCleanup" )
248
+ .invoke (context .runner );
249
+ } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException ex ) {
250
+ ex .printStackTrace ();
251
+ }
251
252
252
- throw lookForSupressedDeploymentException (e .getTargetException ())
253
- .map (d ->
253
+ throw lookForSupressedDeploymentException (e .getTargetException ())
254
+ .map (d ->
254
255
new org .jboss .arquillian .container .spi .client .container .DeploymentException ("Deployment failure!" , d ))
255
- .orElseThrow (() -> new DefinitionException (e ));
256
- } catch (ReflectiveOperationException e ) {
257
- LOGGER .log (Level .INFO , "Failed to start container" , e );
258
- throw new DefinitionException (e ); // validation exceptions
259
- }
256
+ .orElseThrow (() -> new DefinitionException (e ));
257
+ } catch (ReflectiveOperationException e ) {
258
+ LOGGER .log (Level .INFO , "Failed to start container" , e );
259
+ throw new DefinitionException (e ); // validation exceptions
260
+ }
260
261
261
- // Server has started, so we're done.
262
- // ProtocolMetaData pm = new ProtocolMetaData();
263
- // pm.addContext(new HTTPContext("Helidon", "localhost", containerConfig.getPort()));
264
- // return pm;
262
+ // Server has started, so we're done.
263
+ // ProtocolMetaData pm = new ProtocolMetaData();
264
+ // pm.addContext(new HTTPContext("Helidon", "localhost", containerConfig.getPort()));
265
+ // return pm;
266
+ }
265
267
return new ProtocolMetaData ();
266
268
}
267
269
0 commit comments