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

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

Introduction

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

Prototype

public String getName() 

Source Link

Usage

From source file:hudson.gridmaven.util.ExecutionEventLogger.java

License:Apache License

@Override
public void sessionStarted(ExecutionEvent event) {
    if (logger.isInfoEnabled() && event.getSession().getProjects().size() > 1) {
        logger.info(chars('-', LINE_LENGTH));

        logger.info("Reactor Build Order:");

        logger.info("");

        for (MavenProject project : event.getSession().getProjects()) {
            logger.info(project.getName());
        }//from   w w w . j  a  va  2  s . c om
    }
}

From source file:hudson.gridmaven.util.ExecutionEventLogger.java

License:Apache License

private void logReactorSummary(MavenSession session) {
    logger.info(chars('-', LINE_LENGTH));

    logger.info("Reactor Summary:");

    logger.info("");

    MavenExecutionResult result = session.getResult();

    for (MavenProject project : session.getProjects()) {
        StringBuilder buffer = new StringBuilder(128);

        buffer.append(project.getName());

        buffer.append(' ');
        while (buffer.length() < LINE_LENGTH - 21) {
            buffer.append('.');
        }//from ww  w .  j av a2s  .  c  o m
        buffer.append(' ');

        BuildSummary buildSummary = result.getBuildSummary(project);

        if (buildSummary == null) {
            buffer.append("SKIPPED");
        } else if (buildSummary instanceof BuildSuccess) {
            buffer.append("SUCCESS [");
            buffer.append(getFormattedTime(buildSummary.getTime()));
            buffer.append("]");
        } else if (buildSummary instanceof BuildFailure) {
            buffer.append("FAILURE [");
            buffer.append(getFormattedTime(buildSummary.getTime()));
            buffer.append("]");
        }

        logger.info(buffer.toString());
    }
}

From source file:io.fabric8.maven.ZipMojo.java

License:Apache License

protected void generateZip()
        throws DependencyTreeBuilderException, MojoExecutionException, IOException, MojoFailureException {

    File appBuildDir = buildDir;//  w w  w. j a va  2s . c  om
    if (Strings.isNotBlank(pathInZip)) {
        appBuildDir = new File(buildDir, pathInZip);
    }
    appBuildDir.mkdirs();

    if (hasConfigDir()) {
        copyAppConfigFiles(appBuildDir, appConfigDir);

    } else {
        getLog().info("The app configuration files directory " + appConfigDir
                + " doesn't exist, so not copying any additional project documentation or configuration files");
    }
    MavenProject project = getProject();

    if (!ignoreProject) {
        File kubernetesJson = getKubernetesJson();
        if (kubernetesJson != null && kubernetesJson.isFile() && kubernetesJson.exists()) {
            File jsonFile = new File(appBuildDir, "kubernetes.json");
            jsonFile.getParentFile().mkdirs();
            Files.copy(kubernetesJson, jsonFile);
        }

        // TODO if no iconRef is specified we could try guess based on the project?

        // lets check if we can use an icon reference
        copyIconToFolder(appBuildDir);

    }

    // lets only generate a app zip if we have a requirement (e.g. we're not a parent pom packaging project) and
    // we have defined some configuration files or dependencies
    // to avoid generating dummy apps for parent poms
    if (hasConfigDir() || !ignoreProject) {

        if (includeReadMe) {
            copyReadMe(appBuildDir);
        }

        if (generateSummaryFile) {
            copySummaryText(appBuildDir);
        }

        if (generateAppPropertiesFile) {
            String name = project.getName();
            if (Strings.isNullOrBlank(name)) {
                name = project.getArtifactId();
            }
            String description = project.getDescription();
            Properties appProperties = new Properties();
            appProperties.put("name", name);
            if (Strings.isNotBlank(description)) {
                appProperties.put("description", description);
            }
            appProperties.put("groupId", project.getGroupId());
            appProperties.put("artifactId", project.getArtifactId());
            appProperties.put("version", project.getVersion());
            File appPropertiesFile = new File(appBuildDir, "fabric8.properties");
            appPropertiesFile.getParentFile().mkdirs();
            if (!appPropertiesFile.exists()) {
                appProperties.store(new FileWriter(appPropertiesFile), "Fabric8 Properties");
            }
        }

        File outputZipFile = getZipFile();
        File legalDir = null;
        if (includeLegal) {
            legalDir = new File(project.getBuild().getOutputDirectory(), "META-INF");
        }
        Zips.createZipFile(getLog(), buildDir, outputZipFile, legalDir);

        projectHelper.attachArtifact(project, artifactType, artifactClassifier, outputZipFile);
        getLog().info("Created app zip file: " + outputZipFile);
    }
}

From source file:io.sarl.maven.docs.AbstractDocumentationMojo.java

License:Apache License

private Properties createProjectProperties() {
    final Properties props = new Properties();
    final MavenProject prj = this.session.getCurrentProject();
    props.put("project.groupId", prj.getGroupId()); //$NON-NLS-1$
    props.put("project.artifactId", prj.getArtifactId()); //$NON-NLS-1$
    props.put("project.basedir", prj.getBasedir()); //$NON-NLS-1$
    props.put("project.description", prj.getDescription()); //$NON-NLS-1$
    props.put("project.id", prj.getId()); //$NON-NLS-1$
    props.put("project.inceptionYear", prj.getInceptionYear()); //$NON-NLS-1$
    props.put("project.name", prj.getName()); //$NON-NLS-1$
    props.put("project.version", prj.getVersion()); //$NON-NLS-1$
    props.put("project.url", prj.getUrl()); //$NON-NLS-1$
    props.put("project.encoding", this.encoding); //$NON-NLS-1$
    return props;
}

From source file:io.takari.maven.builder.smart.SmartBuilderImpl.java

License:Apache License

void buildProject(MavenProject project) {
    log("Starting " + project.getName());

    final long projectStopwatch = System.currentTimeMillis();

    try {/*from   www  .j  av a2s  . co m*/
        MavenSession copiedSession = rootSession.clone();
        for (TaskSegment taskSegment : taskSegments) {
            lifecycleModuleBuilder.buildProject(copiedSession, rootSession, reactorContext, project,
                    taskSegment);
        }
    } catch (RuntimeException ex) {
        // preserve the xml stack trace, and the java cause chain
        rootSession.getResult()
                .addException(new RuntimeException(project.getName() + ": " + ex.getMessage(), ex));
    } finally {
        // runtime =
        // Ints.checkedCast(TimeUnit.NANOSECONDS.toMillis(executing.stopTask(projectBuild.getId())));

        log("Completed servicing " + project.getName() + " : " + (System.currentTimeMillis() - projectStopwatch)
                + " (ms).");
    }
}

From source file:io.takari.maven.builder.smart.SmartBuilderImpl.java

License:Apache License

private void printReadyQueue(Collection<MavenProject> readyQueue) {
    if (isProfiling() && !readyQueue.isEmpty()) {
        log("================================");
        for (MavenProject project : readyQueue) {
            log(project.getName());
        }/*from ww  w  . jav  a  2s  .  co  m*/
        log("--------------------------------");
    }
}

From source file:ms.dew.devops.kernel.config.ConfigBuilder.java

License:Apache License

private static FinalProjectConfig doBuildProject(DewConfig dewConfig, AppKindPlugin appKindPlugin,
        DeployPlugin deployPlugin, MavenProject mavenProject, String inputProfile, String inputDockerHost,
        String inputDockerRegistryUrl, String inputDockerRegistryUserName, String inputDockerRegistryPassword,
        String inputKubeBase64Config, Optional<String> dockerHostAppendOpt,
        Optional<String> dockerRegistryUrlAppendOpt, Optional<String> dockerRegistryUserNameAppendOpt,
        Optional<String> dockerRegistryPasswordAppendOpt, Optional<String> kubeBase64ConfigAppendOpt)
        throws InvocationTargetException, IllegalAccessException {
    FinalProjectConfig finalProjectConfig = new FinalProjectConfig();
    if (inputProfile.equalsIgnoreCase(FLAG_DEW_DEVOPS_DEFAULT_PROFILE)) {
        $.bean.copyProperties(finalProjectConfig, dewConfig);
    } else {/*from   www  .  j  a  v a  2s.  co  m*/
        $.bean.copyProperties(finalProjectConfig, dewConfig.getProfiles().get(inputProfile));
    }
    // setting basic
    finalProjectConfig.setId(mavenProject.getId());
    finalProjectConfig.setAppKindPlugin(appKindPlugin);
    finalProjectConfig.setDeployPlugin(deployPlugin);
    finalProjectConfig.setProfile(inputProfile);
    finalProjectConfig.setAppGroup(mavenProject.getGroupId());
    finalProjectConfig.setAppName(mavenProject.getArtifactId());
    finalProjectConfig.setSkip(false);
    if (mavenProject.getName() != null && !mavenProject.getName().trim().isEmpty()) {
        finalProjectConfig.setAppShowName(mavenProject.getName());
    } else {
        finalProjectConfig.setAppShowName(mavenProject.getArtifactId());
    }
    // ?
    if (inputDockerHost != null && !inputDockerHost.trim().isEmpty()) {
        finalProjectConfig.getDocker().setHost(inputDockerHost.trim());
    }
    if (inputDockerRegistryUrl != null && !inputDockerRegistryUrl.trim().isEmpty()) {
        finalProjectConfig.getDocker().setRegistryUrl(inputDockerRegistryUrl.trim());
    }
    if (inputDockerRegistryUserName != null && !inputDockerRegistryUserName.trim().isEmpty()) {
        finalProjectConfig.getDocker().setRegistryUserName(inputDockerRegistryUserName.trim());
    }
    if (inputDockerRegistryPassword != null && !inputDockerRegistryPassword.trim().isEmpty()) {
        finalProjectConfig.getDocker().setRegistryPassword(inputDockerRegistryPassword.trim());
    }
    if (inputKubeBase64Config != null && !inputKubeBase64Config.trim().isEmpty()) {
        finalProjectConfig.getKube().setBase64Config(inputKubeBase64Config.trim());
    }

    // setting path
    finalProjectConfig.setDirectory(mavenProject.getBasedir().getPath() + File.separator);
    finalProjectConfig.setTargetDirectory(finalProjectConfig.getDirectory() + "target" + File.separator);

    // setting git info
    finalProjectConfig.setScmUrl(GitHelper.inst().getScmUrl());
    finalProjectConfig.setGitCommit(GitHelper.inst().getCurrentCommit());
    finalProjectConfig.setImageVersion(finalProjectConfig.getGitCommit());
    finalProjectConfig.setAppVersion(finalProjectConfig.getGitCommit());

    // setting custom config by app kind
    finalProjectConfig.getAppKindPlugin().customConfig(finalProjectConfig);
    // setting reuse version
    fillReuseVersionInfo(finalProjectConfig, dewConfig, dockerHostAppendOpt, dockerRegistryUrlAppendOpt,
            dockerRegistryUserNameAppendOpt, dockerRegistryPasswordAppendOpt, kubeBase64ConfigAppendOpt);
    return finalProjectConfig;
}

From source file:net.dynamic_tools.maven.plugin.javascript.util.JavaScriptArchiver.java

License:Apache License

public void createDefaultManifest(MavenProject project)
        throws ManifestException, IOException, ArchiverException {
    Manifest manifest = new Manifest();
    Manifest.Attribute attr = new Manifest.Attribute("Created-By", "Apache Maven");
    manifest.addConfiguredAttribute(attr);
    attr = new Manifest.Attribute("Implementation-Title", project.getName());
    manifest.addConfiguredAttribute(attr);
    attr = new Manifest.Attribute("Implementation-Version", project.getVersion());
    manifest.addConfiguredAttribute(attr);
    attr = new Manifest.Attribute("Implementation-Vendor-Id", project.getGroupId());
    manifest.addConfiguredAttribute(attr);
    if (project.getOrganization() != null) {
        String vendor = project.getOrganization().getName();
        attr = new Manifest.Attribute("Implementation-Vendor", vendor);
        manifest.addConfiguredAttribute(attr);
    }//w w w  . ja v  a 2 s .  c  o m
    attr = new Manifest.Attribute("Built-By", System.getProperty("user.name"));
    manifest.addConfiguredAttribute(attr);

    File mf = File.createTempFile("maven", ".mf");
    mf.deleteOnExit();
    PrintWriter writer = new PrintWriter(new FileWriter(mf));
    manifest.write(writer);
    writer.close();
    setManifest(mf);
}

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

License:Apache License

@Override
public void projectStarted(ExecutionEvent event) {
    MavenProject project;
    Artifact projectArtifact;//from  ww  w  . j av a  2  s  .  com
    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.timandersen.StopTimer.java

License:Apache License

public void execute() throws MojoExecutionException {
    try {/*  ww  w  .j  a va2  s .  c  o  m*/
        String computername = InetAddress.getLocalHost().getHostName();
        MavenProject proj = (MavenProject) getPluginContext().get("project");
        long elapsedTime = Stopwatch.elapsedTime();
        String reportUrlWithParams = reportUrl + "/" + computername + "/" + proj.getName() + "/"
                + proj.getVersion() + "/" + elapsedTime;

        getLog().info("##### Stopping timer! Elapsed Time (" + elapsedTime + " ms)");
        getLog().info(reportUrlWithParams);

        if (reportUrl != null && !reportUrl.equals("")) {
            new HttpClient().executeMethod(new GetMethod(reportUrlWithParams));
        }

    } catch (Exception e) {
        getLog().error("Exception caught =" + e.getMessage());
    }
}