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:net.ubos.tools.pacmanpkgmavenplugin.PacmanPkgMavenPlugin.java

License:Open Source License

/**
 * {@inheritDoc}/*w  w w .java  2s .  com*/
 * 
 * @throws MojoExecutionException
 */
@Override
public void execute() throws MojoExecutionException {
    MavenProject project = (MavenProject) getPluginContext().get("project");
    String packaging = project.getPackaging();

    if (!"jar".equals(packaging) && !"ear".equals(packaging) && !"war".equals(packaging)) {
        return;
    }

    getLog().info("Generating PKGBUILD @ " + project.getName());

    // pull stuff out of MavenProject
    String artifactId = project.getArtifactId();
    String version = project.getVersion();
    String url = project.getUrl();
    String description = project.getDescription();
    Set<Artifact> dependencies = project.getDependencyArtifacts();
    File artifactFile = project.getArtifact().getFile();

    if (artifactFile == null || !artifactFile.exists()) {
        throw new MojoExecutionException("pacmanpkg must be executed as part of a build, not standalone,"
                + " otherwise it can't find the main JAR file");
    }
    // translate to PKGBUILD fields
    String pkgname = artifactId;
    String pkgver = version.replaceAll("-SNAPSHOT", "a"); // alpha
    String pkgdesc = "A Java package available on UBOS";
    if (description != null) {
        if (description.length() > 64) {
            pkgdesc = description.substring(0, 64) + "...";
        } else {
            pkgdesc = description;
        }
    }

    ArrayList<String> depends = new ArrayList<>(dependencies.size());
    for (Artifact a : dependencies) {
        if (!"test".equals(a.getScope())) {
            depends.add(a.getArtifactId());
        }
    }
    // write to PKGBUILD
    try {
        File baseDir = project.getBasedir();
        File pkgBuild = new File(baseDir, "target/PKGBUILD");
        PrintWriter out = new PrintWriter(pkgBuild);

        getLog().debug("Writing PKGBUILD to " + pkgBuild.getAbsolutePath());

        out.println("#");
        out.println(" * Automatically generated by pacman-pkg-maven-plugin; do not modify.");
        out.println("#");

        out.println();

        out.println("pkgname=" + pkgname);
        out.println("pkgver=" + pkgver);
        out.println("pkgrel=" + pkgrel);
        out.println("pkgdesc='" + pkgdesc + "'");
        out.println("arch=('any')");
        out.println("url='" + url + "'");
        out.println("license=('" + license + "')");

        out.print("depends=(");
        String sep = "";
        for (String d : depends) {
            out.print(sep);
            sep = ",";
            out.print("'");
            out.print(d);
            out.print("'");
        }
        out.println(")");

        out.println();

        out.println("package() (");
        out.println("   mkdir -p ${pkgdir}/usr/share/java");
        out.println("   install -m644 ${startdir}/" + artifactFile.getName() + " ${pkgdir}/usr/share/java/");
        out.println(")");

        out.close();

    } catch (IOException ex) {
        throw new MojoExecutionException("Failed to write target/PKGBUILD", ex);
    }
}

From source file:npanday.assembler.impl.AssemblerContextImpl.java

License:Apache License

public AssemblyInfo getAssemblyInfo(MavenProject mavenProject) {
    String basedir = mavenProject.getBasedir().toString();
    AssemblyInfo assemblyInfo = new AssemblyInfo();
    String description = (mavenProject.getDescription() != null) ? mavenProject.getDescription() : "";
    String version = (mavenProject.getVersion() != null) ? mavenProject.getVersion() : "";
    String name = mavenProject.getName();
    Organization org = mavenProject.getOrganization();
    String company = (org != null) ? org.getName() : "";
    String copyright = "";
    String informationalVersion = "";
    String configuration = "";

    File file = new File(basedir + "/COPYRIGHT.txt");
    if (file.exists()) {
        logger.debug("NPANDAY-020-000: Found Copyright: " + file.getAbsolutePath());
        FileInputStream fis = null;
        try {//  w  w w  .  j  av a2  s.  c  o  m
            fis = new FileInputStream(file);
            copyright = IOUtil.toString(fis).replace("\r", " ").replace("\n", " ").replace("\"", "'");
        } catch (IOException e) {
            logger.info("NPANDAY-020-001: Could not get copyright: File = " + file.getAbsolutePath(), e);
        } finally {
            if (fis != null) {
                IOUtil.close(fis);
            }
        }
    }
    informationalVersion = version;
    if (version.contains("-")) {
        version = version.split("-")[0];
    }
    assemblyInfo.setCompany(company);
    assemblyInfo.setCopyright(copyright);
    assemblyInfo.setCulture("");
    assemblyInfo.setDescription(description);
    assemblyInfo.setProduct(company + "-" + name);
    assemblyInfo.setTitle(name);
    assemblyInfo.setTrademark("");
    assemblyInfo.setInformationalVersion(informationalVersion);
    assemblyInfo.setVersion(version);
    assemblyInfo.setConfiguration(configuration);

    return assemblyInfo;
}

From source file:org.apache.camel.maven.packaging.PackageComponentMojo.java

License:Apache License

public static void prepareComponent(Log log, MavenProject project, MavenProjectHelper projectHelper,
        File componentOutDir) throws MojoExecutionException {
    File camelMetaDir = new File(componentOutDir, "META-INF/services/org/apache/camel/");

    StringBuilder buffer = new StringBuilder();
    int count = 0;
    for (Resource r : project.getBuild().getResources()) {
        File f = new File(r.getDirectory());
        if (!f.exists()) {
            f = new File(project.getBasedir(), r.getDirectory());
        }//from  w w w .  j  av a 2s .  c o m
        f = new File(f, "META-INF/services/org/apache/camel/component");

        if (f.exists() && f.isDirectory()) {
            File[] files = f.listFiles();
            if (files != null) {
                for (File file : files) {
                    // skip directories as there may be a sub .resolver directory
                    if (file.isDirectory()) {
                        continue;
                    }
                    String name = file.getName();
                    if (name.charAt(0) != '.') {
                        count++;
                        if (buffer.length() > 0) {
                            buffer.append(" ");
                        }
                        buffer.append(name);
                    }
                }
            }
        }
    }

    if (count > 0) {
        Properties properties = new Properties();
        String names = buffer.toString();
        properties.put("components", names);
        properties.put("groupId", project.getGroupId());
        properties.put("artifactId", project.getArtifactId());
        properties.put("version", project.getVersion());
        properties.put("projectName", project.getName());
        if (project.getDescription() != null) {
            properties.put("projectDescription", project.getDescription());
        }

        camelMetaDir.mkdirs();
        File outFile = new File(camelMetaDir, "component.properties");
        try {
            properties.store(new FileWriter(outFile), "Generated by camel-package-maven-plugin");
            log.info("Generated " + outFile + " containing " + count + " Camel "
                    + (count > 1 ? "components: " : "component: ") + names);

            if (projectHelper != null) {
                List<String> includes = new ArrayList<String>();
                includes.add("**/component.properties");
                projectHelper.addResource(project, componentOutDir.getPath(), includes,
                        new ArrayList<String>());
                projectHelper.attachArtifact(project, "properties", "camelComponent", outFile);
            }
        } catch (IOException e) {
            throw new MojoExecutionException("Failed to write properties to " + outFile + ". Reason: " + e, e);
        }
    } else {
        log.debug(
                "No META-INF/services/org/apache/camel/component directory found. Are you sure you have created a Camel component?");
    }
}

From source file:org.apache.camel.maven.packaging.PackageDataFormatMojo.java

License:Apache License

public static void prepareDataFormat(Log log, MavenProject project, MavenProjectHelper projectHelper,
        File dataFormatOutDir, File schemaOutDir) throws MojoExecutionException {
    File camelMetaDir = new File(dataFormatOutDir, "META-INF/services/org/apache/camel/");

    Map<String, String> javaTypes = new HashMap<String, String>();

    StringBuilder buffer = new StringBuilder();
    int count = 0;
    for (Resource r : project.getBuild().getResources()) {
        File f = new File(r.getDirectory());
        if (!f.exists()) {
            f = new File(project.getBasedir(), r.getDirectory());
        }//  w w  w. jav  a  2  s  . c o  m
        f = new File(f, "META-INF/services/org/apache/camel/dataformat");

        if (f.exists() && f.isDirectory()) {
            File[] files = f.listFiles();
            if (files != null) {
                for (File file : files) {
                    // skip directories as there may be a sub .resolver directory
                    if (file.isDirectory()) {
                        continue;
                    }
                    String name = file.getName();
                    if (name.charAt(0) != '.') {
                        count++;
                        if (buffer.length() > 0) {
                            buffer.append(" ");
                        }
                        buffer.append(name);
                    }

                    // find out the javaType for each data format
                    try {
                        String text = loadText(new FileInputStream(file));
                        Map<String, String> map = parseAsMap(text);
                        String javaType = map.get("class");
                        if (javaType != null) {
                            javaTypes.put(name, javaType);
                        }
                    } catch (IOException e) {
                        throw new MojoExecutionException("Failed to read file " + file + ". Reason: " + e, e);
                    }
                }
            }
        }
    }

    // find camel-core and grab the data format model from there, and enrich this model with information from this artifact
    // and create json schema model file for this data format
    try {
        if (count > 0) {
            Artifact camelCore = findCamelCoreArtifact(project);
            if (camelCore != null) {
                File core = camelCore.getFile();
                if (core != null) {
                    URL url = new URL("file", null, core.getAbsolutePath());
                    URLClassLoader loader = new URLClassLoader(new URL[] { url });
                    for (Map.Entry<String, String> entry : javaTypes.entrySet()) {
                        String name = entry.getKey();
                        String javaType = entry.getValue();
                        String modelName = asModelName(name);

                        InputStream is = loader.getResourceAsStream(
                                "org/apache/camel/model/dataformat/" + modelName + ".json");
                        if (is == null) {
                            // use file input stream if we build camel-core itself, and thus do not have a JAR which can be loaded by URLClassLoader
                            is = new FileInputStream(
                                    new File(core, "org/apache/camel/model/dataformat/" + modelName + ".json"));
                        }
                        String json = loadText(is);
                        if (json != null) {
                            DataFormatModel dataFormatModel = new DataFormatModel();
                            dataFormatModel.setName(name);
                            dataFormatModel.setTitle("");
                            dataFormatModel.setModelName(modelName);
                            dataFormatModel.setLabel("");
                            dataFormatModel.setDescription(project.getDescription());
                            dataFormatModel.setJavaType(javaType);
                            dataFormatModel.setGroupId(project.getGroupId());
                            dataFormatModel.setArtifactId(project.getArtifactId());
                            dataFormatModel.setVersion(project.getVersion());

                            List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("model", json,
                                    false);
                            for (Map<String, String> row : rows) {
                                if (row.containsKey("title")) {
                                    String title = row.get("title");
                                    dataFormatModel.setTitle(asModelTitle(name, title));
                                }
                                if (row.containsKey("label")) {
                                    dataFormatModel.setLabel(row.get("label"));
                                }
                                if (row.containsKey("javaType")) {
                                    dataFormatModel.setModelJavaType(row.get("javaType"));
                                }
                                // override description for camel-core, as otherwise its too generic
                                if ("camel-core".equals(project.getArtifactId())) {
                                    if (row.containsKey("description")) {
                                        dataFormatModel.setLabel(row.get("description"));
                                    }
                                }
                            }
                            log.debug("Model " + dataFormatModel);

                            // build json schema for the data format
                            String properties = after(json, "  \"properties\": {");
                            String schema = createParameterJsonSchema(dataFormatModel, properties);
                            log.debug("JSon schema\n" + schema);

                            // write this to the directory
                            File dir = new File(schemaOutDir,
                                    schemaSubDirectory(dataFormatModel.getJavaType()));
                            dir.mkdirs();

                            File out = new File(dir, name + ".json");
                            FileOutputStream fos = new FileOutputStream(out, false);
                            fos.write(schema.getBytes());
                            fos.close();

                            log.debug("Generated " + out + " containing JSon schema for " + name
                                    + " data format");
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        throw new MojoExecutionException("Error loading dataformat model from camel-core. Reason: " + e, e);
    }

    if (count > 0) {
        Properties properties = new Properties();
        String names = buffer.toString();
        properties.put("dataFormats", names);
        properties.put("groupId", project.getGroupId());
        properties.put("artifactId", project.getArtifactId());
        properties.put("version", project.getVersion());
        properties.put("projectName", project.getName());
        if (project.getDescription() != null) {
            properties.put("projectDescription", project.getDescription());
        }

        camelMetaDir.mkdirs();
        File outFile = new File(camelMetaDir, "dataformat.properties");
        try {
            properties.store(new FileWriter(outFile), "Generated by camel-package-maven-plugin");
            log.info("Generated " + outFile + " containing " + count + " Camel "
                    + (count > 1 ? "dataformats: " : "dataformat: ") + names);

            if (projectHelper != null) {
                List<String> includes = new ArrayList<String>();
                includes.add("**/dataformat.properties");
                projectHelper.addResource(project, dataFormatOutDir.getPath(), includes,
                        new ArrayList<String>());
                projectHelper.attachArtifact(project, "properties", "camelDataFormat", outFile);
            }
        } catch (IOException e) {
            throw new MojoExecutionException("Failed to write properties to " + outFile + ". Reason: " + e, e);
        }
    } else {
        log.debug(
                "No META-INF/services/org/apache/camel/dataformat directory found. Are you sure you have created a Camel data format?");
    }
}

From source file:org.apache.camel.maven.packaging.PackageLanguageMojo.java

License:Apache License

public static void prepareLanguage(Log log, MavenProject project, MavenProjectHelper projectHelper,
        File languageOutDir, File schemaOutDir) throws MojoExecutionException {
    File camelMetaDir = new File(languageOutDir, "META-INF/services/org/apache/camel/");

    Map<String, String> javaTypes = new HashMap<String, String>();

    StringBuilder buffer = new StringBuilder();
    int count = 0;
    for (Resource r : project.getBuild().getResources()) {
        File f = new File(r.getDirectory());
        if (!f.exists()) {
            f = new File(project.getBasedir(), r.getDirectory());
        }//from w  w  w .j  a  v a 2 s.c  om
        f = new File(f, "META-INF/services/org/apache/camel/language");

        if (f.exists() && f.isDirectory()) {
            File[] files = f.listFiles();
            if (files != null) {
                for (File file : files) {
                    // skip directories as there may be a sub .resolver directory such as in camel-script
                    if (file.isDirectory()) {
                        continue;
                    }
                    String name = file.getName();
                    if (name.charAt(0) != '.') {
                        count++;
                        if (buffer.length() > 0) {
                            buffer.append(" ");
                        }
                        buffer.append(name);
                    }

                    // find out the javaType for each data format
                    try {
                        String text = loadText(new FileInputStream(file));
                        Map<String, String> map = parseAsMap(text);
                        String javaType = map.get("class");
                        if (javaType != null) {
                            javaTypes.put(name, javaType);
                        }
                    } catch (IOException e) {
                        throw new MojoExecutionException("Failed to read file " + file + ". Reason: " + e, e);
                    }
                }
            }
        }
    }

    // find camel-core and grab the data format model from there, and enrich this model with information from this artifact
    // and create json schema model file for this data format
    try {
        if (count > 0) {
            Artifact camelCore = findCamelCoreArtifact(project);
            if (camelCore != null) {
                File core = camelCore.getFile();
                if (core != null) {
                    URL url = new URL("file", null, core.getAbsolutePath());
                    URLClassLoader loader = new URLClassLoader(new URL[] { url });
                    for (Map.Entry<String, String> entry : javaTypes.entrySet()) {
                        String name = entry.getKey();
                        String javaType = entry.getValue();
                        String modelName = asModelName(name);

                        InputStream is = loader
                                .getResourceAsStream("org/apache/camel/model/language/" + modelName + ".json");
                        if (is == null) {
                            // use file input stream if we build camel-core itself, and thus do not have a JAR which can be loaded by URLClassLoader
                            is = new FileInputStream(
                                    new File(core, "org/apache/camel/model/language/" + modelName + ".json"));
                        }
                        String json = loadText(is);
                        if (json != null) {
                            LanguageModel languageModel = new LanguageModel();
                            languageModel.setName(name);
                            languageModel.setTitle("");
                            languageModel.setModelName(modelName);
                            languageModel.setLabel("");
                            languageModel.setDescription("");
                            languageModel.setJavaType(javaType);
                            languageModel.setGroupId(project.getGroupId());
                            languageModel.setArtifactId(project.getArtifactId());
                            languageModel.setVersion(project.getVersion());

                            List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("model", json,
                                    false);
                            for (Map<String, String> row : rows) {
                                if (row.containsKey("title")) {
                                    languageModel.setTitle(row.get("title"));
                                }
                                if (row.containsKey("description")) {
                                    languageModel.setDescription(row.get("description"));
                                }
                                if (row.containsKey("label")) {
                                    languageModel.setLabel(row.get("label"));
                                }
                                if (row.containsKey("javaType")) {
                                    languageModel.setModelJavaType(row.get("javaType"));
                                }
                            }
                            log.debug("Model " + languageModel);

                            // build json schema for the data format
                            String properties = after(json, "  \"properties\": {");
                            String schema = createParameterJsonSchema(languageModel, properties);
                            log.debug("JSon schema\n" + schema);

                            // write this to the directory
                            File dir = new File(schemaOutDir, schemaSubDirectory(languageModel.getJavaType()));
                            dir.mkdirs();

                            File out = new File(dir, name + ".json");
                            FileOutputStream fos = new FileOutputStream(out, false);
                            fos.write(schema.getBytes());
                            fos.close();

                            log.debug("Generated " + out + " containing JSon schema for " + name + " language");
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        throw new MojoExecutionException("Error loading language model from camel-core. Reason: " + e, e);
    }

    if (count > 0) {
        Properties properties = new Properties();
        String names = buffer.toString();
        properties.put("languages", names);
        properties.put("groupId", project.getGroupId());
        properties.put("artifactId", project.getArtifactId());
        properties.put("version", project.getVersion());
        properties.put("projectName", project.getName());
        if (project.getDescription() != null) {
            properties.put("projectDescription", project.getDescription());
        }

        camelMetaDir.mkdirs();
        File outFile = new File(camelMetaDir, "language.properties");
        try {
            properties.store(new FileWriter(outFile), "Generated by camel-package-maven-plugin");
            log.info("Generated " + outFile + " containing " + count + " Camel "
                    + (count > 1 ? "languages: " : "language: ") + names);

            if (projectHelper != null) {
                List<String> includes = new ArrayList<String>();
                includes.add("**/language.properties");
                projectHelper.addResource(project, languageOutDir.getPath(), includes, new ArrayList<String>());
                projectHelper.attachArtifact(project, "properties", "camelLanguage", outFile);
            }
        } catch (IOException e) {
            throw new MojoExecutionException("Failed to write properties to " + outFile + ". Reason: " + e, e);
        }
    } else {
        log.debug(
                "No META-INF/services/org/apache/camel/language directory found. Are you sure you have created a Camel language?");
    }
}

From source file:org.apache.felix.bundleplugin.BundlePlugin.java

License:Apache License

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

    String bsn;//from ww  w .  jav a  2s  .c o m
    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(Analyzer.REMOVE_HEADERS, 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) {
        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());
    properties.putAll(getProperties(currentProject.getModel(), "project.build."));
    properties.putAll(getProperties(currentProject.getModel(), "pom."));
    properties.putAll(getProperties(currentProject.getModel(), "project."));
    properties.put("project.baseDir", baseDir);
    properties.put("project.build.directory", getBuildDirectory());
    properties.put("project.build.outputdirectory", getOutputDirectory());

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

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

    return properties;
}

From source file:org.apache.felix.obr.plugin.ResourcesBundle.java

License:Apache License

/**
 * this method gets information form pom.xml to complete missing data from those given by user.
 * @param project project information given by maven
 * @param ebi bundle information extracted from bindex
 * @return true/*from  w w w.jav a2 s.  c  o  m*/
 */
public boolean construct(MavenProject project, ExtractBindexInfo ebi) {

    if (ebi.getPresentationName() != null) {
        setPresentationName(ebi.getPresentationName());
        if (project.getName() != null) {
            m_logger.debug("pom property override:<presentationname> " + project.getName());
        }
    } else {
        setPresentationName(project.getName());
    }

    if (ebi.getSymbolicName() != null) {
        setSymbolicName(ebi.getSymbolicName());
        if (project.getArtifactId() != null) {
            m_logger.debug("pom property override:<symbolicname> " + project.getArtifactId());
        }
    } else {
        setSymbolicName(project.getArtifactId());
    }

    if (ebi.getVersion() != null) {
        setVersion(ebi.getVersion());
        if (project.getVersion() != null) {
            m_logger.debug("pom property override:<version> " + project.getVersion());
        }
    } else {
        setVersion(project.getVersion());
    }

    if (ebi.getId() != null) {
        setId(ebi.getId());
    }

    if (ebi.getDescription() != null) {
        setDescription(ebi.getDescription());
        if (project.getDescription() != null) {
            m_logger.debug("pom property override:<description> " + project.getDescription());
        }
    } else {
        setDescription(project.getDescription());
    }

    if (ebi.getDocumentation() != null) {
        setDocumentation(ebi.getDocumentation());
        if (project.getUrl() != null) {
            m_logger.debug("pom property override:<documentation> " + project.getUrl());
        }
    } else {
        setDocumentation(project.getUrl());
    }

    if (ebi.getSource() != null) {
        setSource(ebi.getSource());
        if (project.getScm() != null) {
            m_logger.debug("pom property override:<source> " + project.getScm());
        }
    } else {
        String src = null;
        if (project.getScm() != null) {
            src = project.getScm().getUrl();
        }
        setSource(src);
    }

    if (ebi.getLicense() != null) {
        setLicense(ebi.getLicense());
        String lic = null;
        List l = project.getLicenses();
        Iterator it = l.iterator();
        while (it.hasNext()) {
            if (it.next() != null) {
                m_logger.debug("pom property override:<license> " + lic);
                break;
            }
        }
    } else {
        String lic = null;
        List l = project.getLicenses();
        Iterator it = l.iterator();
        while (it.hasNext()) {
            lic = it.next() + ";";
        }

        setLicense(lic);
    }

    // create the first capability (ie : bundle)
    Capability capability = new Capability();
    capability.setName("bundle");
    PElement p = new PElement();
    p.setN("manifestversion");
    p.setV("2");
    capability.addP(p);

    p = new PElement();
    p.setN("presentationname");
    p.setV(getPresentationName());
    capability.addP(p);

    p = new PElement();
    p.setN("symbolicname");
    p.setV(getSymbolicName());
    capability.addP(p);

    p = new PElement();
    p.setN("version");
    p.setT("version");
    p.setV(getVersion());
    capability.addP(p);

    addCapability(capability);

    List capabilities = ebi.getCapabilities();
    for (int i = 0; i < capabilities.size(); i++) {
        addCapability((Capability) capabilities.get(i));
    }

    List requirement = ebi.getRequirement();
    for (int i = 0; i < requirement.size(); i++) {
        addRequire((Require) requirement.get(i));
    }

    // we also add the goupId
    Category category = new Category();
    category.setId(project.getGroupId());
    addCategory(category);

    return true;
}

From source file:org.apache.felix.obrplugin.ResourcesBundle.java

License:Apache License

/**
 * this method gets information form pom.xml to complete missing data from those given by user.
 * @param project project information given by maven
 * @param ebi bundle information extracted from bindex
 * @param sourcePath path to local sources
 * @param javadocPath path to local javadocs
 * @return true//from w  ww . j  av a2s .  c  o  m
 */
public boolean construct(MavenProject project, ExtractBindexInfo ebi, String sourcePath, String javadocPath) {

    if (ebi.getPresentationName() != null) {
        setPresentationName(ebi.getPresentationName());
        if (project.getName() != null) {
            m_logger.debug("pom property override:<presentationname> " + project.getName());
        }
    } else {
        setPresentationName(project.getName());
    }

    if (ebi.getSymbolicName() != null) {
        setSymbolicName(ebi.getSymbolicName());
        if (project.getArtifactId() != null) {
            m_logger.debug("pom property override:<symbolicname> " + project.getArtifactId());
        }
    } else {
        setSymbolicName(project.getArtifactId());
    }

    if (ebi.getVersion() != null) {
        setVersion(ebi.getVersion());
        if (project.getVersion() != null) {
            m_logger.debug("pom property override:<version> " + project.getVersion());
        }
    } else {
        setVersion(project.getVersion());
    }

    if (ebi.getId() != null) {
        setId(ebi.getId());
    }

    if (ebi.getDescription() != null) {
        setDescription(ebi.getDescription());
        if (project.getDescription() != null) {
            m_logger.debug("pom property override:<description> " + project.getDescription());
        }
    } else {
        setDescription(project.getDescription());
    }

    // fallback to javadoc if no project URL
    String documentation = project.getUrl();
    if (null == documentation) {
        documentation = javadocPath;
    }

    if (ebi.getDocumentation() != null) {
        setDocumentation(ebi.getDocumentation());
        if (documentation != null) {
            m_logger.debug("pom property override:<documentation> " + documentation);
        }
    } else {
        setDocumentation(documentation);
    }

    if (ebi.getSource() != null) {
        setSource(ebi.getSource());
        if (sourcePath != null) {
            m_logger.debug("pom property override:<source> " + sourcePath);
        }
    } else {
        setSource(sourcePath);
    }

    setJavadoc(javadocPath);

    if (ebi.getLicense() != null) {
        setLicense(ebi.getLicense());
        String lic = null;
        List l = project.getLicenses();
        Iterator it = l.iterator();
        while (it.hasNext()) {
            if (it.next() != null) {
                m_logger.debug("pom property override:<license> " + lic);
                break;
            }
        }
    } else {
        String lic = null;
        List l = project.getLicenses();
        Iterator it = l.iterator();
        while (it.hasNext()) {
            lic = it.next() + ";";
        }

        setLicense(lic);
    }

    // create the first capability (ie : bundle)
    Capability capability = new Capability();
    capability.setName("bundle");
    PElement p = new PElement();
    p.setN("manifestversion");
    p.setV("2");
    capability.addP(p);

    p = new PElement();
    p.setN("presentationname");
    p.setV(getPresentationName());
    capability.addP(p);

    p = new PElement();
    p.setN("symbolicname");
    p.setV(getSymbolicName());
    capability.addP(p);

    p = new PElement();
    p.setN("version");
    p.setT("version");
    p.setV(getVersion());
    capability.addP(p);

    addCapability(capability);

    List capabilities = ebi.getCapabilities();
    for (int i = 0; i < capabilities.size(); i++) {
        addCapability((Capability) capabilities.get(i));
    }

    List requirement = ebi.getRequirement();
    for (int i = 0; i < requirement.size(); i++) {
        addRequire((Require) requirement.get(i));
    }

    List categories = ebi.getCategories();
    for (int i = 0; i < categories.size(); i++) {
        addCategory((Category) categories.get(i));
    }

    // we also add the goupId
    Category category = new Category();
    category.setId(project.getGroupId());
    addCategory(category);

    return true;
}

From source file:org.apache.hyracks.maven.license.project.Project.java

License:Apache License

public Project(MavenProject project, String location, File artifactPath) {
    mavenProject = project;/*from   w  w w  .  j a  v  a  2s . c  o  m*/
    name = project.getName();
    groupId = project.getGroupId();
    artifactId = project.getArtifactId();
    version = project.getVersion();
    url = project.getUrl();
    this.artifactPath = artifactPath.getPath();
    setLocation(location);
}

From source file:org.apache.james.mailet.AggregateMailetdocsReport.java

License:Apache License

private void logProject(MavenProject project) {
    if (getLog().isDebugEnabled()) {
        getLog().debug("Aggregating mailets within " + project.getName());
    }/*ww w .  j a  va 2 s.  c  om*/
}