protected Model createFlattenedPom ( File pomFile ) throws MojoExecutionException , MojoFailureException { ModelBuildingRequest buildingRequest = createModelBuildingRequest ( pomFile ) ; Model effectivePom = createEffectivePom ( buildingRequest , isEmbedBuildProfileDependencies ( ) , this . flattenMode ) ; Model flattenedPom = new Model ( ) ; // keep original encoding (we could also normalize to UTF-8 here) String modelEncoding = effectivePom . getModelEncoding ( ) ; if ( StringUtils . isEmpty ( modelEncoding ) ) { modelEncoding = "UTF-8" ; } flattenedPom . setModelEncoding ( modelEncoding ) ; Model cleanPom = createCleanPom ( effectivePom ) ; FlattenDescriptor descriptor = getFlattenDescriptor ( ) ; Model originalPom = this . project . getOriginalModel ( ) ; Model resolvedPom = this . project . getModel ( ) ; Model interpolatedPom = createResolvedPom ( buildingRequest ) ; // copy the configured additional POM elements... for ( PomProperty < ? > property : PomProperty . getPomProperties ( ) ) { if ( property . isElement ( ) ) { Model sourceModel = getSourceModel ( descriptor , property , effectivePom , originalPom , resolvedPom , interpolatedPom , cleanPom ) ; if ( sourceModel == null ) { if ( property . isRequired ( ) ) { throw new MojoFailureException ( "Property " + property . getName ( ) + " is required and can not be removed!" ) ; } } else { property . copy ( sourceModel , flattenedPom ) ; } } } return flattenedPom ; }
This method creates the flattened POM what is the main task of this plugin .