use of org.kie.workbench.common.project.migration.cli.maven.PomMigrationEditor in project kie-wb-common by kiegroup.
the class PomMigrationTool method processWorkspaceProject.
private void processWorkspaceProject(WorkspaceProject workspaceProject, String jsonPath, MigrationServicesCDIWrapper cdiWrapper) {
if (systemMigrationWasExecuted(cdiWrapper)) {
PomMigrationEditor editor = new PomMigrationEditor();
final int[] counter = { 0 };
Files.walkFileTree(Paths.convert(workspaceProject.getRootPath()), new SimpleFileVisitor<org.uberfire.java.nio.file.Path>() {
@Override
public FileVisitResult visitFile(org.uberfire.java.nio.file.Path visitedPath, BasicFileAttributes attrs) throws IOException {
org.uberfire.backend.vfs.Path visitedVFSPath = Paths.convert(visitedPath);
String fileName = visitedVFSPath.getFileName();
File file = visitedPath.toFile();
if (file.isFile() && fileName.equals(POM_DOT_XML)) {
try {
Model model;
if (jsonPath.isEmpty()) {
model = editor.updatePom(visitedPath, cdiWrapper);
} else {
model = editor.updatePom(visitedPath, jsonPath, cdiWrapper);
}
if (!model.getBuild().getPlugins().isEmpty()) {
counter[0]++;
}
} catch (Exception e) {
system.err().println("Error reading from filename [" + fileName + "] (error below).");
e.printStackTrace(system.err());
}
}
return FileVisitResult.CONTINUE;
}
});
system.out().println("Migrated " + counter[0] + " POMs for project: " + workspaceProject.getName());
}
}
Aggregations