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

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

Introduction

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

Prototype

public String getDescription() 

Source Link

Usage

From source file:org.hsc.novelSpider.bundleplugin.BundlePlugin.java

License:Apache License

protected Properties getDefaultProperties(MavenProject currentProject) {
    Properties properties = new Properties();

    String bsn;//from  w ww.ja  va  2  s  .  c om
    try {
        bsn = getMaven2OsgiConverter().getBundleSymbolicName(currentProject.getArtifact());
    } catch (Exception e) {
        bsn = currentProject.getGroupId() + "." + currentProject.getArtifactId();
    }

    // Setup defaults
    properties.put(MAVEN_SYMBOLICNAME, bsn);
    properties.put(Analyzer.BUNDLE_SYMBOLICNAME, bsn);
    properties.put(Analyzer.IMPORT_PACKAGE, "*");
    properties.put(Analyzer.BUNDLE_VERSION, getMaven2OsgiConverter().getVersion(currentProject.getVersion()));

    // remove the extraneous Include-Resource and Private-Package entries from generated manifest
    properties.put(Constants.REMOVEHEADERS, Analyzer.INCLUDE_RESOURCE + ',' + Analyzer.PRIVATE_PACKAGE);

    header(properties, Analyzer.BUNDLE_DESCRIPTION, currentProject.getDescription());
    StringBuffer licenseText = printLicenses(currentProject.getLicenses());
    if (licenseText != null) {
        header(properties, Analyzer.BUNDLE_LICENSE, licenseText);
    }
    header(properties, Analyzer.BUNDLE_NAME, currentProject.getName());

    if (currentProject.getOrganization() != null) {
        if (currentProject.getOrganization().getName() != null) {
            String organizationName = currentProject.getOrganization().getName();
            header(properties, Analyzer.BUNDLE_VENDOR, organizationName);
            properties.put("project.organization.name", organizationName);
            properties.put("pom.organization.name", organizationName);
        }
        if (currentProject.getOrganization().getUrl() != null) {
            String organizationUrl = currentProject.getOrganization().getUrl();
            header(properties, Analyzer.BUNDLE_DOCURL, organizationUrl);
            properties.put("project.organization.url", organizationUrl);
            properties.put("pom.organization.url", organizationUrl);
        }
    }

    properties.putAll(currentProject.getProperties());
    properties.putAll(currentProject.getModel().getProperties());
    if (m_mavenSession != null) {
        try {
            // don't pass upper-case session settings to bnd as they end up in the manifest
            Properties sessionProperties = m_mavenSession.getExecutionProperties();
            for (Enumeration e = sessionProperties.propertyNames(); e.hasMoreElements();) {
                String key = (String) e.nextElement();
                if (key.length() > 0 && !Character.isUpperCase(key.charAt(0))) {
                    properties.put(key, sessionProperties.getProperty(key));
                }
            }
        } catch (Exception e) {
            getLog().warn("Problem with Maven session properties: " + e.getLocalizedMessage());
        }
    }

    properties.putAll(getProperties(currentProject.getModel(), "project.build."));
    properties.putAll(getProperties(currentProject.getModel(), "pom."));
    properties.putAll(getProperties(currentProject.getModel(), "project."));

    properties.put("project.baseDir", getBase(currentProject));
    properties.put("project.build.directory", getBuildDirectory());
    properties.put("project.build.outputdirectory", getOutputDirectory());

    properties.put("classifier", classifier == null ? "" : classifier);

    getLog().info("BlueprintPlugin");
    // Add default plugins
    header(properties, Analyzer.PLUGIN, SpringXMLType.class.getName());
    //header( properties, Analyzer.PLUGIN, BlueprintPlugin.class.getName() + "," + SpringXMLType.class.getName() );

    return properties;
}

From source file:org.javagems.core.maven.DebianMojo.java

License:Apache License

/**
 * Copy properties from the maven project to the ant project.
 *
 * @param mavenProject//from w ww . j av a2s.com
 * @param antProject
 */
public void copyProperties(MavenProject mavenProject, Project antProject) {
    Properties mavenProps = mavenProject.getProperties();
    Iterator iter = mavenProps.keySet().iterator();
    while (iter.hasNext()) {
        String key = (String) iter.next();
        antProject.setProperty(key, mavenProps.getProperty(key));
    }

    // Set the POM file as the ant.file for the tasks run directly in Maven.
    antProject.setProperty("ant.file", mavenProject.getFile().getAbsolutePath());

    // Add some of the common maven properties
    getLog().debug("Setting properties with prefix: " + propertyPrefix);
    antProject.setProperty((propertyPrefix + "project.groupId"), mavenProject.getGroupId());
    antProject.setProperty((propertyPrefix + "project.artifactId"), mavenProject.getArtifactId());
    antProject.setProperty((propertyPrefix + "project.name"), mavenProject.getName());
    if (mavenProject.getDescription() != null) {
        antProject.setProperty((propertyPrefix + "project.description"), mavenProject.getDescription());
    }
    antProject.setProperty((propertyPrefix + "project.version"), mavenProject.getVersion());
    antProject.setProperty((propertyPrefix + "project.packaging"), mavenProject.getPackaging());
    antProject.setProperty((propertyPrefix + "project.build.directory"),
            mavenProject.getBuild().getDirectory());
    antProject.setProperty((propertyPrefix + "project.build.outputDirectory"),
            mavenProject.getBuild().getOutputDirectory());
    antProject.setProperty((propertyPrefix + "project.build.testOutputDirectory"),
            mavenProject.getBuild().getTestOutputDirectory());
    antProject.setProperty((propertyPrefix + "project.build.sourceDirectory"),
            mavenProject.getBuild().getSourceDirectory());
    antProject.setProperty((propertyPrefix + "project.build.testSourceDirectory"),
            mavenProject.getBuild().getTestSourceDirectory());
    antProject.setProperty((propertyPrefix + "localRepository"), localRepository.toString());
    antProject.setProperty((propertyPrefix + "settings.localRepository"), localRepository.getBasedir());

    // Add properties for depenedency artifacts
    Set depArtifacts = mavenProject.getArtifacts();
    for (Iterator it = depArtifacts.iterator(); it.hasNext();) {
        Artifact artifact = (Artifact) it.next();

        String propName = artifact.getDependencyConflictId();

        antProject.setProperty(propertyPrefix + propName, artifact.getFile().getPath());
    }

    // Add a property containing the list of versions for the mapper
    StringBuffer versionsBuffer = new StringBuffer();
    for (Iterator it = depArtifacts.iterator(); it.hasNext();) {
        Artifact artifact = (Artifact) it.next();

        versionsBuffer.append(artifact.getVersion() + File.pathSeparator);
    }
    antProject.setProperty(versionsPropertyName, versionsBuffer.toString());
}

From source file:org.nuxeo.build.swing.tree.ItemProvider.java

License:Open Source License

public String getInfo(Node node) {
    String id = node.getId().substring(0, node.getId().length() - 1);
    Collection<Edge> edgesIn = node.getEdgesIn();
    String scopes = null;/* ww  w.j  av a 2  s .  com*/
    if (edgesIn != null && !edgesIn.isEmpty()) {
        scopes = "<br>";
        for (Edge edge : edgesIn) {
            scopes += "&nbsp;&nbsp;<dd>" + edge.in.getArtifact().getArtifactId() + ": <strong><i>"
                    + (edge.scope == null ? "compile" : edge.scope) + "</i></strong></dd><br>";
        }
        // scopes+="</ul>";
    } else {
        scopes = "N/A";
    }
    MavenProject pom = node.getPomIfAlreadyLoaded();
    String desc = null;
    if (pom != null) {
        desc = "<i>" + pom.getDescription() + "</i>";
        String href = pom.getUrl();
        String fileRef = null;
        try {
            fileRef = node.getFile().toURI().toURL().toExternalForm();
        } catch (Exception e) {
            fileRef = "file:/" + node.getFile().getAbsolutePath();
        }
        desc += "<p><b>Url:</b> " + href + "<br><b>File:</b> <a href=\"" + fileRef + "\">" + node.getFile()
                + "</a></p>";
    } else {
        desc = "<i><font color=\"light-gray\">Pom not loaded. Enter the artifact to load it.</font></i>";
    }
    return "<html><body><b>Artifact: </b> " + id + "<br><b>Scopes: </b>" + scopes + "<p>" + desc
            + "</p></body></html>";
}

From source file:org.openmrs.maven.plugins.bintray.OpenmrsBintray.java

public BintrayPackage createPackage(MavenProject mavenProject, String repository) {
    CreatePackageRequest request = new CreatePackageRequest();
    request.setName(mavenProject.getArtifactId());
    request.setDescription(mavenProject.getDescription());

    String githubUrl = mavenProject.getScm().getUrl();
    if (githubUrl.endsWith("/"))
        githubUrl = StringUtils.stripEnd(githubUrl, "/");
    String githubRepo = githubUrl.substring(githubUrl.lastIndexOf("/")).replace(".git", "");
    request.setVcsUrl(githubUrl + (githubUrl.endsWith(".git") ? "" : ".git"));
    request.setGithubRepo(OPENMRS_USERNAME + githubRepo);
    request.setWebsiteUrl("http://openmrs.org/");

    request.setIssueTrackerUrl(new DefaultJira().getJiraUrl());
    //so far all OpenMRS projects have MPL-2.0 license
    request.setLicenses(Arrays.asList("MPL-2.0"));
    return createPackage(OPENMRS_USERNAME, repository, request);
}

From source file:org.overlord.sramp.integration.java.artifactbuilder.MavenPomArtifactBuilder.java

License:Apache License

@Override
public ArtifactBuilder buildArtifacts(BaseArtifactType primaryArtifact, ArtifactContent artifactContent)
        throws IOException {
    super.buildArtifacts(primaryArtifact, artifactContent);

    try {/*  www  .  ja  va  2  s. c  o m*/
        Model model = new MavenXpp3Reader().read(getContentStream());
        MavenProject project = new MavenProject(model);
        ((ExtendedDocument) primaryArtifact).setExtendedType(JavaModel.TYPE_MAVEN_POM_XML);
        for (String key : project.getProperties().stringPropertyNames()) {
            String value = project.getProperties().getProperty(key);
            SrampModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_PROPERTY + key, value);
        }
        //set core properties when not specified on the request
        if (primaryArtifact.getDescription() == null)
            primaryArtifact.setDescription(project.getDescription());
        if (primaryArtifact.getName() == null)
            primaryArtifact.setName(project.getName());
        if (primaryArtifact.getVersion() == null)
            primaryArtifact.setVersion(project.getVersion());
        //set the GAV and packaging info
        SrampModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_ARTIFACT_ID,
                model.getArtifactId());
        SrampModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_GROUP_ID, model.getGroupId());
        SrampModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_VERSION, model.getVersion());
        SrampModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_PACKAGING,
                model.getPackaging());
        //set the parent GAV info
        if (model.getParent() != null) {
            SrampModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_PARENT_ARTIFACT_ID,
                    model.getParent().getArtifactId());
            SrampModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_PARENT_GROUP_ID,
                    model.getParent().getGroupId());
            SrampModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_PARENT_VERSION,
                    model.getParent().getVersion());
        }

        return this;
    } catch (XmlPullParserException e) {
        throw new IOException(e.getMessage(), e);
    }
}

From source file:org.overlord.sramp.integration.java.deriver.MavenPomDeriver.java

License:Apache License

/**
 * @see org.overlord.sramp.common.derived.ArtifactDeriver#derive(org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactType, java.io.InputStream)
 *//*  ww w.  j av a2  s  . com*/
@Override
public Collection<BaseArtifactType> derive(BaseArtifactType artifact, InputStream contentStream)
        throws IOException {
    List<BaseArtifactType> derivedArtifacts = new ArrayList<BaseArtifactType>();
    try {
        Model model = new MavenXpp3Reader().read(contentStream);
        MavenProject project = new MavenProject(model);
        ((ExtendedDocument) artifact).setExtendedType(JavaModel.TYPE_MAVEN_POM_XML);
        for (String key : project.getProperties().stringPropertyNames()) {
            String value = project.getProperties().getProperty(key);
            SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_PROPERTY + key, value);
        }
        //set core properties when not specified on the request
        if (artifact.getDescription() == null)
            artifact.setDescription(project.getDescription());
        if (artifact.getName() == null)
            artifact.setName(project.getName());
        if (artifact.getVersion() == null)
            artifact.setVersion(project.getVersion());
        //set the GAV and packaging info
        SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_ARTIFACT_ID, model.getArtifactId());
        SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_GROUP_ID, model.getGroupId());
        SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_VERSION, model.getVersion());
        SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_PACKAGING, model.getPackaging());
        //set the parent GAV info
        if (model.getParent() != null) {
            SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_PARENT_ARTIFACT_ID,
                    model.getParent().getArtifactId());
            SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_PARENT_GROUP_ID,
                    model.getParent().getGroupId());
            SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_PARENT_VERSION,
                    model.getParent().getVersion());
        }
    } catch (XmlPullParserException e) {
        throw new IOException(e.getMessage(), e);
    }
    return derivedArtifacts;
}

From source file:org.sonar.batch.maven.MavenProjectConverter.java

License:Open Source License

@VisibleForTesting
void merge(MavenProject pom, ProjectDefinition definition) {
    String key = getSonarKey(pom);
    // IMPORTANT NOTE : reference on properties from POM model must not be saved,
    // instead they should be copied explicitly - see SONAR-2896
    definition.setProperties(pom.getModel().getProperties()).setKey(key).setVersion(pom.getVersion())
            .setName(pom.getName()).setDescription(pom.getDescription()).addContainerExtension(pom);
    guessJavaVersion(pom, definition);//from ww  w.j  a va  2  s.com
    guessEncoding(pom, definition);
    convertMavenLinksToProperties(definition, pom);
    synchronizeFileSystem(pom, definition);
}

From source file:org.sonar.batch.MavenProjectBuilder.java

License:Open Source License

public Project create(MavenProject pom) {
    Configuration configuration = getStartupConfiguration(pom);
    return new Project(loadProjectKey(pom), loadProjectBranch(configuration), pom.getName()).setPom(pom)
            .setDescription(pom.getDescription()).setPackaging(pom.getPackaging());
}

From source file:org.sonar.batch.MavenProjectConverter.java

License:Open Source License

/**
 * Visibility has been relaxed for tests.
 *//*  www  .j av a  2  s .c o  m*/
static ProjectDefinition convert(MavenProject pom) {
    String key = new StringBuilder().append(pom.getGroupId()).append(":").append(pom.getArtifactId())
            .toString();
    ProjectDefinition definition = ProjectDefinition.create(pom.getModel().getProperties());
    definition.setKey(key).setVersion(pom.getVersion()).setName(pom.getName())
            .setDescription(pom.getDescription()).addContainerExtension(pom);
    synchronizeFileSystem(pom, definition);
    return definition;
}

From source file:org.sonar.batch.scan.maven.MavenProjectConverter.java

License:Open Source License

@VisibleForTesting
static ProjectDefinition convert(MavenProject pom) {
    String key = new StringBuilder().append(pom.getGroupId()).append(":").append(pom.getArtifactId())
            .toString();/*  w  w  w.j  a va2 s.com*/
    ProjectDefinition definition = ProjectDefinition.create();
    // IMPORTANT NOTE : reference on properties from POM model must not be saved,
    // instead they should be copied explicitly - see SONAR-2896
    definition.setProperties(pom.getModel().getProperties()).setKey(key).setVersion(pom.getVersion())
            .setName(pom.getName()).setDescription(pom.getDescription()).addContainerExtension(pom);
    guessJavaVersion(pom, definition);
    guessEncoding(pom, definition);
    convertMavenLinksToProperties(definition, pom);
    synchronizeFileSystem(pom, definition);
    return definition;
}