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

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

Introduction

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

Prototype

public String getArtifactId() 

Source Link

Usage

From source file:uk.ac.ox.oucs.plugins.DiscoverMojo.java

License:Apache License

public MavenProject findImplementation(Artifact artifact) {
    MavenProject project = null;
    String groupId = artifact.getGroupId();
    String artifactId = artifact.getArtifactId();
    String version = artifact.getVersion();

    String key = groupId + ":" + artifactId;
    String prefer = preferred.getProperty(key);
    if (prefer != null) {
        if (prefer.equalsIgnoreCase("exclude")) {
            return null;
        }/*w ww .j  a va 2s. co  m*/
        getLog().debug("Prefered: " + prefer);
        String[] parts = prefer.split(":");
        if (parts.length > 0) {
            groupId = parts[0];
            if (parts.length > 1) {
                artifactId = parts[1];
                if (parts.length > 2)
                    version = parts[2];
            }
        }
        project = locateImplmentation(groupId, artifactId, version);

    }

    else {
        if (cachedImplementations.containsKey(key)) {
            String implementationId = cachedImplementations.getProperty(key);
            if (!"none".equals(implementationId)) {
                project = locateImplmentation(groupId, implementationId, version);
            }
        } else {
            if (artifactId.endsWith("-api")) {
                String baseId = artifactId.substring(0, artifactId.length() - "-api".length());
                String implmentationId = baseId + "-bundle";
                project = locateImplmentation(groupId, implmentationId, version);
                if (project == null) {
                    implmentationId = baseId + "-pack";
                    project = locateImplmentation(groupId, implmentationId, version);
                    if (project == null) {
                        implmentationId = baseId + "-components";
                        project = locateImplmentation(groupId, implmentationId, version);
                        if (project == null) {
                            // OSP fix
                            implmentationId = baseId + "-component";
                            project = locateImplmentation(groupId, implmentationId, version);
                        }
                    }
                }
            } else if (artifactId.endsWith("-tool")) {
                String baseId = artifactId.substring(0, artifactId.length() - "-tool".length());
                String implmentationId = baseId + "-help";
                project = locateImplmentation(groupId, implmentationId, version);
            }
            cachedImplementations.setProperty(key, (project == null) ? "none" : project.getArtifactId());
        }

    }
    return project;
}

From source file:uk.co.unclealex.executable.plugin.ExecutableMojo.java

License:Apache License

/**
 * Deletes file-sets in the following project build directory order: (source)
 * directory, output directory, test directory, report directory, and then the
 * additional file-sets./*from  www. j  av  a2s . c  o m*/
 * 
 * @throws MojoExecutionException
 *           When a directory failed to get deleted.
 * @see org.apache.maven.plugin.Mojo#execute()
 */
public void execute() throws MojoExecutionException {
    Scripter scripter = Guice.createInjector(new CodeGeneratorModule()).getInstance(Scripter.class);
    Path buildDirectory = getBuildDirectory().toPath();
    Path classesDirectory = getOutputDirectory().toPath();
    MavenProject project = getProject();
    String version = project.getVersion();
    Path targetPath = buildDirectory.resolve(project.getArtifactId() + "-" + version + ".sh");
    Path workDirectory = buildDirectory.resolve("executable");
    Iterable<Path> dependencyJarFiles = Iterables.transform(getClasspathElements(), new PathFunction());
    try {
        scripter.generate(targetPath, classesDirectory, getHomeExpression(), version, workDirectory,
                dependencyJarFiles);
        //getProjectHelper(). attachArtifact(project, "sh", targetPath.toFile());
        project.getArtifact().setFile(targetPath.toFile());
    } catch (IOException | ExecutableScanException e) {
        throw new MojoExecutionException("Building an executable script failed.", e);
    }
}