Program: 126264
Project: 126264
Buggy source:
/** 
 * Clean the pom_xxx.xml and assembly_xxx.xml and target folder, also clean the module and dependencies.
 */
public void cleanMavenFiles(IProgressMonitor monitor) throws Exception {
  final String routinesPomFileName=PomUtil.getPomFileName(TalendMavenContants.DEFAULT_ROUTINES_ARTIFACT_ID);
  File[] pomFiles=codeProject.getProject().getLocation().toFile().listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.startsWith(MavenConstants.POM_NAME + '_') && name.endsWith(MavenConstants.XML_EXT) && !name.equals(routinesPomFileName);
    }
  }
);
  deleteFiles(pomFiles);
  IFolder assembliesFolder=codeProject.getAssembliesFolder();
  if (assembliesFolder != null && assembliesFolder.exists()) {
    File[] assembliesFiles=assembliesFolder.getLocation().toFile().listFiles(new FilenameFilter(){
      @Override public boolean accept(      File dir,      String name){
        return name.startsWith(MavenConstants.ASSEMBLY_NAME + '_') && name.endsWith(MavenConstants.XML_EXT);
      }
    }
);
    deleteFiles(assembliesFiles);
  }
  FilesUtils.deleteFile(codeProject.getOutputFolder().getParent().getLocation().toFile(),true);
  IFile projectPomFile=codeProject.getProjectPom();
  File pPomFile=projectPomFile.getLocation().toFile();
  if (pPomFile.exists()) {
    MavenModelManager mavenModelManager=MavenPlugin.getMavenModelManager();
    Model projModel=mavenModelManager.readMavenModel(projectPomFile);
    List<String> modules=projModel.getModules();
    if (modules != null) {
      modules.clear();
    }
    final Model routinesModel=PomUtil.getRoutinesTempalteModel();
    modules.add(PomUtil.getPomFileName(routinesModel.getArtifactId()));
    CreateMavenRoutinePom.addDependencies(projModel);
    PomUtil.savePom(monitor,projModel,projectPomFile);
  }
}

Fixed version (ground truth):
/** 
 * Clean the pom_xxx.xml and assembly_xxx.xml and target folder, also clean the module and dependencies.
 */
public void cleanMavenFiles(IProgressMonitor monitor) throws Exception {
  final String routinesPomFileName=PomUtil.getPomFileName(TalendMavenContants.DEFAULT_ROUTINES_ARTIFACT_ID);
  File[] pomFiles=codeProject.getProject().getLocation().toFile().listFiles(new FilenameFilter(){
    @Override public boolean accept(    File dir,    String name){
      return name.startsWith(MavenConstants.POM_NAME + '_') && name.endsWith(MavenConstants.XML_EXT) && !name.equals(routinesPomFileName);
    }
  }
);
  deleteFiles(pomFiles);
  IFolder assembliesFolder=codeProject.getAssembliesFolder();
  if (assembliesFolder != null && assembliesFolder.exists()) {
    File[] assembliesFiles=assembliesFolder.getLocation().toFile().listFiles(new FilenameFilter(){
      @Override public boolean accept(      File dir,      String name){
        return name.startsWith(MavenConstants.ASSEMBLY_NAME + '_') && name.endsWith(MavenConstants.XML_EXT);
      }
    }
);
    deleteFiles(assembliesFiles);
  }
  FilesUtils.deleteFile(codeProject.getOutputFolder().getParent().getLocation().toFile(),true);
  IFile projectPomFile=codeProject.getProjectPom();
  File pPomFile=projectPomFile.getLocation().toFile();
  if (pPomFile.exists()) {
    MavenModelManager mavenModelManager=MavenPlugin.getMavenModelManager();
    Model projModel=mavenModelManager.readMavenModel(projectPomFile);
    List<String> modules=projModel.getModules();
    if (modules != null) {
      modules.clear();
    }
    final Model routinesModel=PomUtil.getRoutinesTempalteModel();
    modules.add(PomUtil.getPomFileName(routinesModel.getArtifactId()));
    CreateMavenRoutinePom.addDependencies(projModel);
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
      ILibraryManagerService libManagerService=(ILibraryManagerService)GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
      List<String> jarsNeedRetrieve=new ArrayList<String>();
      for (      Dependency d : projModel.getDependencies()) {
        if (d.getScope() != null && d.getScope().equals("String_Node_Str")) {
          jarsNeedRetrieve.add(d.getArtifactId() + FileExtensions.JAR_FILE_SUFFIX);
        }
      }
      libManagerService.retrieve(jarsNeedRetrieve,codeProject.getLibFolder().getLocation().toPortableString(),false);
    }
    PomUtil.savePom(monitor,projModel,projectPomFile);
  }
  codeProject.buildModules(MavenConstants.GOAL_COMPILE,null);
}