List of usage examples for org.jdom2 Text normalizeString
public static String normalizeString(String str)
From source file:org.apache.marmotta.maven.plugins.refpack.RefPackMojo.java
License:Apache License
private void writeModuleXML(Artifact module, OutputStream out) throws IOException { Element installation = new Element("installation"); installation.setAttribute("version", "1.0"); Element packs = new Element("packs"); installation.addContent(packs);//from w w w . j a v a 2s .c o m Element pack = new Element("pack"); packs.addContent(pack); // get the model for the artifact, we read name and description from it Model pom = getArtifactModel(module); // set name of pack from artifact if (pom != null && pom.getName() != null) { pack.setAttribute("name", pom.getName()); } else { pack.setAttribute("name", module.getArtifactId()); } if (pom != null && pom.getDescription() != null) { Element description = new Element("description"); description.setText(Text.normalizeString(pom.getDescription())); pack.addContent(description); } // add a file entry for the module itself if (!module.getExtension().equals("war")) { Element mainFile = new Element("file"); pack.addContent(mainFile); mainFile.setAttribute("src", module.getFile().getAbsolutePath()); mainFile.setAttribute("targetdir", "$INSTALL_PATH/apache-tomcat-$TOMCAT_VERSION/webapps/marmotta/WEB-INF/lib"); } // add a file entry for each library of the artifact for (Artifact library : moduleLibraries.get(module)) { Element file = new Element("file"); pack.addContent(file); file.setAttribute("src", library.getFile().getAbsolutePath()); file.setAttribute("targetdir", "$INSTALL_PATH/apache-tomcat-$TOMCAT_VERSION/webapps/marmotta/WEB-INF/lib"); } // add a depends name for each module the current one depends on (in case the project is not the webapp) if (!module.getExtension().equals("war")) { if (requiredModules.contains(module.getArtifactId())) { pack.setAttribute("required", "yes"); } else { pack.setAttribute("required", "no"); } for (Artifact dependency : moduleDependencies.get(module)) { Element depends = new Element("depends"); pack.addContent(depends); // get the model for the artifact, we read name and description from it Model pom2 = getArtifactModel(dependency); // set name of pack from artifact if (pom2 != null && pom2.getName() != null) { depends.setAttribute("packname", pom2.getName()); } else { depends.setAttribute("packname", module.getArtifactId()); } } } else { pack.setAttribute("required", "yes"); // add webapp directory from installer configuration Element appDir = new Element("fileset"); appDir.setAttribute("dir", outputDirectory + "/../webapp/"); appDir.setAttribute("targetdir", "$INSTALL_PATH/apache-tomcat-$TOMCAT_VERSION/webapps/marmotta/"); appDir.setAttribute("includes", "**"); pack.addContent(appDir); Element logDir = new Element("fileset"); logDir.setAttribute("dir", outputDirectory + "/../log/"); logDir.setAttribute("targetdir", "$INSTALL_PATH/apache-tomcat-$TOMCAT_VERSION/logs/"); logDir.setAttribute("includes", "**"); pack.addContent(logDir); } XMLOutputter writer = new XMLOutputter(Format.getPrettyFormat()); writer.output(installation, out); }