Source:
protected Model createFlattenedPom( File pomFile ) throws MojoExecutionException, MojoFailureException { ModelBuildingRequest buildingRequest = createModelBuildingRequest( pomFile ); Model effectivePom = createEffectivePom( buildingRequest, isEmbedBuildProfileDependencies(), this.flattenMode ); Dependencies managedDependencies = new Dependencies(); if (effectivePom.getDependencyManagement() != null && effectivePom.getDependencyManagement().getDependencies() != null) managedDependencies.addAll(effectivePom.getDependencyManagement().getDependencies()); if (effectivePom.getProfiles() != null) { for (Profile prof : effectivePom.getProfiles()) { if (prof.getDependencies() == null) continue; for (Dependency dep : prof.getDependencies()) { if (managedDependencies.contains(dep)) { dep.setVersion(managedDependencies.resolve(dep).getVersion()); dep.setScope(managedDependencies.resolve(dep).getScope()); dep.setOptional(managedDependencies.resolve(dep).getOptional()); } } } } Model flattenedPom = new Model(); String modelEncoding = effectivePom.getModelEncoding(); if ( StringUtils.isEmpty( modelEncoding ) ) { modelEncoding = "UTF-8"; } flattenedPom.setModelEncoding( modelEncoding ); Model cleanPom = null; try { cleanPom = createCleanPom( effectivePom ); } catch (Exception e) { throw new MojoExecutionException("failed to create a clean pom", e); } FlattenDescriptor descriptor = getFlattenDescriptor(); Model originalPom = this.project.getOriginalModel(); Model resolvedPom = this.project.getModel(); Model interpolatedPom = createResolvedPom( buildingRequest ); 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; }

Target:
protected Model createFlattenedPom( File pomFile ) throws MojoExecutionException, MojoFailureException { ModelBuildingRequest buildingRequest = createModelBuildingRequest( pomFile ); Model effectivePom = createEffectivePom( buildingRequest, isEmbedBuildProfileDependencies(), this.flattenMode ); Model flattenedPom = new Model(); String modelEncoding = effectivePom.getModelEncoding(); if ( StringUtils.isEmpty( modelEncoding ) ) { modelEncoding = "UTF-8"; } flattenedPom.setModelEncoding( modelEncoding ); Model cleanPom = null; try { cleanPom = createCleanPom( effectivePom ); } catch (Exception e) { throw new MojoExecutionException("failed to create a clean pom", e); } FlattenDescriptor descriptor = getFlattenDescriptor(); Model originalPom = this.project.getOriginalModel(); Model resolvedPom = this.project.getModel(); Model interpolatedPom = createResolvedPom( buildingRequest ); 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; }