private void updateProperties() { if (this.properties == null) { this.properties = new Properties(); } // we want to use a dedicated Maven repository this.properties.setProperty("maven.repo.local", this.inspector.getM2LocalPath()); for (String skip : SKIP_LIST) { this.properties.setProperty(skip, "true"); } if (this.skipCheckstyle) { this.properties.setProperty("checkstyle.skip", "true"); } }
private File[] findModules(String pomPath, boolean rootCall) { List<File> modules = new ArrayList<>(); File pomFile = new File(pomPath); Model model = MavenHelper.readPomXml(pomFile, this.getInspector().getM2LocalPath()); if (model == null) { this.addStepError("Error while building model: no model has been retrieved."); return null; } if (model.getModules() == null) { this.addStepError("Error while obtaining modules from pom.xml: module section has not been found."); return null; } for (String moduleName : model.getModules()) { File module = new File(pomFile.getParent() + File.separator + moduleName); modules.add(module); File[] moreModules = this.findModules(module.getPath() + File.separator + Utils.POM_FILE, false); if (moreModules != null && moreModules.length > 0) { modules.addAll(Arrays.asList(moreModules)); } } if (rootCall && modules.size() == 0) { modules.add(pomFile.getParentFile()); } return modules.toArray(new File[modules.size()]); }
protected void cleanMavenArtifactsAndLocalRepo() { if (this.inspector.getM2LocalPath() != null) { try { FileUtils.deleteDirectory(this.inspector.getM2LocalPath()); } catch (IOException e) { getLogger().warn( "Error while deleting the M2 local directory (" + this.inspector.getM2LocalPath() + "): " + e); } } File repoDir = new File(this.inspector.getRepoLocalPath(), Utils.REMOTE_REPO_EXT); if (repoDir.exists() && this.getConfig().isClean()) { try { FileUtils.deleteDirectory(this.inspector.getRepoLocalPath()); } catch (IOException e) { getLogger().warn("Error while deleting the workspace directory (" + this.inspector.getRepoLocalPath() + "): " + e); } } }
model = MavenHelper.readPomXml(pomOfCurrentDirPath, this.getInspector().getM2LocalPath()); if (model == null) { this.addStepError("Error while building pom.xml model: no model has been retrieved.");
private List<Plugin> findPlugins(String pomPath) { List<File> plugins = new ArrayList<>(); File pomFile = new File(pomPath); Model model = MavenHelper.readPomXml(pomFile, this.getInspector().getM2LocalPath()); if (model == null) { this.addStepError("Error while building model: no model has been retrieved."); return null; } if (model.getBuild() == null) { this.addStepError("Error while obtaining build from pom.xml: build section has not been found."); return null; } if (model.getBuild().getPlugins() == null) { this.addStepError("Error while obtaining plugins from pom.xml: plugin section has not been found."); return null; } return model.getBuild().getPlugins(); }