@@ -2511,78 +2511,88 @@ private void printDevModeMessages(boolean inputUnavailable, boolean startup) thr
25112511 hotTests = true ;
25122512 }
25132513 if (startup ) {
2514- if (container ) {
2515- boolean nonDefaultHttpPortUsed = !skipDefaultPorts && !String .valueOf (LIBERTY_DEFAULT_HTTP_PORT ).equals (httpPort );
2516- boolean nonDefaultHttpsPortUsed = !skipDefaultPorts && !String .valueOf (LIBERTY_DEFAULT_HTTPS_PORT ).equals (httpsPort );
2517- boolean nonDefaultDebugPortUsed = alternativeDebugPort != -1 ; // this is set when a random ephemeral port is selected
2518- if (containerHttpPort != null || containerHttpsPort != null || libertyDebug ) {
2514+ printPortInfo (true );
2515+ // print barrier footer
2516+ info (formatAttentionBarrier ());
2517+ }
2518+ }
2519+
2520+ private void printPortInfo (boolean pKeyPressed ) throws PluginExecutionException {
2521+ if (container ) {
2522+ boolean nonDefaultHttpPortUsed = !skipDefaultPorts && !String .valueOf (LIBERTY_DEFAULT_HTTP_PORT ).equals (httpPort );
2523+ boolean nonDefaultHttpsPortUsed = !skipDefaultPorts && !String .valueOf (LIBERTY_DEFAULT_HTTPS_PORT ).equals (httpsPort );
2524+ boolean nonDefaultDebugPortUsed = alternativeDebugPort != -1 ; // this is set when a random ephemeral port is selected
2525+ if (containerHttpPort != null || containerHttpsPort != null || libertyDebug ) {
2526+ if (!pKeyPressed ) {
2527+ //this line not needed when showing port info on keypress of "p"
25192528 info (formatAttentionMessage ("" ));
2520- info (formatAttentionTitle ("Liberty container port information:" ));
2521- }
2522- if ((containerHttpPort != null && httpPort != null && nonDefaultHttpPortUsed )
2523- || (containerHttpsPort != null && httpsPort != null && nonDefaultHttpsPortUsed )
2524- || (libertyDebug && nonDefaultDebugPortUsed )) {
2525- warn (formatAttentionMessage ("The Liberty container is using non-default host ports to avoid port conflict errors." ));
25262529 }
2527- if (containerHttpPort != null ) {
2528- if (httpPort != null ) {
2529- if (!nonDefaultHttpPortUsed ) {
2530- info (formatAttentionMessage ("Internal container HTTP port [ " + containerHttpPort + " ] is mapped to container host port [ " + httpPort + " ]" ));
2531- } else {
2532- info (formatAttentionMessage ("Internal container HTTP port [ " + containerHttpPort + " ] is mapped to container host port [ " + httpPort + " ] <" ));
2533- }
2530+ info (formatAttentionTitle ("Liberty container port information:" ));
2531+ }
2532+ if ((containerHttpPort != null && httpPort != null && nonDefaultHttpPortUsed )
2533+ || (containerHttpsPort != null && httpsPort != null && nonDefaultHttpsPortUsed )
2534+ || (libertyDebug && nonDefaultDebugPortUsed )) {
2535+ warn (formatAttentionMessage ("The Liberty container is using non-default host ports to avoid port conflict errors." ));
2536+ }
2537+ if (containerHttpPort != null ) {
2538+ if (httpPort != null ) {
2539+ if (!nonDefaultHttpPortUsed ) {
2540+ info (formatAttentionMessage ("Internal container HTTP port [ " + containerHttpPort + " ] is mapped to container host port [ " + httpPort + " ]" ));
25342541 } else {
2535- info (formatAttentionMessage ("Internal container HTTP port: [ " + containerHttpPort + " ]" ));
2542+ info (formatAttentionMessage ("Internal container HTTP port [ " + containerHttpPort + " ] is mapped to container host port [ " + httpPort + " ] < " ));
25362543 }
2544+ } else {
2545+ info (formatAttentionMessage ("Internal container HTTP port: [ " + containerHttpPort + " ]" ));
25372546 }
2538- if (containerHttpsPort != null ) {
2539- if (httpsPort != null ) {
2540- if (!nonDefaultHttpsPortUsed ) {
2541- info (formatAttentionMessage ("Internal container HTTPS port [ " + containerHttpsPort + " ] is mapped to container host port [ " + httpsPort + " ]" ));
2542- } else {
2543- info (formatAttentionMessage ("Internal container HTTPS port [ " + containerHttpsPort + " ] is mapped to container host port [ " + httpsPort + " ] <" ));
2544- }
2547+ }
2548+ if (containerHttpsPort != null ) {
2549+ if (httpsPort != null ) {
2550+ if (!nonDefaultHttpsPortUsed ) {
2551+ info (formatAttentionMessage ("Internal container HTTPS port [ " + containerHttpsPort + " ] is mapped to container host port [ " + httpsPort + " ]" ));
25452552 } else {
2546- info (formatAttentionMessage ("Internal container HTTPS port: [ " + containerHttpsPort + " ]" ));
2553+ info (formatAttentionMessage ("Internal container HTTPS port [ " + containerHttpsPort + " ] is mapped to container host port [ " + httpsPort + " ] < " ));
25472554 }
2555+ } else {
2556+ info (formatAttentionMessage ("Internal container HTTPS port: [ " + containerHttpsPort + " ]" ));
25482557 }
2549- if ( libertyDebug ) {
2550- int debugPort = ( alternativeDebugPort == - 1 ? libertyDebugPort : alternativeDebugPort );
2551- if (! nonDefaultDebugPortUsed ) {
2552- info ( formatAttentionMessage ( "Liberty debug port mapped to container host port: [ " + debugPort + " ]" ));
2553- } else {
2554- info ( formatAttentionMessage ( "Liberty debug port mapped to container host port: [ " + debugPort + " ] <" ));
2555- }
2558+ }
2559+ if ( libertyDebug ) {
2560+ int debugPort = ( alternativeDebugPort == - 1 ? libertyDebugPort : alternativeDebugPort );
2561+ if (! nonDefaultDebugPortUsed ) {
2562+ info ( formatAttentionMessage ( "Liberty debug port mapped to container host port: [ " + debugPort + " ]" ));
2563+ } else {
2564+ info ( formatAttentionMessage ( "Liberty debug port mapped to container host port: [ " + debugPort + " ] <" ));
25562565 }
2557- info (formatAttentionMessage ("" ));
2558- info (formatAttentionTitle ("Container network information:" ));
2559- info (formatAttentionMessage ("Container name: [ " + containerName + " ]" ));
2566+ }
2567+ info (formatAttentionMessage ("" ));
2568+ info (formatAttentionTitle ("Container network information:" ));
2569+ info (formatAttentionMessage ("Container name: [ " + containerName + " ]" ));
25602570
2561- String [] networks = getContainerNetworks (containerName );
2562- if (networks != null ) {
2563- for (String network : networks ) {
2564- info (formatAttentionMessage ("IP address [ " + getContainerIPAddress (containerName , network ) + " ] on container network [ " + network + " ]" ));
2565- }
2571+ String [] networks = getContainerNetworks (containerName );
2572+ if (networks != null ) {
2573+ for (String network : networks ) {
2574+ info (formatAttentionMessage ("IP address [ " + getContainerIPAddress (containerName , network ) + " ] on container network [ " + network + " ]" ));
25662575 }
25672576 }
2568- else {
2569- if (httpPort != null || httpsPort != null || libertyDebug ) {
2577+ }
2578+ else {
2579+ if (httpPort != null || httpsPort != null || libertyDebug ) {
2580+ if (!pKeyPressed ) {
2581+ //this line not needed when showing port info on keypress of "p"
25702582 info (formatAttentionMessage ("" ));
2571- info (formatAttentionTitle ("Liberty server port information:" ));
2572- }
2573- if (httpPort != null ) {
2574- info (formatAttentionMessage ("Liberty server HTTP port: [ " + httpPort + " ]" ));
2575- }
2576- if (httpsPort != null ) {
2577- info (formatAttentionMessage ("Liberty server HTTPS port: [ " + httpsPort + " ]" ));
2578- }
2579- if (libertyDebug ) {
2580- int debugPort = (alternativeDebugPort == -1 ? libertyDebugPort : alternativeDebugPort );
2581- info (formatAttentionMessage ("Liberty debug port: [ " + debugPort + " ]" ));
25822583 }
2584+ info (formatAttentionTitle ("Liberty server port information:" ));
2585+ }
2586+ if (httpPort != null ) {
2587+ info (formatAttentionMessage ("Liberty server HTTP port: [ " + httpPort + " ]" ));
2588+ }
2589+ if (httpsPort != null ) {
2590+ info (formatAttentionMessage ("Liberty server HTTPS port: [ " + httpsPort + " ]" ));
2591+ }
2592+ if (libertyDebug ) {
2593+ int debugPort = (alternativeDebugPort == -1 ? libertyDebugPort : alternativeDebugPort );
2594+ info (formatAttentionMessage ("Liberty debug port: [ " + debugPort + " ]" ));
25832595 }
2584- // print barrier footer
2585- info (formatAttentionBarrier ());
25862596 }
25872597 }
25882598
@@ -2612,6 +2622,7 @@ private void printHelpMessages() {
26122622 info (formatAttentionMessage ("r - restart the server, type 'r' and press Enter." ));
26132623 }
26142624 info (formatAttentionMessage ("h - see the help menu for available actions, type 'h' and press Enter." ));
2625+ info (formatAttentionMessage ("p - see the port information, type 'p' and press Enter." ));
26152626 info (formatAttentionMessage ("q - stop the server and quit dev mode, press Ctrl-C or type 'q' and press Enter." ));
26162627 }
26172628
@@ -2747,6 +2758,7 @@ private void readInput() {
27472758 HotKey g = new HotKey ("g" );
27482759 HotKey o = new HotKey ("o" );
27492760 HotKey t = new HotKey ("t" );
2761+ HotKey p = new HotKey ("p" );
27502762 HotKey enter = new HotKey ("" );
27512763 if (scanner .hasNextLine ()) {
27522764 synchronized (inputUnavailable ) {
@@ -2784,6 +2796,14 @@ private void readInput() {
27842796 warn ("Cannot optimize features because automatic generation of features is off." );
27852797 warn ("To toggle the automatic generation of features, type 'g' and press Enter." );
27862798 }
2799+ } else if (p .isPressed (line )) {
2800+ try {
2801+ info (formatAttentionBarrier ());
2802+ printPortInfo (true );
2803+ info (formatAttentionBarrier ());
2804+ } catch (PluginExecutionException e ) {
2805+ error ("Could not get port information." , e );
2806+ }
27872807 } else if ((t .isPressed (line ) && isChangeOnDemandTestsAction ()) || (enter .isPressed (line ) && !isChangeOnDemandTestsAction ())) {
27882808 debug ("Detected test command. Running tests... " );
27892809 if (isMultiModuleProject ()) {
0 commit comments