public Pipeline watch ( ) { // Delete all error reports before starting the watcher. error = new File ( baseDir , "target/pipeline" ) ; FileUtils . deleteQuietly ( error ) ; mojo . getLog ( ) . debug ( "Creating the target/pipeline directory : " + error . mkdirs ( ) ) ; // Start the watching process. watcher = new FileAlterationMonitor ( Integer . getInteger ( "watch.period" , 2 ) * 1000 ) ; watcher . setThreadFactory ( new DefensiveThreadFactory ( "wisdom-pipeline-watcher" , mojo ) ) ; FileAlterationObserver srcObserver = new FileAlterationObserver ( new File ( baseDir , "src" ) , TrueFileFilter . INSTANCE ) ; PipelineWatcher listener = new PipelineWatcher ( this ) ; srcObserver . addListener ( listener ) ; watcher . addObserver ( srcObserver ) ; if ( pomFileMonitoring ) { FileAlterationObserver pomObserver = new FileAlterationObserver ( baseDir , new FileFilter ( ) { @ Override public boolean accept ( File file ) { return file . equals ( new File ( baseDir , "pom.xml" ) ) ; } } ) ; pomObserver . addListener ( listener ) ; watcher . addObserver ( pomObserver ) ; } try { mojo . getLog ( ) . info ( "Start watching " + baseDir . getAbsolutePath ( ) ) ; watcher . start ( ) ; } catch ( Exception e ) { mojo . getLog ( ) . error ( "Cannot start the watcher" , e ) ; } return this ; }
Starts the watching .