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

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

Introduction

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

Prototype

public List<String> getFilters() 

Source Link

Usage

From source file:org.wisdom.maven.utils.MavenUtils.java

License:Apache License

/**
 * Gets the default set of properties for the given project.
 *
 * @param currentProject the project//  ww w.jav a2s.  c o  m
 * @return the set of properties, containing default bundle packaging instructions.
 */
public static Properties getDefaultProperties(MavenProject currentProject) {
    Properties properties = new Properties();
    String bsn = DefaultMaven2OsgiConverter.getBundleSymbolicName(currentProject.getArtifact());

    // Setup defaults
    properties.put(MAVEN_SYMBOLICNAME, bsn);
    properties.put("bundle.file.name",
            DefaultMaven2OsgiConverter.getBundleFileName(currentProject.getArtifact()));
    properties.put(Analyzer.BUNDLE_SYMBOLICNAME, bsn);
    properties.put(Analyzer.IMPORT_PACKAGE, "*");
    properties.put(Analyzer.BUNDLE_VERSION, DefaultMaven2OsgiConverter.getVersion(currentProject.getVersion()));

    header(properties, Analyzer.BUNDLE_DESCRIPTION, currentProject.getDescription());
    StringBuilder 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.getModel().getProperties());

    for (String s : currentProject.getFilters()) {
        File filterFile = new File(s);
        if (filterFile.isFile()) {
            properties.putAll(PropertyUtils.loadProperties(filterFile));
        }
    }

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

    properties.put("project.baseDir", currentProject.getBasedir().getAbsolutePath());
    properties.put("project.build.directory", currentProject.getBuild().getDirectory());
    properties.put("project.build.outputdirectory", currentProject.getBuild().getOutputDirectory());

    properties.put("project.source.roots", getArray(currentProject.getCompileSourceRoots()));
    properties.put("project.testSource.roots", getArray(currentProject.getTestCompileSourceRoots()));

    properties.put("project.resources", toString(currentProject.getResources()));
    properties.put("project.testResources", toString(currentProject.getTestResources()));

    return properties;
}