protected void createFile ( File stagingDirectory ) throws MojoExecutionException { File targetDirectory = newSubdirectory ( stagingDirectory , "META-INF" ) ; File newEntry = new File ( targetDirectory , filename ) ; try ( FileOutputStream out = new FileOutputStream ( newEntry ) ; PrintStream ps = new PrintStream ( out ) ; ) { Iterator < ConfigEntry > iter = entries . values ( ) . iterator ( ) ; ConfigEntry entry = null ; for ( int i = 0 ; i < buffer . size ( ) ; i ++ ) { if ( entry == null && iter . hasNext ( ) ) { entry = iter . next ( ) ; } if ( entry != null && entry . placeholder == i ) { for ( String line : entry . buffer ) { ps . println ( line ) ; } entry = null ; continue ; } ps . println ( buffer . get ( i ) ) ; } } catch ( Exception e ) { throw new MojoExecutionException ( "Unexpected error while creating configuration file." , e ) ; } }
Create the xml configuration descriptor .