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

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

Introduction

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

Prototype

public String getVersion() 

Source Link

Usage

From source file:com.ericsson.tools.cpp.compiler.artifacts.ArtifactManager.java

License:Apache License

public Artifact createProjectArtifact(final MavenProject project) {
    return factory.createProjectArtifact(project.getGroupId(), project.getArtifactId(), project.getVersion());
}

From source file:com.github.ferstl.maven.pomenforcers.PedanticDependencyManagementLocationEnforcer.java

License:Apache License

private boolean isDependencyManagingProject(MavenProject project) {
    ArtifactModel projectInfo = new ArtifactModel(project.getGroupId(), project.getArtifactId(),
            project.getVersion());
    return this.dependencyManagingPoms.isEmpty() || this.dependencyManagingPoms.contains(projectInfo);

}

From source file:com.github.ferstl.maven.pomenforcers.PedanticPluginManagementLocationEnforcer.java

License:Apache License

private boolean isPluginManagingProject(MavenProject project) {
    ArtifactModel projectInfo = new ArtifactModel(project.getGroupId(), project.getArtifactId(),
            project.getVersion());
    return this.pluginManagingPoms.isEmpty() || this.pluginManagingPoms.contains(projectInfo);
}

From source file:com.github.jeluard.maven.ParentEnforcerRule.java

License:Apache License

@Override
public void execute(final EnforcerRuleHelper helper) throws EnforcerRuleException {
    final MavenProject project;
    try {/*from  ww  w.  ja va  2s.com*/
        project = (MavenProject) helper.evaluate("${project}");
    } catch (ExpressionEvaluationException e) {
        throw new EnforcerRuleException("Failed to access ${project} variable", e);
    }

    final String type = project.getArtifact().getType();
    if (!ParentEnforcerRule.POM_ARTIFACT_TYPE.equals(type)) {
        helper.getLog().debug("Skipping non " + ParentEnforcerRule.POM_ARTIFACT_TYPE + " artifact.");

        return;
    }

    final Parent parent = new Parent();
    parent.setGroupId(project.getGroupId());
    parent.setArtifactId(project.getArtifactId());
    parent.setVersion(project.getVersion());
    try {
        validateSubModules(extractRootFolder(project), project.getModel(), parent);
    } catch (IOException e) {
        throw new EnforcerRuleException("Failed to process one of project's module", e);
    }
}

From source file:com.github.jlgrock.javascriptframework.jspreprocessor.processors.FileTimeStamp.java

/**
 * fill this in later...// w ww .j  a v  a2s .  c  o m
 * 
 * @param project
 *            asd TODO .
 */
public final void executeFileTimeStamp(final MavenProject project) {
    // TODO add this information to the top of every file
    project.getVersion();
    project.getGroupId();
    project.getArtifactId();
    System.getProperty("java.version");
    System.getProperty("os.name");
    System.getProperty("user.name");
    // getCopyright();
    // getLicense();
}

From source file:com.github.jrh3k5.flume.mojo.plugin.AbstractFlumePluginMojo.java

License:Apache License

/**
 * Format the name of a Maven project.//from w ww  .ja  va  2  s  . c o  m
 * 
 * @param mavenProject
 *            The {@link MavenProject} whose name is to be formatted.
 * @return A formatted identifier of the given {@link MavenProject}.
 */
protected static String formatIdentifier(MavenProject mavenProject) {
    return String.format("%s:%s:%s:%s", mavenProject.getGroupId(), mavenProject.getArtifactId(),
            mavenProject.getVersion(), mavenProject.getPackaging());
}

From source file:com.github.maven_nar.NarLayout20.java

License:Apache License

@Override
public final void attachNars(final File baseDir, final ArchiverManager archiverManager,
        final MavenProjectHelper projectHelper, final MavenProject project) throws MojoExecutionException {
    if (getIncludeDirectory(baseDir, project.getArtifactId(), project.getVersion()).exists()) {
        attachNar(archiverManager, projectHelper, project, "noarch", baseDir, "include/**");
    }/* w w  w. j a v a  2s.c o m*/

    final String[] binAOL = new File(baseDir, "bin").list();
    for (int i = 0; binAOL != null && i < binAOL.length; i++) {
        attachNar(archiverManager, projectHelper, project, binAOL[i] + "-" + Library.EXECUTABLE, baseDir,
                "bin/" + binAOL[i] + "/**");
    }

    final File libDir = new File(baseDir, "lib");
    final String[] libAOL = libDir.list();
    for (int i = 0; libAOL != null && i < libAOL.length; i++) {
        final String bindingType = null;
        final String[] libType = new File(libDir, libAOL[i]).list();
        for (int j = 0; libType != null && j < libType.length; j++) {
            attachNar(archiverManager, projectHelper, project, libAOL[i] + "-" + libType[j], baseDir,
                    "lib/" + libAOL[i] + "/" + libType[j] + "/**");
        }

    }
}

From source file:com.github.maven_nar.NarLayout20.java

License:Apache License

@Override
public final void prepareNarInfo(final File baseDir, final MavenProject project, final NarInfo narInfo,
        final AbstractNarMojo mojo) throws MojoExecutionException {
    if (getIncludeDirectory(baseDir, project.getArtifactId(), project.getVersion()).exists()) {
        narInfo.setNar(null, "noarch", project.getGroupId() + ":" + project.getArtifactId() + ":"
                + NarConstants.NAR_TYPE + ":" + "noarch");
    }//from   w w w  . j  a v a2s .c om

    final String[] binAOL = new File(baseDir, "bin").list();
    for (int i = 0; binAOL != null && i < binAOL.length; i++) {// TODO: chose
                                                               // not to apply
                                                               // new file
                                                               // naming for
                                                               // outfile in
                                                               // case of
                                                               // backwards
                                                               // compatability,
                                                               // may need to
                                                               // reconsider
        narInfo.setNar(null, Library.EXECUTABLE, project.getGroupId() + ":" + project.getArtifactId() + ":"
                + NarConstants.NAR_TYPE + ":" + "${aol}" + "-" + Library.EXECUTABLE);
        narInfo.setBinding(new AOL(binAOL[i]), Library.EXECUTABLE);
        narInfo.setBinding(null, Library.EXECUTABLE);
    }

    final File libDir = new File(baseDir, "lib");
    final String[] libAOL = libDir.list();
    for (int i = 0; libAOL != null && i < libAOL.length; i++) {
        String bindingType = null;
        final String[] libType = new File(libDir, libAOL[i]).list();
        for (int j = 0; libType != null && j < libType.length; j++) {
            narInfo.setNar(null, libType[j], project.getGroupId() + ":" + project.getArtifactId() + ":"
                    + NarConstants.NAR_TYPE + ":" + "${aol}" + "-" + libType[j]);

            // set if not set or override if SHARED
            if (bindingType == null || libType[j].equals(Library.SHARED)) {
                bindingType = libType[j];
            }
        }

        final AOL aol = new AOL(libAOL[i]);
        if (narInfo.getBinding(aol, null) == null) {
            narInfo.setBinding(aol, bindingType != null ? bindingType : Library.NONE);
        }
        if (narInfo.getBinding(null, null) == null) {
            narInfo.setBinding(null, bindingType != null ? bindingType : Library.NONE);
        }
    }
}

From source file:com.github.maven_nar.NarLayout21.java

License:Apache License

@Override
public final void attachNars(final File baseDir, final ArchiverManager archiverManager,
        final MavenProjectHelper projectHelper, final MavenProject project) throws MojoExecutionException {
    if (getNoArchDirectory(baseDir, project.getArtifactId(), project.getVersion()).exists()) {
        attachNar(archiverManager, projectHelper, project, NarConstants.NAR_NO_ARCH,
                getNoArchDirectory(baseDir, project.getArtifactId(), project.getVersion()), "*/**");
    }//from   w  w  w. java  2 s.  c  om

    // list all directories in basedir, scan them for classifiers
    final String[] subDirs = baseDir.list();
    for (int i = 0; subDirs != null && i < subDirs.length; i++) {
        final String artifactIdVersion = project.getArtifactId() + "-" + project.getVersion();

        // skip entries not belonging to this project
        if (!subDirs[i].startsWith(artifactIdVersion)) {
            continue;
        }

        final String classifier = subDirs[i].substring(artifactIdVersion.length() + 1);

        // skip noarch here
        if (classifier.equals(NarConstants.NAR_NO_ARCH)) {
            continue;
        }

        final File dir = new File(baseDir, subDirs[i]);
        attachNar(archiverManager, projectHelper, project, classifier, dir, "*/**");
    }
}

From source file:com.github.maven_nar.NarLayout21.java

License:Apache License

@Override
public final void prepareNarInfo(final File baseDir, final MavenProject project, final NarInfo narInfo,
        final AbstractNarMojo mojo) throws MojoExecutionException {
    if (getNoArchDirectory(baseDir, project.getArtifactId(), project.getVersion()).exists()) {
        narInfo.setNar(null, NarConstants.NAR_NO_ARCH, project.getGroupId() + ":" + project.getArtifactId()
                + ":" + NarConstants.NAR_TYPE + ":" + NarConstants.NAR_NO_ARCH);
    }/*from   ww w .  ja v  a  2s  . c om*/

    final String artifactIdVersion = project.getArtifactId() + "-" + project.getVersion();
    // list all directories in basedir, scan them for classifiers
    final String[] subDirs = baseDir.list();
    final ArrayList<String> classifiers = new ArrayList<String>();
    for (int i = 0; subDirs != null && i < subDirs.length; i++) {
        // skip entries not belonging to this project
        if (!subDirs[i].startsWith(artifactIdVersion)) {
            continue;
        }

        final String classifier = subDirs[i].substring(artifactIdVersion.length() + 1);

        // skip noarch here
        if (classifier.equals(NarConstants.NAR_NO_ARCH)) {
            continue;
        }

        classifiers.add(classifier);
    }

    if (!classifiers.isEmpty()) {

        for (final String classifier : classifiers) {
            final int lastDash = classifier.lastIndexOf('-');
            final String type = classifier.substring(lastDash + 1);
            final AOL aol = new AOL(classifier.substring(0, lastDash));

            if (narInfo.getOutput(aol, null) == null) {
                narInfo.setOutput(aol, mojo.getOutput(!Library.EXECUTABLE.equals(type)));
            }

            // We prefer shared to jni/executable/static/none,
            if (type.equals(Library.SHARED)) // overwrite whatever we had
            {
                narInfo.setBinding(aol, type);
                narInfo.setBinding(null, type);
            } else {
                // if the binding is already set, then don't write it for
                // jni/executable/static/none.
                if (narInfo.getBinding(aol, null) == null) {
                    narInfo.setBinding(aol, type);
                }
                if (narInfo.getBinding(null, null) == null) {
                    narInfo.setBinding(null, type);
                }
            }

            narInfo.setNar(null, type, project.getGroupId() + ":" + project.getArtifactId() + ":"
                    + NarConstants.NAR_TYPE + ":" + "${aol}" + "-" + type);

        }

        // setting this first stops the per type config because getOutput check
        // for aol defaults to this generic one...
        if (mojo != null && narInfo.getOutput(null, null) == null) {
            narInfo.setOutput(null, mojo.getOutput(true));
        }
    }
}