public URI buildWar ( ) { if ( option . getName ( ) == null ) { option . name ( UUID . randomUUID ( ) . toString ( ) ) ; } processClassPath ( ) ; try { File webResourceDir = getWebResourceDir ( ) ; File probeWar = new File ( tempDir , option . getName ( ) + ".war" ) ; ZipBuilder builder = new ZipBuilder ( probeWar ) ; for ( String library : option . getLibraries ( ) ) { File file = toLocalFile ( library ) ; /* * ScatteredArchive copies all directory class path items to WEB-INF/classes, * so that separate CDI bean deployment archives get merged into one. To avoid * that, we convert each directory class path to a JAR file. */ if ( file . isDirectory ( ) ) { file = toJar ( file ) ; } LOG . debug ( "including library {} = {}" , library , file ) ; builder . addFile ( file , "WEB-INF/lib/" + file . getName ( ) ) ; } builder . addDirectory ( webResourceDir , "" ) ; builder . close ( ) ; URI warUri = probeWar . toURI ( ) ; LOG . info ( "WAR probe = {}" , warUri ) ; return warUri ; } catch ( IOException exc ) { throw new TestContainerException ( exc ) ; } }
Builds a WAR from the given option .