protected File zipSubfolder ( File rootDir , String zipSubFolder , String zipFileName , String archiveFolder ) throws MojoExecutionException { int resultCode = 0 ; try { File scriptDirectory = new File ( project . getBuild ( ) . getDirectory ( ) , "scripts" ) . getCanonicalFile ( ) ; scriptDirectory . deleteOnExit ( ) ; if ( archiveFolder != null ) { resultCode = ScriptRunner . copyAndExecuteScript ( System . out , "/com/sap/prd/mobile/ios/mios/zip-subfolder.sh" , scriptDirectory , rootDir . getCanonicalPath ( ) , zipSubFolder , zipFileName , archiveFolder ) ; } else { resultCode = ScriptRunner . copyAndExecuteScript ( System . out , "/com/sap/prd/mobile/ios/mios/zip-subfolder.sh" , scriptDirectory , rootDir . getCanonicalPath ( ) , zipSubFolder , zipFileName ) ; } } catch ( Exception ex ) { throw new MojoExecutionException ( "Cannot create zip file " + zipFileName + ". Check log for details." , ex ) ; } if ( resultCode != 0 ) { throw new MojoExecutionException ( "Cannot create zip file " + zipFileName + ". Check log for details." ) ; } getLog ( ) . info ( "Zip file '" + zipFileName + "' created." ) ; return new File ( rootDir , zipFileName ) ; }
Calls a shell script in order to zip a folder . We have to call a shell script as Java cannot zip symbolic links .