List of usage examples for org.apache.maven.project MavenProject equals
@Override public boolean equals(Object other)
From source file:org.jszip.maven.RunMojo.java
License:Apache License
private boolean buildPlanEqual(List<MavenProject> newPlan, List<MavenProject> oldPlan) { if (newPlan.size() != oldPlan.size()) { return false; }//from ww w . j a v a2 s . c om int seq = 0; for (Iterator<MavenProject> i = newPlan.iterator(), j = oldPlan.iterator(); i.hasNext() && j.hasNext();) { MavenProject left = i.next(); MavenProject right = j.next(); getLog().debug("[" + (seq++) + "] = " + left.equals(right) + (left == right ? " same" : " diff") + " : " + left.getName() + "[" + left.getDependencies().size() + "], " + right.getName() + "[" + right.getDependencies().size() + "]"); if (!left.equals(right)) { return false; } if (left.getDependencies().size() != right.getDependencies().size()) { getLog().info("Dependency tree of " + left.getId() + " has been modified"); } } return true; }
From source file:org.kie.workbench.common.services.backend.compiler.external339.AFMavenCli.java
License:Apache License
protected int execute(AFCliRequest cliRequest) throws MavenExecutionRequestPopulationException { MavenExecutionRequest request = executionRequestPopulator.populateDefaults(cliRequest.getRequest()); eventSpyDispatcher.onEvent(request); MavenExecutionResult result = maven.execute(request); eventSpyDispatcher.onEvent(result);/*from ww w. j ava 2 s .co m*/ eventSpyDispatcher.close(); if (result.hasExceptions()) { ExceptionHandler handler = new DefaultExceptionHandler(); Map<String, String> references = new LinkedHashMap<String, String>(); MavenProject project = null; for (Throwable exception : result.getExceptions()) { ExceptionSummary summary = handler.handleException(exception); logSummary(summary, references, "", cliRequest.isShowErrors()); if (project == null && exception instanceof LifecycleExecutionException) { project = ((LifecycleExecutionException) exception).getProject(); } } slf4jLogger.error(""); if (!cliRequest.isShowErrors()) { slf4jLogger.error("To see the full stack trace of the errors, re-run Maven with the -e switch."); } if (!slf4jLogger.isDebugEnabled()) { slf4jLogger.error("Re-run Maven using the -X switch to enable full debug logging."); } if (!references.isEmpty()) { slf4jLogger.error(""); slf4jLogger.error("For more information about the errors and possible solutions" + ", please read the following articles:"); for (Map.Entry<String, String> entry : references.entrySet()) { slf4jLogger.error(entry.getValue() + " " + entry.getKey()); } } if (project != null && !project.equals(result.getTopologicallySortedProjects().get(0))) { slf4jLogger.error(""); slf4jLogger.error("After correcting the problems, you can resume the build with the command"); slf4jLogger.error(" mvn <goals> -rf :" + project.getArtifactId()); } if (MavenExecutionRequest.REACTOR_FAIL_NEVER .equals(cliRequest.getRequest().getReactorFailureBehavior())) { slf4jLogger.info("Build failures were ignored."); return 0; } else { return 1; } } else { return 0; } }
From source file:org.kie.workbench.common.services.backend.compiler.impl.external339.AFMavenCli.java
License:Apache License
protected int execute(AFCliRequest cliRequest) throws MavenExecutionRequestPopulationException { MavenExecutionRequest request = executionRequestPopulator.populateDefaults(cliRequest.getRequest()); eventSpyDispatcher.onEvent(request); MavenExecutionResult result = maven.execute(request); eventSpyDispatcher.onEvent(result);// www .ja v a2s .c om eventSpyDispatcher.close(); if (result.hasExceptions()) { ExceptionHandler handler = new DefaultExceptionHandler(); Map<String, String> references = new LinkedHashMap<String, String>(); MavenProject project = null; for (Throwable exception : result.getExceptions()) { ExceptionSummary summary = handler.handleException(exception); logSummary(summary, references, "", cliRequest.isShowErrors()); if (project == null && exception instanceof LifecycleExecutionException) { project = ((LifecycleExecutionException) exception).getProject(); } } slf4jLogger.error(""); if (!cliRequest.isShowErrors()) { slf4jLogger.error("To see the full stack trace of the errors, re-run Maven with the -e switch."); } if (!slf4jLogger.isDebugEnabled()) { slf4jLogger.error("Re-run Maven using the -X switch to enable full debug logging."); } if (!references.isEmpty()) { slf4jLogger.error(""); slf4jLogger.error("For more information about the errors and possible solutions" + ", please read the following articles:"); for (Entry<String, String> entry : references.entrySet()) { slf4jLogger.error(entry.getValue() + " " + entry.getKey()); } } if (project != null && !project.equals(result.getTopologicallySortedProjects().get(0))) { slf4jLogger.error(""); slf4jLogger.error("After correcting the problems, you can resume the build with the command"); slf4jLogger.error(" mvn <goals> -rf :" + project.getArtifactId()); } if (MavenExecutionRequest.REACTOR_FAIL_NEVER .equals(cliRequest.getRequest().getReactorFailureBehavior())) { slf4jLogger.info("Build failures were ignored."); return 0; } else { return 1; } } else { return 0; } }
From source file:org.kie.workbench.common.services.backend.compiler.impl.external339.ReusableAFMavenCli.java
License:Apache License
protected int execute(AFCliRequest cliRequest) throws MavenExecutionRequestPopulationException { MavenExecutionRequest request = reusableExecutionRequestPopulator.populateDefaults(cliRequest.getRequest()); reusableEventSpyDispatcher.onEvent(request); MavenExecutionResult result = reusableMaven.execute(request); reusableEventSpyDispatcher.onEvent(result); reusableEventSpyDispatcher.close();/*from ww w .j av a 2 s . c om*/ if (result.hasExceptions()) { ExceptionHandler handler = new DefaultExceptionHandler(); Map<String, String> references = new LinkedHashMap<String, String>(); MavenProject project = null; for (Throwable exception : result.getExceptions()) { ExceptionSummary summary = handler.handleException(exception); logSummary(summary, references, "", cliRequest.isShowErrors()); if (project == null && exception instanceof LifecycleExecutionException) { project = ((LifecycleExecutionException) exception).getProject(); } } reusableSlf4jLogger.error(""); if (!cliRequest.isShowErrors()) { reusableSlf4jLogger .error("To see the full stack trace of the errors, re-run Maven with the -e switch."); } if (!reusableSlf4jLogger.isDebugEnabled()) { reusableSlf4jLogger.error("Re-run Maven using the -X switch to enable full debug logging."); } if (!references.isEmpty()) { reusableSlf4jLogger.error(""); reusableSlf4jLogger.error("For more information about the errors and possible solutions" + ", please read the following articles:"); for (Entry<String, String> entry : references.entrySet()) { reusableSlf4jLogger.error(entry.getValue() + " " + entry.getKey()); } } if (project != null && !project.equals(result.getTopologicallySortedProjects().get(0))) { reusableSlf4jLogger.error(""); reusableSlf4jLogger .error("After correcting the problems, you can resume the build with the command"); reusableSlf4jLogger.error(" mvn <goals> -rf :" + project.getArtifactId()); } if (MavenExecutionRequest.REACTOR_FAIL_NEVER .equals(cliRequest.getRequest().getReactorFailureBehavior())) { reusableSlf4jLogger.info("Build failures were ignored."); return 0; } else { return 1; } } else { return 0; } }
From source file:org.owasp.dependencycheck.maven.AggregateMojo.java
License:Apache License
/** * Returns a set containing all the descendant projects of the given * project./*from w w w . j a v a2s . c o m*/ * * @param project the project for which all descendants will be returned * @return the set of descendant projects */ protected Set<MavenProject> getDescendants(MavenProject project) { if (project == null) { return Collections.emptySet(); } final Set<MavenProject> descendants = new HashSet<>(); int size; if (getLog().isDebugEnabled()) { getLog().debug(String.format("Collecting descendants of %s", project.getName())); } for (String m : project.getModules()) { for (MavenProject mod : getReactorProjects()) { try { File mpp = new File(project.getBasedir(), m); mpp = mpp.getCanonicalFile(); if (mpp.compareTo(mod.getBasedir()) == 0 && descendants.add(mod) && getLog().isDebugEnabled()) { getLog().debug(String.format("Descendant module %s added", mod.getName())); } } catch (IOException ex) { if (getLog().isDebugEnabled()) { getLog().debug("Unable to determine module path", ex); } } } } do { size = descendants.size(); for (MavenProject p : getReactorProjects()) { if (project.equals(p.getParent()) || descendants.contains(p.getParent())) { if (descendants.add(p) && getLog().isDebugEnabled()) { getLog().debug(String.format("Descendant %s added", p.getName())); } for (MavenProject modTest : getReactorProjects()) { if (p.getModules() != null && p.getModules().contains(modTest.getName()) && descendants.add(modTest) && getLog().isDebugEnabled()) { getLog().debug(String.format("Descendant %s added", modTest.getName())); } } } final Set<MavenProject> addedDescendants = new HashSet<>(); for (MavenProject dec : descendants) { for (String mod : dec.getModules()) { try { File mpp = new File(dec.getBasedir(), mod); mpp = mpp.getCanonicalFile(); if (mpp.compareTo(p.getBasedir()) == 0) { addedDescendants.add(p); } } catch (IOException ex) { if (getLog().isDebugEnabled()) { getLog().debug("Unable to determine module path", ex); } } } } for (MavenProject addedDescendant : addedDescendants) { if (descendants.add(addedDescendant) && getLog().isDebugEnabled()) { getLog().debug(String.format("Descendant module %s added", addedDescendant.getName())); } } } } while (size != 0 && size != descendants.size()); if (getLog().isDebugEnabled()) { getLog().debug(String.format("%s has %d children", project, descendants.size())); } return descendants; }
From source file:org.topdesk.maven.tracker.MavenCli.java
License:Apache License
private int execute(CliRequest cliRequest) { MavenExecutionResult result = maven.execute(cliRequest.request); if (result.hasExceptions()) { ExceptionHandler handler = new DefaultExceptionHandler(); Map<String, String> references = new LinkedHashMap<String, String>(); MavenProject project = null; for (Throwable exception : result.getExceptions()) { ExceptionSummary summary = handler.handleException(exception); logSummary(summary, references, "", cliRequest.showErrors); if (project == null && exception instanceof LifecycleExecutionException) { project = ((LifecycleExecutionException) exception).getProject(); }//from w w w . ja v a2s. c o m } logger.error(""); if (!cliRequest.showErrors) { logger.error("To see the full stack trace of the errors, re-run Maven with the -e switch."); } if (!logger.isDebugEnabled()) { logger.error("Re-run Maven using the -X switch to enable full debug logging."); } if (!references.isEmpty()) { logger.error(""); logger.error("For more information about the errors and possible solutions" + ", please read the following articles:"); for (Map.Entry<String, String> entry : references.entrySet()) { logger.error(entry.getValue() + " " + entry.getKey()); } } if (project != null && !project.equals(result.getTopologicallySortedProjects().get(0))) { logger.error(""); logger.error("After correcting the problems, you can resume the build with the command"); logger.error(" mvn <goals> -rf :" + project.getArtifactId()); } if (MavenExecutionRequest.REACTOR_FAIL_NEVER.equals(cliRequest.request.getReactorFailureBehavior())) { logger.info("Build failures were ignored."); return 0; } else { return 1; } } else { return 0; } }
From source file:org.universAAL.support.directives.mojos.CheckReportMojo.java
License:Apache License
/** * @param sink/*from w w w . j ava 2s . c om*/ * @param loc */ private void renderModulesTable(Sink sink, Locale loc) { for (MavenProject mp : reactorProjects) { for (int i = 0; i < checks.length; i++) { if (!mp.equals(project)) { boolean passed; AbstractMojoExecutionException ex = null; try { passed = checks[i].check(mp, getLog()); } catch (MojoExecutionException e) { passed = false; ex = e; } catch (MojoFailureException e) { passed = false; ex = e; } catch (Exception e) { passed = false; ex = new MojoExecutionException("Unexpected Exception", e); } // IF passed, do nothing if failed write row. if (!passed) { sink.tableRow(); sink.tableCell(); // sink.text(mp.getGroupId() + ":" + mp.getArtifactId()); sink.text(mp.getArtifactId()); sink.tableCell_(); writeRow(checks[i], passed, ex, sink, loc); sink.tableRow_(); FailedModules.add(mp); } } } } }
From source file:org.whitesource.bamboo.agent.MavenOssInfoExtractor.java
License:Apache License
private AgentProjectInfo processProject(MavenProject project) { long startTime = System.currentTimeMillis(); log.info(WssUtils.logMsg(LOG_COMPONENT, "processing Maven project " + project.getId())); AgentProjectInfo projectInfo = new AgentProjectInfo(); // project token if (project.equals(mavenParser.getMavenProject())) { projectInfo.setProjectToken(projectToken); } else {//from ww w .j ava 2s. c o m projectInfo.setProjectToken(moduleTokens.get(project.getArtifactId())); } // project coordinates projectInfo.setCoordinates(extractCoordinates(project)); Parent parent = project.getModel().getParent(); // parent coordinates if (parent != null) { projectInfo.setParentCoordinates(extractParentCoordinates(parent)); } // dependencies Map<Dependency, Artifact> lut = createLookupTable(project); for (Dependency dependency : mavenParser.getDependencies(project)) { DependencyInfo dependencyInfo = getDependencyInfo(dependency); Artifact artifact = lut.get(dependency); if (artifact != null) { File artifactFile = artifact.getFile(); if (artifactFile != null && artifactFile.exists()) { try { dependencyInfo.setSha1(ChecksumUtils.calculateSHA1(artifactFile)); } catch (IOException e) { log.warn(WssUtils.logMsg(LOG_COMPONENT, ERROR_SHA1 + " for " + artifact.getId())); } } } projectInfo.getDependencies().add(dependencyInfo); } log.info(WssUtils.logMsg(LOG_COMPONENT, "Total Maven project processing time is " + (System.currentTimeMillis() - startTime) + " [msec]")); return projectInfo; }
From source file:org_scala_tools_maven.ScalaDocMojo.java
License:Apache License
@SuppressWarnings("unchecked") protected void tryAggregateUpper(MavenProject prj) throws Exception { if (prj != null && prj.hasParent() && canAggregate()) { MavenProject parent = prj.getParent(); List<MavenProject> modules = parent.getCollectedProjects(); if ((modules.size() > 1) && prj.equals(modules.get(modules.size() - 1))) { aggregate(parent);/*from ww w. ja va 2 s. c om*/ } } }