List of usage examples for org.apache.maven.project MavenProject getDescription
public String getDescription()
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()); }/*from w w w. j ava 2s .co 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 ww w.j a va2 s . c o m*/ 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;/* ww w . j a v a2s .com*/ 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 . java 2 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 ava 2 s.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.artificer.integration.java.artifactbuilder.MavenPomArtifactBuilder.java
License:Apache License
@Override public ArtifactBuilder buildArtifacts(BaseArtifactType primaryArtifact, ArtifactContent artifactContent) throws Exception { super.buildArtifacts(primaryArtifact, artifactContent); try {/*w w w . j a v a 2 s . co 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); ArtificerModelUtils.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 ArtificerModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_ARTIFACT_ID, model.getArtifactId()); ArtificerModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_GROUP_ID, model.getGroupId()); ArtificerModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_VERSION, model.getVersion()); ArtificerModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_PACKAGING, model.getPackaging()); //set the parent GAV info if (model.getParent() != null) { ArtificerModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_PARENT_ARTIFACT_ID, model.getParent().getArtifactId()); ArtificerModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_PARENT_GROUP_ID, model.getParent().getGroupId()); ArtificerModelUtils.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.codehaus.cargo.documentation.ConfluenceProjectStructureDocumentationGenerator.java
License:Apache License
/** * Writes the current MavenProject information. * @param aProject the MavenProject we are currently documenting. * @param treeIndex the current project level. * @return the markup for the given MavenProject. *//*from w w w. j ava 2 s . c om*/ private String getProjectInfo(MavenProject aProject, int treeIndex) { StringBuilder markup = new StringBuilder(""); markup.append(ASTERISK); markup.append(" "); markup.append(START_COLOR); markup.append(aProject.getFile().getParentFile().getName()); markup.append("/"); markup.append(END_COLOR); String description = aProject.getDescription() != null ? aProject.getDescription() : aProject.getName(); markup.append(": "); markup.append(description); markup.append(LINE_SEPARATOR); markup.append(getModuleTree(aProject, treeIndex)); return markup.toString(); }
From source file:org.codehaus.mojo.unix.maven.plugin.MavenProjectWrapper.java
License:Open Source License
public static MavenProjectWrapper mavenProjectWrapper(final MavenProject project, MavenSession session) { SortedMap<String, String> properties = new TreeMap<String, String>(); // This is perhaps not ideal. Maven uses reflection to dynamically extract properties from the project // when interpolating each file. This uses a static list that doesn't contain the project.* properties, except // the new we hard-code support for. //// w ww. jav a 2s.c o m // The user can work around this like this: // <properties> // <project.build.directory>${project.build.directory}</project.build.directory> // </properties> // // If this has to change, the properties has to be a F<String, String> and interpolation tokens ("${" and "}") // has to be defined. Doable but too painful for now. properties.putAll(toMap(session.getSystemProperties())); properties.putAll(toMap(session.getUserProperties())); properties.putAll(toMap(project.getProperties())); properties.put("project.groupId", project.getGroupId()); properties.put("project.artifactId", project.getArtifactId()); properties.put("project.version", project.getVersion()); return new MavenProjectWrapper(project.getGroupId(), project.getArtifactId(), project.getVersion(), project.getArtifact(), project.getName(), project.getDescription(), project.getBasedir(), new File(project.getBuild().getDirectory()), new LocalDateTime(), project.getArtifacts(), project.getLicenses(), new ArtifactMap(project.getArtifacts()), unmodifiableSortedMap(properties)); }
From source file:org.eclipse.virgo.ide.bundlor.internal.core.maven.MavenPropertiesSource.java
License:Open Source License
public Properties getProperties() { try {//w ww .j a v a2s. c o m IMavenProjectRegistry registry = MavenPlugin.getMavenProjectRegistry(); IMavenProjectFacade facade = registry.create(this.project, new NullProgressMonitor()); if (facade != null) { MavenProject mavenProj = facade.getMavenProject(new NullProgressMonitor()); Properties props = mavenProj.getProperties(); // add in some special maven properties addPropertyIfNotNull(props, "project.artifactId", mavenProj.getArtifactId()); //$NON-NLS-1$ addPropertyIfNotNull(props, "project.groupId", mavenProj.getGroupId()); //$NON-NLS-1$ addPropertyIfNotNull(props, "project.description", mavenProj.getDescription()); //$NON-NLS-1$ addPropertyIfNotNull(props, "project.name", mavenProj.getName()); //$NON-NLS-1$ addPropertyIfNotNull(props, "project.version", mavenProj.getVersion()); //$NON-NLS-1$ addPropertyIfNotNull(props, "pom.artifactId", mavenProj.getArtifactId()); //$NON-NLS-1$ addPropertyIfNotNull(props, "pom.groupId", mavenProj.getGroupId()); //$NON-NLS-1$ addPropertyIfNotNull(props, "pom.description", mavenProj.getDescription()); //$NON-NLS-1$ addPropertyIfNotNull(props, "pom.name", mavenProj.getName()); //$NON-NLS-1$ addPropertyIfNotNull(props, "pom.version", mavenProj.getVersion()); //$NON-NLS-1$ return props; } } catch (CoreException e) { // this exception will be reported later on as the properties can't be reported. } return EMPTY_STANDARD; }
From source file:org.glassfish.jersey.tools.plugins.GenerateJerseyModuleListMojo.java
License:Open Source License
private StringBuilder processModuleList(String categoryCaption, String categoryId, List<MavenProject> projectsInCategory) { StringBuilder categoryContent = new StringBuilder(); // Output table header for the category categoryContent.append(configuration.getTableHeader().replace(CATEGORY_CAPTION_PLACEHOLDER, categoryCaption) .replace(CATEGORY_GROUP_ID_PLACEHOLDER, categoryId)); // Sort projects in each category alphabetically Collections.sort(projectsInCategory, new Comparator<MavenProject>() { @Override//from w ww .j a v a2s .co m public int compare(MavenProject o1, MavenProject o2) { return o1.getArtifactId().compareTo(o2.getArtifactId()); } }); // Output projects in a category for (MavenProject project : projectsInCategory) { // skip the "parent" type projects if (project.getArtifactId().equals("project")) { continue; } String linkPrefix = getLinkPath(project); categoryContent .append(configuration.getTableRow().replace(MODULE_NAME_PLACEHOLDER, project.getArtifactId()) .replace(MODULE_DESCRIPTION_PLACEHOLDER, project.getDescription()) .replace(MODULE_LINK_PATH_PLACEHOLDER, linkPrefix + project.getArtifactId())); } categoryContent.append(configuration.getTableFooter()); return categoryContent; }