Example usage for org.apache.maven.project MavenProject getParent

List of usage examples for org.apache.maven.project MavenProject getParent

Introduction

In this page you can find the example usage for org.apache.maven.project MavenProject getParent.

Prototype

public MavenProject getParent() 

Source Link

Document

Returns the project corresponding to a declared parent.

Usage

From source file:org.hudsonci.maven.eventspy_30.ProfileCollector.java

License:Open Source License

private void collectFromProjectUp(final MavenProject project) {
    // At the top of the hierarchy, stop recursion.
    if (null == project) {
        return;/*w w  w  . j  a v a2 s .  c  o  m*/
    }

    collectResolvedProfiles(project, project.getModel().getProfiles());
    // Walk up hierarchy.
    collectFromProjectUp(project.getParent());
}

From source file:org.impalaframework.maven.plugin.MojoUtils.java

License:Apache License

static String getModuleStagingDirectory(Log log, MavenProject project, String moduleStagingDirectory)
        throws MojoExecutionException {

    //FIXME test//from w  w  w. j av a 2 s . c  o m

    String parentName = null;

    if (moduleStagingDirectory == null) {
        MavenProject parent = project.getParent();
        if (parent != null) {
            parentName = parent.getName();
            final String parentOutputDirectory = parent.getBuild().getDirectory();
            if (parentOutputDirectory != null) {
                moduleStagingDirectory = parentOutputDirectory + "/staging";
            }
        }
    }

    if (moduleStagingDirectory == null) {
        throw new MojoExecutionException("Unable to determine module staging directory for project '"
                + project.getName() + "'"
                + (parentName != null ? " from project parent '" + parentName + "'" : " with no project parent")
                + ". Please use 'moduleStagingDirectory' configuration parameter to specify this.");
    }

    log.info("Using module staging directory: " + moduleStagingDirectory);

    return moduleStagingDirectory;
}

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();
    }/*from  ww w.j  a  v a2s.  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;
    }/*  ww  w  .j a  v a  2 s  .co m*/
    if (groupId.equals(parent.getGroupId()) && artifactId.equals(parent.getArtifactId())) {
        return true;
    } else {
        return checkProjectParent(parent, groupId, artifactId);
    }
}

From source file:org.jasig.maven.legal.util.ResourceFinder.java

License:Apache License

private URL searchProjectTree(MavenProject project, String resource) {
    // first search relatively to the base directory
    URL res = toURL(new File(project.getBasedir(), resource));
    if (res != null) {
        return res;
    }/*from  w ww  . ja  va 2s.  c  o  m*/

    //Look up the project tree to try and find a match as well.
    final MavenProject parent = project.getParent();
    if (!project.isExecutionRoot() && parent != null && parent.getBasedir() != null) {
        return this.searchProjectTree(parent, resource);
    }

    return null;
}

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 .  java  2  s.com*/
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.jetbrains.idea.maven.server.embedder.Maven2ServerEmbedderImpl.java

License:Apache License

private Collection<String> collectActivatedProfiles(MavenProject mavenProject) {
    // for some reason project's active profiles do not contain parent's profiles - only local and settings'.
    // parent's profiles do not contain settings' profiles.

    List<Profile> profiles = new ArrayList<Profile>();
    while (mavenProject != null) {
        if (profiles != null) {
            profiles.addAll(mavenProject.getActiveProfiles());
        }//from w ww  .j  a  va2  s  .  c om
        mavenProject = mavenProject.getParent();
    }
    return collectProfilesIds(profiles);
}

From source file:org.jetbrains.idea.maven.server.Maven30ServerEmbedderImpl.java

License:Apache License

private static Collection<String> collectActivatedProfiles(MavenProject mavenProject) throws RemoteException {
    // for some reason project's active profiles do not contain parent's profiles - only local and settings'.
    // parent's profiles do not contain settings' profiles.

    List<Profile> profiles = new ArrayList<Profile>();
    try {/*w  ww .  j a va 2s . co  m*/
        while (mavenProject != null) {
            profiles.addAll(mavenProject.getActiveProfiles());
            mavenProject = mavenProject.getParent();
        }
    } catch (Exception e) {
        // don't bother user if maven failed to build parent project
        Maven3ServerGlobals.getLogger().info(e);
    }
    return collectProfilesIds(profiles);
}

From source file:org.jooby.JoobyMojo.java

License:Apache License

@SuppressWarnings("unchecked")
private Set<Artifact> references(final MavenProject project) {
    MavenProject parent = project.getParent();
    if (parent != null) {
        List<String> modules = parent.getModules();
        if (modules != null) {
            Set<Artifact> artifacts = new LinkedHashSet<Artifact>(mavenProject.getArtifacts());
            String groupId = project.getGroupId();
            String version = project.getVersion();
            return artifacts.stream().filter(a -> a.getGroupId().equals(groupId)
                    && a.getVersion().equals(version) && modules.contains(a.getArtifactId()))
                    .collect(Collectors.toSet());
        }/*  w ww  .  ja  va2 s  .c  o m*/
    }
    return Collections.emptySet();
}

From source file:org.jooby.JoobyMojo.java

License:Apache License

private Set<File> refbasedir(final MavenProject project, final Set<Artifact> references) {
    Set<File> cp = new LinkedHashSet<>();
    for (Artifact reference : references) {
        File basedir = project.getParent().getBasedir();
        cp.add(new File(basedir, reference.getArtifactId()));
    }//from w w w  .j  a v  a 2  s . co  m
    return cp;
}