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

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

Introduction

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

Prototype

public String getGroupId() 

Source Link

Usage

From source file:net.oneandone.maven.plugins.prerelease.core.Archive.java

License:Apache License

public static List<FileNode> directories(List<FileNode> storages, MavenProject project) {
    List<FileNode> directories;

    directories = new ArrayList<>(storages.size());
    for (FileNode storage : storages) {
        directories.add(storage.join(project.getGroupId(), project.getArtifactId()));
    }// w w w . j  a va  2s. c om
    return directories;
}

From source file:net.oneandone.maven.plugins.prerelease.core.Project.java

License:Apache License

public static Project forMavenProject(MavenProject project, String version) {
    return new Project(project.getGroupId(), project.getArtifactId(), version);
}

From source file:net.oneandone.maven.plugins.prerelease.util.PromoteExecutionListener.java

License:Apache License

@Override
public void projectStarted(ExecutionEvent event) {
    MavenProject project;
    Artifact projectArtifact;//  www  . j  ava 2s  . c o m
    Versioning versioning;
    ArtifactRepositoryMetadata metadata;
    GroupRepositoryMetadata groupMetadata;

    project = event.getSession().getCurrentProject();
    try {
        prerelease.artifactFiles(project, projectHelper);
        project.getProperties().putAll(prerelease.descriptor.deployProperties);
        if (prerelease.descriptor.deployPluginMetadata) {
            // from http://svn.apache.org/viewvc/maven/plugin-tools/tags/maven-plugin-tools-3.2/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/AddPluginArtifactMetadataMojo.java

            projectArtifact = project.getArtifact();
            versioning = new Versioning();
            versioning.setLatest(projectArtifact.getVersion());
            versioning.updateTimestamp();
            metadata = new ArtifactRepositoryMetadata(projectArtifact, versioning);
            projectArtifact.addMetadata(metadata);
            groupMetadata = new GroupRepositoryMetadata(project.getGroupId());
            groupMetadata.addPluginMapping(
                    PluginDescriptor.getGoalPrefixFromArtifactId(project.getArtifactId()),
                    project.getArtifactId(), project.getName());

            projectArtifact.addMetadata(groupMetadata);
        }
    } catch (IOException e) {
        throw new RuntimeException("TODO", e);
    }
    super.projectStarted(event);
}

From source file:net.oneandone.maven.rules.common.RuleHelper.java

License:Apache License

public static String getProjectIdentifier(MavenProject mavenProject) {
    return mavenProject.getGroupId() + ":" + mavenProject.getArtifactId();
}

From source file:net.oneandone.pommes.cli.Environment.java

License:Apache License

public String lookup(String name) throws IOException {
    MavenProject p;
    FileNode here;/*from   ww  w .  j a v  a 2s .co m*/
    Point point;

    switch (name) {
    case "svn":
        here = (FileNode) world.getWorking();
        point = fstab().pointOpt(here);
        if (point == null) {
            throw new IllegalArgumentException("no mount point for directory " + here.getAbsolute());
        }
        return point.svnurl(here);
    case "gav":
        p = project();
        return p.getGroupId() + ":" + p.getArtifactId() + ":" + p.getVersion();
    case "ga":
        p = project();
        return p.getGroupId() + ":" + p.getArtifactId();
    default:
        return null;
    }
}

From source file:net.oneandone.pommes.model.Pom.java

License:Apache License

public static Pom forProject(String origin, MavenProject project) {
    Pom result;//from  w  ww.  j a va  2 s. co m

    result = new Pom(origin, new GAV(project.getGroupId(), project.getArtifactId(), project.getVersion()));
    for (Dependency dependency : project.getDependencies()) {
        result.dependencies.add(GAV.forDependency(dependency));
    }
    return result;
}

From source file:net.oneki.maven.plugins.helper.ArtifactHelper.java

License:Apache License

public static String getArtifactCoord(MavenProject project) {
    return getArtifactCoord(project.getGroupId(), project.getArtifactId(), project.getVersion());
}

From source file:net.roboconf.maven.ValidateApplicationMojo.java

License:Apache License

/**
 * Validate aspects that are specific to recipes (i.e. partial Roboconf applications).
 * <p>/*ww w. ja  va2  s.c om*/
 * Most of this validation could have been handled through enforcer rules. However,
 * they are all warnings and we do not want to create hundreds of projects. We can
 * see these rules as good practices that will be shared amongst all the Roboonf users.
 * </p>
 * <p>
 * At worst, users can ignore these warnings.
 * Or they can submit a feature request to add or remove validation rules.
 * </p>
 *
 * @param project a Maven project
 * @param tpl an application template
 * @param official true if this recipe is maintained by the Roboconf team, false otherwise
 * @return a non-null list of errors
 */
static Collection<RoboconfError> validateRecipesSpecifics(MavenProject project, ApplicationTemplate tpl,
        boolean official) {

    Collection<RoboconfError> result = new ArrayList<>();
    if (!project.getArtifactId().equals(project.getArtifactId().toLowerCase()))
        result.add(new RoboconfError(ErrorCode.REC_ARTIFACT_ID_IN_LOWER_CASE));

    if (!tpl.getRootInstances().isEmpty())
        result.add(new RoboconfError(ErrorCode.REC_AVOID_INSTANCES));

    if (official && !Constants.OFFICIAL_RECIPES_GROUP_ID.equals(project.getGroupId()))
        result.add(new RoboconfError(ErrorCode.REC_OFFICIAL_GROUP_ID));

    if (!project.getArtifactId().equals(project.getArtifactId()))
        result.add(new RoboconfError(ErrorCode.REC_NON_MATCHING_ARTIFACT_ID));

    File[] files = project.getBasedir().listFiles();
    boolean found = false;
    if (files != null) {
        for (int i = 0; i < files.length && !found; i++)
            found = files[i].getName().matches("(?i)readme(\\..*)?");
    }

    if (!found)
        result.add(new RoboconfError(ErrorCode.REC_MISSING_README));

    return result;
}

From source file:net.sf.buildbox.maven.contentcheck.LicenseShowMojo.java

License:Open Source License

/**
 * @see net.sf.buildbox.maven.contentcheck.AbstractArchiveContentMojo#doExecute()
 *//*from  w  w w .jav  a2s  .co  m*/
@Override
protected void doExecute() throws IOException, MojoExecutionException, MojoFailureException {
    List<MavenProject> mavenProjectForDependencies = getMavenProjectForDependencies();

    DefaultIntrospector introspector = new DefaultIntrospector(getLog(), isIgnoreVendorArchives(),
            getVendorId(), getManifestVendorEntry(), getCheckFilesPattern());
    introspector.readArchive(getArchive());

    Set<String> archiveEntries = new LinkedHashSet<String>(introspector.getArchiveEntries());
    Map<String, List<License>> entries = new LinkedHashMap<String, List<License>>();

    Map<String, List<License>> additionalLicenseInformation = new LinkedHashMap<String, List<License>>();
    if (licenseMappingFile != null && licenseMappingFile.exists()) {
        //read additional license information
        LicenseMappingParser licenseMappingParser = new LicenseMappingParser(getLog(), licenseMappingFile);
        additionalLicenseInformation.putAll(licenseMappingParser.parseLicenseMappingFile());
    }

    getLog().info("Comparing the archive content with Maven project artifacts");
    for (String archiveEntry : archiveEntries) {
        List<License> licenses = null; //these licenses will be associated with the given archive entry

        for (MavenProject mavenProject : mavenProjectForDependencies) {
            mavenProject.getGroupId();
            String artifactId = mavenProject.getArtifactId();
            String version = mavenProject.getVersion();
            String jarName = artifactId + "-" + version + ".jar"; //guess jar name
            if (archiveEntry.endsWith(jarName)) {
                @SuppressWarnings("unchecked")
                List<License> _licenses = mavenProject.getLicenses();
                licenses = _licenses == null || _licenses.size() == 0 ? null : _licenses;
                break;
            }
        }

        List<License> licensesMappingFile = additionalLicenseInformation
                .get(stripJARNameFromPath(archiveEntry));

        if (licenses == null && licensesMappingFile == null) {//misising license information
            getLog().debug(String.format(
                    "Cannot resolve license information for archive entry %s neither from the POM file nor the file for license mapping",
                    archiveEntry));
            //archive entry must be present even if there is no a matching Maven Project
            entries.put(archiveEntry, Collections.<License>emptyList());
        } else if (licenses != null && licensesMappingFile != null) {//licenses specified in both - POM and license mapping file
            getLog().warn(String.format(
                    "The license information for file %s are defined in the POM file and also in the file for license mapping. Using license information from the the file for license mapping.",
                    archiveEntry));
            entries.put(archiveEntry, licensesMappingFile); //mapping manually specified licenses precedes licenses from POM
        } else if (licenses != null) {//license information in POM
            entries.put(archiveEntry, licenses);//license
        } else {
            //license information in mapping file
            //put additional license information to the object that holds this information
            entries.put(archiveEntry, licensesMappingFile);
        }
    }

    LicenseOutput logOutput = new LogOutput(getLog());
    logOutput.output(entries);

    if (csvOutput) {
        CsvOutput csvOutput = new CsvOutput(getLog(), csvOutputFile);
        csvOutput.output(entries);
    }
}

From source file:nl.mpi.tla.version.controller.VersionControlCheck.java

License:Open Source License

@Override
public void execute() throws MojoExecutionException {
    final VcsVersionChecker versionChecker;
    try {//  w ww .  ja  va  2  s. c om
        switch (VcsType.valueOf(vcsType)) {
        case git:
            versionChecker = new GitVersionChecker(new CommandRunnerImpl());
            break;
        case svn:
            versionChecker = new SvnVersionChecker(new CommandRunnerImpl());
            break;
        default:
            throw new MojoExecutionException("Unknown version control system: " + vcsType);
        }
    } catch (IllegalArgumentException exception) {
        throw new MojoExecutionException("Unknown version control system: " + vcsType + "\nValid options are: "
                + VcsType.git.name() + " or " + VcsType.svn.name());
    }
    if (verbose) {
        logger.info("VersionControlCheck");
        logger.info("project: " + project);
        logger.info("majorVersion: " + majorVersion);
        logger.info("minorVersion: " + minorVersion);
        logger.info("buildType: " + buildType);
        logger.info("outputDirectory: " + outputDirectory);
        logger.info("projectDirectory :" + projectDirectory);
    }
    for (MavenProject reactorProject : mavenProjects) {
        final String artifactId = reactorProject.getArtifactId();
        final String moduleVersion = reactorProject.getVersion();
        final String groupId = reactorProject.getGroupId();
        logger.info("Checking version numbers for " + artifactId);
        if (verbose) {
            logger.info("artifactId: " + artifactId);
            logger.info("moduleVersion: " + moduleVersion);
            logger.info("moduleDir :" + reactorProject.getBasedir());
        }
        //                for (MavenProject dependencyProject : reactorProject.getDependencies()) {
        //                    logger.info("dependencyProject:" + dependencyProject.getArtifactId());
        //                }
        final String expectedVersion;
        final String buildVersionString;
        final File moduleDirectory = reactorProject.getBasedir();
        if (allowSnapshots && moduleVersion.contains("SNAPSHOT")) {
            expectedVersion = majorVersion + "." + minorVersion + "-" + buildType + "-SNAPSHOT";
            buildVersionString = "-1"; //"SNAPSHOT"; it will be nice to have snapshot here but we need to update some of the unit tests first
        } else if ((modulesWithShortVersion != null && modulesWithShortVersion.contains(artifactId))
                || (moduleWithShortVersion != null && moduleWithShortVersion.equals(artifactId))) {
            expectedVersion = majorVersion + "." + minorVersion;
            buildVersionString = "-1";
        } else {
            logger.info("getting build number");
            int buildVersion = versionChecker.getBuildNumber(verbose, moduleDirectory, ".");
            logger.info(artifactId + ".buildVersion: " + Integer.toString(buildVersion));
            expectedVersion = majorVersion + "." + minorVersion + "." + buildVersion + "-" + buildType;
            buildVersionString = Integer.toString(buildVersion);
        }
        if (!expectedVersion.equals(moduleVersion)) {
            logger.error("Expecting version number: " + expectedVersion);
            logger.error("But found: " + moduleVersion);
            logger.error("Artifact: " + artifactId);
            throw new MojoExecutionException("The build numbers to not match for '" + artifactId + "': '"
                    + expectedVersion + "' vs '" + moduleVersion + "'");
        }
        // get the last commit date
        logger.info("getting lastCommitDate");
        final String lastCommitDate = versionChecker.getLastCommitDate(verbose, moduleDirectory, ".");
        logger.info(".lastCommitDate:" + lastCommitDate);
        // construct the compile date
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
        Date date = new Date();
        final String buildDate = dateFormat.format(date);
        // setting the maven properties
        final String versionPropertyName = groupId + "." + artifactId + ".moduleVersion";
        logger.info("Setting property '" + versionPropertyName + "' to '" + expectedVersion + "'");
        reactorProject.getProperties().setProperty(versionPropertyName, expectedVersion);
        reactorProject.getProperties().setProperty(propertiesPrefix + ".majorVersion", majorVersion);
        reactorProject.getProperties().setProperty(propertiesPrefix + ".minorVersion", minorVersion);
        reactorProject.getProperties().setProperty(propertiesPrefix + ".buildVersion", buildVersionString);
        reactorProject.getProperties().setProperty(propertiesPrefix + ".lastCommitDate", lastCommitDate);
        reactorProject.getProperties().setProperty(propertiesPrefix + ".buildDate", buildDate);
    }
}