List of usage examples for org.apache.commons.lang SystemUtils LINE_SEPARATOR
String LINE_SEPARATOR
To view the source code for org.apache.commons.lang SystemUtils LINE_SEPARATOR.
Click Source Link
The line.separator
System Property.
From source file:org.bsc.maven.reporting.renderer.ScmRenderer.java
/** * Return a <code>SCM repository</code> defined by a given url * * @param scmUrl an SCM URL//from ww w . j a va 2s . c om * @return a valid SCM repository or null */ public ScmRepository getScmRepository(String scmUrl) { if (StringUtils.isEmpty(scmUrl)) { return null; } ScmRepository repo = null; List<String> messages = new ArrayList<String>(); try { messages.addAll(scmManager.validateScmRepository(scmUrl)); } catch (Exception e) { messages.add(e.getMessage()); } if (messages.size() > 0) { StringBuilder sb = new StringBuilder(); boolean isIntroAdded = false; for (String msg : messages) { // Ignore NoSuchScmProviderException msg // See impl of AbstractScmManager#validateScmRepository() if (msg.startsWith("No such provider")) { continue; } if (!isIntroAdded) { sb.append("This SCM url '"); sb.append(scmUrl); sb.append("' is invalid due to the following errors:"); sb.append(SystemUtils.LINE_SEPARATOR); isIntroAdded = true; } sb.append(" * "); sb.append(msg); sb.append(SystemUtils.LINE_SEPARATOR); } if (StringUtils.isNotEmpty(sb.toString())) { sb.append("For more information about SCM URL Format, please refer to: " + "http://maven.apache.org/scm/scm-url-format.html"); throw new IllegalArgumentException(sb.toString()); } } try { repo = scmManager.makeScmRepository(scmUrl); } catch (NoSuchScmProviderException e) { if (log.isDebugEnabled()) { log.debug(e.getMessage(), e); } } catch (ScmRepositoryException e) { if (log.isDebugEnabled()) { log.debug(e.getMessage(), e); } } catch (Exception e) { // Should be already catched if (log.isDebugEnabled()) { log.debug(e.getMessage(), e); } } return repo; }
From source file:org.codehaus.mojo.aspectj.AjcHelper.java
/** * Creates a file that can be used as input to the ajc compiler using the -argdfile flag. * Each line in these files should contain one option or filename. * Comments, as in Java, start with // and extend to the end of the line. * /*from ww w .j a v a 2 s. c o m*/ * @param arguments All arguments passed to ajc in this run * @param fileName the filename of the argfile * @param outputDir the build output area. * @throws IOException */ public static void writeBuildConfigToFile(List arguments, String fileName, File outputDir) throws IOException { FileUtils.forceMkdir(outputDir); File argFile = new File(outputDir.getAbsolutePath(), fileName); argFile.getParentFile().mkdirs(); argFile.createNewFile(); FileWriter writer = new FileWriter(argFile); Iterator iter = arguments.iterator(); while (iter.hasNext()) { String argument = (String) iter.next(); writer.write(argument + SystemUtils.LINE_SEPARATOR); } writer.flush(); writer.close(); }
From source file:org.codehaus.mojo.gwt.reports.SoycReport.java
@Override protected void executeReport(Locale locale) throws MavenReportException { StringBuilder message = new StringBuilder(); message.append("--------------------------------------------------------------------------"); message.append(SystemUtils.LINE_SEPARATOR); message.append(getI18nString(locale, "soyc.report.warning")); message.append(SystemUtils.LINE_SEPARATOR); message.append("--------------------------------------------------------------------------"); getLog().warn(message.toString());/* w w w .j av a 2 s . com*/ if (skip) { getLog().info("Soyc Report is skipped"); return; } DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir(extra); scanner.setIncludes(new String[] { "**/soycReport/stories0.xml.gz" }); boolean soycRawReport = true; if (extra.exists()) { scanner.scan(); } else { soycRawReport = false; } if (!soycRawReport || scanner.getIncludedFiles().length == 0) { getLog().warn("No SOYC raw report found, did you compile with soyc option set ?"); soycRawReport = false; } GwtDevHelper gwtDevHelper = new GwtDevHelper(pluginArtifacts, project, getLog(), AbstractGwtMojo.GWT_GROUP_ID); String[] includeFiles = soycRawReport ? scanner.getIncludedFiles() : new String[0]; for (String path : includeFiles) { try { //Usage: java com.google.gwt.soyc.SoycDashboard -resources dir -soycDir dir -symbolMaps dir [-out dir] String module = path.substring(0, path.indexOf(File.separatorChar)); JavaCommandRequest javaCommandRequest = new JavaCommandRequest() .setClassName("com.google.gwt.soyc.SoycDashboard").setLog(getLog()); JavaCommand cmd = new JavaCommand(javaCommandRequest).withinClasspath(gwtDevHelper.getGwtDevJar()) .arg("-out").arg(reportingOutputDirectory.getAbsolutePath() + File.separatorChar + module); cmd.arg(new File(extra, path).getAbsolutePath()); cmd.arg(new File(extra, path).getAbsolutePath().replace("stories", "dependencies")); cmd.arg(new File(extra, path).getAbsolutePath().replace("stories", "splitPoints")); cmd.execute(); } catch (Exception e) { getLog().warn(e.getMessage(), e); new CompilationReportRenderer(getSink(), new ArrayList<GwtModule>(0), getLog(), soycRawReport, "soyc", false, i18n, locale).render(); } } try { GwtModuleReader gwtModuleReader = new DefaultGwtModuleReader(this.project, getLog(), classpathBuilder); List<GwtModule> gwtModules = new ArrayList<GwtModule>(); List<String> moduleNames = gwtModuleReader.getGwtModules(); for (String name : moduleNames) { gwtModules.add(gwtModuleReader.readModule(name)); } // add link in the page to all module reports CompilationReportRenderer compilationReportRenderer = new CompilationReportRenderer(getSink(), gwtModules, getLog(), soycRawReport, "soyc", false, i18n, locale); compilationReportRenderer.render(); } catch (GwtModuleReaderException e) { throw new MavenReportException(e.getMessage(), e); } }
From source file:org.codehaus.mojo.gwt.shell.CompileMojo.java
private int getLocalWorkers() { if (localWorkers > 0) { return localWorkers; }//from w ww . j av a 2s . co m // workaround to GWT issue 4031 whith IBM JDK // @see http://code.google.com/p/google-web-toolkit/issues/detail?id=4031 if (System.getProperty("java.vendor").startsWith("IBM")) { StringBuilder sb = new StringBuilder("Build is using IBM JDK, localWorkers set to 1 as a workaround"); sb.append(SystemUtils.LINE_SEPARATOR); sb.append("see http://code.google.com/p/google-web-toolkit/issues/detail?id=4031"); getLog().info(sb.toString()); return 1; } return Runtime.getRuntime().availableProcessors(); }
From source file:org.codehaus.mojo.gwt.shell.CSSMojo.java
public void doExecute() throws MojoExecutionException, MojoFailureException { setup();//from w w w . j a v a2s. c om boolean generated = false; // java -cp gwt-dev.jar:gwt-user.jar // com.google.gwt.resources.css.InterfaceGenerator -standalone -typeName some.package.MyCssResource -css // input.css if (cssFiles != null) { for (String file : cssFiles) { final String typeName = FilenameUtils.separatorsToSystem(file).substring(0, file.lastIndexOf('.')) .replace(File.separatorChar, '.'); final File javaOutput = new File(getGenerateDirectory(), typeName.replace('.', File.separatorChar) + ".java"); final StringBuilder content = new StringBuilder(); out = new StreamConsumer() { public void consumeLine(String line) { content.append(line).append(SystemUtils.LINE_SEPARATOR); } }; for (Resource resource : (List<Resource>) getProject().getResources()) { final File candidate = new File(resource.getDirectory(), file); if (candidate.exists()) { getLog().info("Generating " + javaOutput + " with typeName " + typeName); ensureTargetPackageExists(getGenerateDirectory(), typeName); try { new JavaCommand("com.google.gwt.resources.css.InterfaceGenerator") .withinScope(Artifact.SCOPE_COMPILE).arg("-standalone").arg("-typeName") .arg(typeName).arg("-css").arg(candidate.getAbsolutePath()) .withinClasspath(getGwtDevJar()).withinClasspath(getGwtUserJar()).execute(); final FileWriter outputWriter = new FileWriter(javaOutput); outputWriter.write(content.toString()); outputWriter.close(); } catch (IOException e) { throw new MojoExecutionException("Failed to write to file: " + javaOutput); } generated = true; break; } } if (content.length() == 0) { throw new MojoExecutionException("cannot generate java source from file " + file + "."); } } } if (generated) { getLog().debug("add compile source root " + getGenerateDirectory()); addCompileSourceRoot(getGenerateDirectory()); } }
From source file:org.ebayopensource.turmeric.runtime.tests.common.jetty.AbstractWithProxyServerTest.java
private void writeXml(File file, Document doc) throws IOException { FileWriter writer = null;/*from w w w .j a v a 2 s . com*/ try { writer = new FileWriter(file); XMLOutputter serializer = new XMLOutputter(); serializer.getFormat().setIndent(" "); serializer.getFormat().setLineSeparator(SystemUtils.LINE_SEPARATOR); serializer.output(doc, writer); } finally { IOUtils.closeQuietly(writer); } }
From source file:org.ebayopensource.turmeric.runtime.tests.common.jetty.DebugHandler.java
private void logResponse(DebugHttpServletResponse debugResponse) { String ln = SystemUtils.LINE_SEPARATOR; byte responseBody[] = debugResponse.getCapturedBody(); StringBuilder dbg = new StringBuilder(); dbg.append(ln).append(" Status: ").append(debugResponse.getStatusCode()); dbg.append(ln).append(" Reason: ").append(debugResponse.getStatusReason()); dbg.append(ln).append(" Content-Length: ").append(debugResponse.getContentLength()); Map<String, String> headers = debugResponse.getHeaders(); dbg.append(ln).append(" Headers (").append(headers.size()).append(")"); for (String name : headers.keySet()) { dbg.append(ln).append(" ").append(name).append(": "); dbg.append(headers.get(name));// ww w.ja va 2s.c o m } dbg.append(ln).append(" Body.length: ").append(responseBody.length); dbg.append(ln).append(WordUtils.wrap(new String(responseBody, 0, responseBody.length), 70)); Log.info("Response: " + dbg.toString()); }
From source file:org.ebayopensource.turmeric.runtime.tests.common.jetty.DebugHandler.java
private void logRequest(Request request) { String ln = SystemUtils.LINE_SEPARATOR; StringBuilder dbg = new StringBuilder(); dbg.append(ln).append(" Method: ").append(request.getMethod()); dbg.append(ln).append(" Request URI: ").append(request.getRequestURI()); if (request.getQueryString() != null) { dbg.append("?").append(request.getQueryString()); }// www .ja v a 2 s . c o m @SuppressWarnings("unchecked") List<String> headerNames = Collections.list(request.getHeaderNames()); dbg.append(ln).append(" HTTP Request Headers (").append(headerNames.size()).append(")"); for (String name : headerNames) { dbg.append(ln).append(" ").append(name).append(": "); dbg.append(request.getHeader(name)); } @SuppressWarnings("unchecked") List<String> paramNames = Collections.list(request.getParameterNames()); dbg.append(ln).append(" Request Parameters (").append(paramNames.size()).append(")"); for (String name : paramNames) { dbg.append(ln).append(" ").append(name).append(" = "); dbg.append(request.getParameter(name)); } Log.info("Request: " + dbg.toString()); }
From source file:org.ebayopensource.turmeric.runtime.tests.common.util.NVAssert.java
/** * Simply makes the map readable by humans, which in turn makes the test results more meaningful and easier to read. * With an added benefit that the Eclipse Junit views will highlight the differences in a much clearer fashion. * /* w w w . j av a2 s . c o m*/ * @param nvmap * the nvmap to represent in human readable form * @return the human readable form. */ private static String humanReadable(Map<String, String> nvmap) { StringBuilder str = new StringBuilder(); boolean needsDelim = false; for (Entry<String, String> entry : nvmap.entrySet()) { if (needsDelim) { str.append("@").append(SystemUtils.LINE_SEPARATOR); } str.append('&'); str.append(entry.getKey()).append("="); str.append(entry.getValue()); needsDelim = true; } return str.toString(); }
From source file:org.ebayopensource.turmeric.tools.codegen.CodegenTestUtils.java
private static String readFileToStringTrimmed(File file) throws IOException { StringBuilder contents = new StringBuilder(); FileReader fr = null;//w w w . j ava2 s . com BufferedReader br = null; try { fr = new FileReader(file); br = new BufferedReader(fr); String tmpStr = null; while ((tmpStr = br.readLine()) != null) { if (tmpStr.startsWith("#")) { // a comment: skip continue; } if (StringUtils.isBlank(tmpStr)) { // empty line: skip continue; } contents.append(tmpStr.trim()).append(SystemUtils.LINE_SEPARATOR); } } finally { IOUtils.closeQuietly(br); IOUtils.closeQuietly(fr); } return contents.toString(); }