List of usage examples for org.apache.maven.project MavenProject hasParent
public boolean hasParent()
From source file:com.github.maven_nar.NarUtil.java
License:Apache License
/** * (Darren) this code lifted from mvn help:active-profiles plugin Recurses * into the project's parent poms to find the active profiles of the * specified project and all its parents. * //ww w.ja va 2 s.c o m * @param project * The project to start with * @return A list of active profiles */ static List collectActiveProfiles(final MavenProject project) { final List profiles = project.getActiveProfiles(); if (project.hasParent()) { profiles.addAll(collectActiveProfiles(project.getParent())); } return profiles; }
From source file:org.geotools.maven.JarCollector.java
License:Open Source License
/** * Copies the {@code .jar} files to the collect directory. * * @throws MojoExecutionException if the plugin execution failed. *///from ww w .j a va 2s. c om public void execute() throws MojoExecutionException { /* * Gets the parent "target" directory. */ MavenProject parent = project; while (parent.hasParent()) { parent = parent.getParent(); } collectDirectory = parent.getBuild().getDirectory(); /* * Now collects the JARs. */ try { collect(); } catch (IOException e) { throw new MojoExecutionException("Error collecting the JAR file.", e); } }
From source file:org.kloeckner.maven.plugin.util.VersionRangeUtils.java
License:Apache License
public static String rewriteParent(MavenProject project, Element rootElement, Namespace namespace, Map<String, String> mappedVersions, Map<String, String> originalVersions) throws MojoExecutionException { String parentVersion = null;//ww w. j a va 2s.c o m if (project.hasParent()) { Element parentElement = rootElement.getChild("parent", namespace); Element versionElement = parentElement.getChild("version", namespace); MavenProject parent = project.getParent(); String key = ArtifactUtils.versionlessKey(parent.getGroupId(), parent.getArtifactId()); parentVersion = mappedVersions.get(key); // if (parentVersion == null) { // //MRELEASE-317 // parentVersion = getResolvedSnapshotVersion(key, resolvedSnapshotDependencies); // } if (parentVersion == null) { if (parent.getVersion().equals(originalVersions.get(key))) { throw new MojoExecutionException( "Version for parent '" + parent.getName() + "' was not mapped"); } } else { rewriteValue(versionElement, parentVersion); } } return parentVersion; }
From source file:org.m1theo.apt.repo.utils.Utils.java
License:Open Source License
/** * Collects all artifacts of the given type. * //ww w. ja v a2 s . c o m * @param project The maven project which should be used. * @param type The file type which should be collected. * @return A collection of all artifacts with the given type. */ @SuppressWarnings("unchecked") public static Collection<Artifact> getAllArtifacts4Type(MavenProject project, String type, Boolean aggregate) { final Set<Artifact> artifacts = new LinkedHashSet<Artifact>(); List<MavenProject> modules = new ArrayList<MavenProject>(); modules.add(project); List<MavenProject> collectedProjects = project.getCollectedProjects(); if (collectedProjects != null) { modules.addAll(collectedProjects); } for (MavenProject module : modules) { addDebArtifact(module.getArtifact(), artifacts, type); for (Object artifact : module.getArtifacts()) { if (artifact instanceof Artifact) { addDebArtifact((Artifact) artifact, artifacts, type); } } for (Object artifact : module.getAttachedArtifacts()) { if (artifact instanceof Artifact) { addDebArtifact((Artifact) artifact, artifacts, type); } } } if (project.hasParent() && aggregate) { artifacts.addAll(getAllArtifacts4Type(project.getParent(), type, aggregate)); } return artifacts; }
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 w w w .ja v a 2 s . c om } } }
From source file:se.jiderhamn.promote.maven.plugin.PromoteArtifactsMojo.java
License:Apache License
/** Read release descriptor to find the release version of the given artifact */ private String getReleasedVersion(MavenProject project, Artifact artifact) throws MojoExecutionException { if (project == null || project.getBasedir() == null) throw new MojoExecutionException("Basedir must be provided for project " + project); final String key = ArtifactUtils.versionlessKey(artifact); try {/* ww w . j a v a 2 s . c o m*/ PropertiesReleaseDescriptorStore descriptorStore = new PropertiesReleaseDescriptorStore(); ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor(); releaseDescriptor.setWorkingDirectory(project.getBasedir().getAbsolutePath()); releaseDescriptor = descriptorStore.read(releaseDescriptor); // "groupId:artifactId" -> version final Map<String, String> releaseVersions = releaseDescriptor.getReleaseVersions(); getLog().debug("Read versions from " + project.getBasedir() + ": " + releaseVersions); if (releaseVersions.containsKey(key)) return releaseVersions.get(key); } catch (ReleaseDescriptorStoreException e) { throw new MojoExecutionException("Error parsing release descriptor", e); } catch (NullPointerException e) { // No release.properties found getLog().debug("Error finding release descriptor", e); } if (project.hasParent() && project.getParent().getBasedir() != null) { getLog().debug("No version for " + key + " found in " + project + "; looking in parent "); return getReleasedVersion(project.getParent(), artifact); } else return null; }