public static boolean addToServer ( LibertyServer targetServer , String targetDir , String earName , boolean addEarResources , String warName , String [ ] warPackageNames , boolean addWarResources , String jarName , String [ ] jarPackageNames , boolean addJarResources ) throws Exception { if ( warName == null ) { throw new IllegalArgumentException ( "A war name must be specified." ) ; } if ( targetServer . isStarted ( ) ) { String appName = warName . substring ( 0 , warName . indexOf ( ".war" ) ) ; if ( ! targetServer . getInstalledAppNames ( appName ) . isEmpty ( ) ) { return false ; } } JavaArchive jar ; if ( jarName == null ) { jar = null ; } else { jar = createJar ( jarName , jarPackageNames , addJarResources ) ; // throws Exception } WebArchive war = createWar ( warName , warPackageNames , addWarResources , jar ) ; // throws Exception EnterpriseArchive ear ; if ( earName == null ) { ear = null ; } else { ear = createEar ( earName , addEarResources , war ) ; // throws Exception } if ( ear != null ) { ShrinkHelper . exportToServer ( targetServer , targetDir , ear ) ; // throws Exception } else { ShrinkHelper . exportToServer ( targetServer , targetDir , war ) ; // throws Exception } return true ; }
Conditionally package a JAR WAR and EAR and add them to a server .