List of usage examples for org.apache.maven.project MavenProject getArtifactId
public String getArtifactId()
From source file:org.jacoco.maven.ReportAggregateMojo.java
License:Open Source License
private MavenProject findProjectFromReactor(final Dependency d) { for (final MavenProject p : reactorProjects) { if (p.getGroupId().equals(d.getGroupId()) && p.getArtifactId().equals(d.getArtifactId()) && p.getVersion().equals(d.getVersion())) { return p; }/*from w ww . j a v a 2s .com*/ } return null; }
From source file:org.jacoco.maven.ReportSupport.java
License:Open Source License
/** * Calculates coverage for the given project and emits it to the report * group without source references//from w w w . j av a 2 s. co m * * @param visitor * group visitor to emit the project's coverage to * @param project * the MavenProject * @param includes * list of includes patterns * @param excludes * list of excludes patterns * @throws IOException * if class files can't be read */ public void processProject(final IReportGroupVisitor visitor, final MavenProject project, final List<String> includes, final List<String> excludes) throws IOException { processProject(visitor, project.getArtifactId(), project, includes, excludes, new NoSourceLocator()); }
From source file:org.jahia.utils.maven.plugin.modules.JahiaVersionMojo.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { MavenProject p = project.getParent(); while (p != null && !StringUtils.equals(p.getArtifactId(), "jahia-modules")) { p = p.getParent();//ww w.java2 s.c om } if (p != null) { project.getProperties().put("jahia.version", p.getVersion()); if (!project.getProperties().containsKey("jahia-download-sources-available")) { project.getProperties().put("jahia-download-sources-available", isProjectProtected() ? "false" : "true"); } } else { for (Dependency dep : project.getDependencies()) { if (StringUtils.equals(dep.getArtifactId(), "jahia-impl")) { project.getProperties().put("jahia.version", dep.getVersion()); return; } } } }
From source file:org.jahia.utils.maven.plugin.osgi.ConvertToOSGiMojo.java
License:Open Source License
private boolean checkProjectParent(MavenProject p, String groupId, String artifactId) { MavenProject parent = p.getParent(); if (parent == null) { return false; }/* w w w . j a va 2s. c om*/ if (groupId.equals(parent.getGroupId()) && artifactId.equals(parent.getArtifactId())) { return true; } else { return checkProjectParent(parent, groupId, artifactId); } }
From source file:org.jasig.maven.notice.AbstractNoticeMojo.java
License:Apache License
/** * Loads the dependency tree for the project via {@link #loadDependencyTree(MavenProject)} and then uses * the {@link DependencyNodeVisitor} to load the license data. If {@link #aggregating} is enabled the method * recurses on each child module./*from w w w . j ava 2 s. c o m*/ */ @SuppressWarnings("unchecked") protected void parseProject(MavenProject project, DependencyNodeVisitor visitor) throws MojoExecutionException, MojoFailureException { final Log logger = this.getLog(); logger.info("Parsing Dependencies for: " + project.getName()); //Load and parse immediate dependencies final DependencyNode tree = this.loadDependencyTree(project); tree.accept(visitor); //If not including child deps don't recurse on modules if (!this.includeChildDependencies) { return; } //No child modules, return final List<MavenProject> collectedProjects = project.getCollectedProjects(); if (collectedProjects == null) { return; } //Find all sub-modules for the project for (final MavenProject moduleProject : collectedProjects) { if (this.isExcluded(moduleProject, project.getArtifactId())) { continue; } this.parseProject(moduleProject, visitor); } }
From source file:org.jasig.maven.notice.AbstractNoticeMojo.java
License:Apache License
/** * Check if a project is excluded based on its artifactId or a parent's artifactId *//*from w w w . j a va2 s .c o m*/ protected boolean isExcluded(MavenProject mavenProject, String rootArtifactId) { final Log logger = this.getLog(); final String artifactId = mavenProject.getArtifactId(); if (this.excludedModules.contains(artifactId)) { logger.info("Skipping aggregation of child module " + mavenProject.getName() + " with excluded artifactId: " + artifactId); return true; } MavenProject parentProject = mavenProject.getParent(); while (parentProject != null && !rootArtifactId.equals(parentProject.getArtifactId())) { final String parentArtifactId = parentProject.getArtifactId(); if (this.excludedModules.contains(parentArtifactId)) { logger.info("Skipping aggregation of child module " + mavenProject.getName() + " with excluded parent artifactId: " + parentArtifactId); return true; } parentProject = parentProject.getParent(); } return false; }
From source file:org.javagems.core.maven.DebianMojo.java
License:Apache License
/** * Copy properties from the maven project to the ant project. * * @param mavenProject/*from ww w . j a v a 2 s . c o m*/ * @param antProject */ public void copyProperties(MavenProject mavenProject, Project antProject) { Properties mavenProps = mavenProject.getProperties(); Iterator iter = mavenProps.keySet().iterator(); while (iter.hasNext()) { String key = (String) iter.next(); antProject.setProperty(key, mavenProps.getProperty(key)); } // Set the POM file as the ant.file for the tasks run directly in Maven. antProject.setProperty("ant.file", mavenProject.getFile().getAbsolutePath()); // Add some of the common maven properties getLog().debug("Setting properties with prefix: " + propertyPrefix); antProject.setProperty((propertyPrefix + "project.groupId"), mavenProject.getGroupId()); antProject.setProperty((propertyPrefix + "project.artifactId"), mavenProject.getArtifactId()); antProject.setProperty((propertyPrefix + "project.name"), mavenProject.getName()); if (mavenProject.getDescription() != null) { antProject.setProperty((propertyPrefix + "project.description"), mavenProject.getDescription()); } antProject.setProperty((propertyPrefix + "project.version"), mavenProject.getVersion()); antProject.setProperty((propertyPrefix + "project.packaging"), mavenProject.getPackaging()); antProject.setProperty((propertyPrefix + "project.build.directory"), mavenProject.getBuild().getDirectory()); antProject.setProperty((propertyPrefix + "project.build.outputDirectory"), mavenProject.getBuild().getOutputDirectory()); antProject.setProperty((propertyPrefix + "project.build.testOutputDirectory"), mavenProject.getBuild().getTestOutputDirectory()); antProject.setProperty((propertyPrefix + "project.build.sourceDirectory"), mavenProject.getBuild().getSourceDirectory()); antProject.setProperty((propertyPrefix + "project.build.testSourceDirectory"), mavenProject.getBuild().getTestSourceDirectory()); antProject.setProperty((propertyPrefix + "localRepository"), localRepository.toString()); antProject.setProperty((propertyPrefix + "settings.localRepository"), localRepository.getBasedir()); // Add properties for depenedency artifacts Set depArtifacts = mavenProject.getArtifacts(); for (Iterator it = depArtifacts.iterator(); it.hasNext();) { Artifact artifact = (Artifact) it.next(); String propName = artifact.getDependencyConflictId(); antProject.setProperty(propertyPrefix + propName, artifact.getFile().getPath()); } // Add a property containing the list of versions for the mapper StringBuffer versionsBuffer = new StringBuffer(); for (Iterator it = depArtifacts.iterator(); it.hasNext();) { Artifact artifact = (Artifact) it.next(); versionsBuffer.append(artifact.getVersion() + File.pathSeparator); } antProject.setProperty(versionsPropertyName, versionsBuffer.toString()); }
From source file:org.jboss.maven.extension.dependency.DependencyManagementLifecycleParticipant.java
License:Apache License
@Override public void afterProjectsRead(MavenSession session) throws MavenExecutionException { // The dependency management overrider needs to know which projects // are in the reactor, and therefore should not be overridden. StringBuilder reactorProjects = new StringBuilder(); for (MavenProject project : session.getProjects()) { reactorProjects.append(project.getGroupId() + ":" + project.getArtifactId() + ","); }// w ww .ja v a 2 s .c o m System.setProperty("reactorProjectGAs", reactorProjects.toString()); // Apply model modifiers to the projects' models for (MavenProject project : session.getProjects()) { logger.debug("Checking project '" + project.getId() + "'"); int modelChangeCount = 0; Model currModel = project.getModel(); // Run the modifiers against the built model for (ModelModifier currModifier : afterProjectsReadModifierList) { boolean modelChanged = currModifier.updateModel(currModel); if (modelChanged) { modelChangeCount++; } } // If something changed, then it will be useful to output extra info if (sessionChangeCount >= 1 || modelChangeCount >= 1) { logger.debug("Session/Model changed at least once, writing informational files"); try { MetaInfWriter.writeResource(currModel, new EffectivePomGenerator()); } catch (IOException e) { logger.error( "Could not write the effective POM of model '" + currModel.getId() + "' due to " + e); } } } }
From source file:org.jboss.maven.plugins.qstools.BomUpdaterMojo.java
License:Apache License
/** * @param project//w ww. ja v a 2 s .c om * @throws Exception */ private void processProject(MavenProject project) throws Exception { pomModified = false; Rules rules = configurationProvider.getQuickstartsRules(project.getGroupId()); getLog().debug("Processing " + project.getArtifactId()); Document doc = PositionalXMLReader.readXML(new FileInputStream(project.getFile())); NodeList dependencies = (NodeList) xPath.evaluate("/project/dependencyManagement/dependencies/dependency", doc, XPathConstants.NODESET); replaceBOMsIfNeeded(project, dependencies, rules); updateBomsVersionIfNeeded(project, dependencies, rules, doc); if (pomModified) { getLog().info("*** Saving changes to " + project.getFile() + "\n"); updatedProjects++; XMLUtil.writeXML(doc, project.getFile()); } }
From source file:org.jboss.maven.plugins.qstools.checkers.AbstractProjectChecker.java
License:Apache License
@Override @SuppressWarnings("unchecked") public Map<String, List<Violation>> check(MavenProject project, MavenSession mavenSession, List<MavenProject> reactorProjects, Log log) throws QSCheckerException { this.mavenSession = mavenSession; this.log = log; Map<String, List<Violation>> results = new TreeMap<String, List<Violation>>(); try {/*from w ww . j av a2 s . co m*/ List<String> ignoredQuickstarts = (List<String>) context.get(Constants.IGNORED_QUICKSTARTS_CONTEXT); for (MavenProject mavenProject : reactorProjects) { if (!ignoredQuickstarts.contains(mavenProject.getBasedir().getName())) { Document doc = PositionalXMLReader.readXML(new FileInputStream(mavenProject.getFile())); if (configurationProvider.getQuickstartsRules(project.getGroupId()).isCheckerIgnored(this)) { String msg = "Skiping %s for %s:%s"; log.warn(String.format(msg, this.getClass().getSimpleName(), project.getGroupId(), project.getArtifactId())); } else { processProject(mavenProject, doc, results); } } else { log.debug("Ignoring " + mavenProject.getBasedir().getName() + ". It is listed on .quickstarts_ignore file"); } } if (violationsQtd > 0) { log.info("There are " + violationsQtd + " checkers errors"); } } catch (Exception e) { // Any other exception is a problem. throw new QSCheckerException(e); } return results; }