private boolean copyRelease ( Path src , Path dest , boolean isTop , boolean isForced ) { try { if ( ! fs . exists ( dest ) ) { if ( ! fs . mkdirs ( dest ) ) { LOG . error ( "Unable to make dir " + dest . toString ( ) ) ; return false ; } } else { if ( isTop && ! isForced ) { Path donePath = new Path ( dest , RELEASE_TAG_FILE ) ; if ( fs . exists ( donePath ) ) { LOG . info ( donePath + " exists. There is no need to copy again" ) ; return true ; } } } for ( FileStatus fileStat : fs . listStatus ( src ) ) { Path srcPath = fileStat . getPath ( ) ; if ( ! fileStat . isDir ( ) ) { boolean copyFlag = true ; if ( release_pattern != null ) { Matcher m = release_pattern . matcher ( srcPath . toString ( ) ) ; if ( ! m . find ( ) ) { copyFlag = false ; } } if ( copyFlag ) { Path destPath = new Path ( dest , srcPath . getName ( ) ) ; fs . copyFromLocalFile ( srcPath , destPath ) ; } } else { Path destPath = new Path ( dest , srcPath . getName ( ) ) ; if ( ! copyRelease ( srcPath , destPath , false , isForced ) ) { LOG . error ( "Unable to create link for " + srcPath . toString ( ) + " as " + destPath . toString ( ) ) ; return false ; } } } if ( isTop ) { // create the tag file Path donePath = new Path ( dest , RELEASE_TAG_FILE ) ; FSDataOutputStream fos = fs . create ( donePath ) ; fos . close ( ) ; } } catch ( IOException ioe ) { LOG . error ( "IOException when link dir " , ioe ) ; return false ; } return true ; }
For every jar files from the source create a link in the dest