List of usage examples for org.apache.maven.plugin.logging Log debug
void debug(Throwable error);
From source file:org.apache.axis2.maven2.wsdl2code.WSDL2CodeMojo.java
License:Apache License
private void showDependencies() { Log log = getLog(); if (!log.isDebugEnabled()) { return;//from ww w .java2 s . co m } log.debug("The projects dependency artifacts are: "); for (Iterator iter = project.getDependencyArtifacts().iterator(); iter.hasNext();) { Artifact artifact = (Artifact) iter.next(); log.debug(" " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() + ":" + artifact.getClassifier() + ":" + artifact.getScope() + ":" + artifact.getType()); } log.debug("The projects transitive artifacts are: "); for (Iterator iter = project.getArtifacts().iterator(); iter.hasNext();) { Artifact artifact = (Artifact) iter.next(); log.debug(" " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() + ":" + artifact.getClassifier() + ":" + artifact.getScope() + ":" + artifact.getType()); } }
From source file:org.apache.cactus.maven2.mojos.Dependency.java
License:Apache License
/** * We override this mothod. /*from w w w .j av a2 s . c om*/ * @param theProject The Maven project parameter * @param theLog The Maven Log parameter * @return the path to the dependency as <code>java.lang.String</code> * @throws MojoExecutionException in case an error occurs */ public String getDependencyPath(MavenProject theProject, Log theLog) throws MojoExecutionException { String path = getLocation(); if (path == null) { if ((getGroupId() == null) || (getArtifactId() == null)) { throw new MojoExecutionException("You must specify a " + "groupId/artifactId or a location that points to a " + "directory or JAR"); } // Default to jar if not type is specified if (getType() == null) { setType("jar"); } path = findArtifactLocation(theProject.getArtifacts(), theLog); } theLog.debug("Classpath location = [" + new File(path).getPath() + "]"); return new File(path).getPath(); }
From source file:org.apache.camel.guice.maven.DotMojo.java
License:Apache License
protected String convertFile(File file, String format) throws CommandLineException { Log log = getLog(); if (!useDot) { log.info("DOT generation disabled"); return null; }//from w w w .ja va 2 s.c o m if (this.executable == null || this.executable.length() == 0) { log.warn("Parameter <executable/> was not set in the pom.xml. Skipping conversion."); return null; } String generatedFileName = removeFileExtension(file.getAbsolutePath()) + "." + format; Commandline cl = new Commandline(); cl.setExecutable(executable); cl.createArg().setValue("-T" + format); cl.createArg().setValue("-o"); cl.createArg().setValue(generatedFileName); cl.createArg().setValue(file.getAbsolutePath()); log.debug("executing: " + cl.toString()); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.executeCommandLine(cl, stdout, stderr); String output = stdout.getOutput(); if (output.length() > 0) { log.debug(output); } String errOutput = stderr.getOutput(); if (errOutput.length() > 0) { log.warn(errOutput); } return generatedFileName; }
From source file:org.apache.camel.maven.DotMojo.java
License:Apache License
protected String convertFile(File file, String format) throws CommandLineException { Log log = getLog(); if (!useDot) { log.info("DOT generation disabled."); return null; } else {//from w w w. j av a 2s.c o m if (dotHelpExitCode() != 0) { log.info("'dot -?' execution failed so DOT generation disabled."); return null; } } if (this.executable == null || this.executable.length() == 0) { log.warn("Parameter <executable/> was not set in the pom.xml. Skipping conversion."); return null; } String generatedFileName = removeFileExtension(file.getAbsolutePath()) + "." + format; Commandline cl = new Commandline(); cl.setExecutable(executable); cl.createArg().setValue("-T" + format); cl.createArg().setValue("-o"); cl.createArg().setValue(generatedFileName); cl.createArg().setValue(file.getAbsolutePath()); log.debug("executing: " + cl.toString()); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.executeCommandLine(cl, stdout, stderr); String output = stdout.getOutput(); if (output.length() > 0) { log.debug(output); } String errOutput = stderr.getOutput(); if (errOutput.length() > 0) { log.warn(errOutput); } return generatedFileName; }
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()); }// ww w . j a v 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()); }//from w w w . j a v a 2s. c om 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 a2 s . com*/ 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 static void dumpInstructions(String title, Properties properties, Log log) { if (log.isDebugEnabled()) { log.debug(title); log.debug("------------------------------------------------------------------------"); for (Enumeration e = properties.propertyNames(); e.hasMoreElements();) { String key = (String) e.nextElement(); log.debug(key + ": " + properties.getProperty(key)); }//from w w w . j a v a 2 s . c o m log.debug("------------------------------------------------------------------------"); } }
From source file:org.apache.felix.bundleplugin.BundlePlugin.java
License:Apache License
protected static void dumpClasspath(String title, List classpath, Log log) { if (log.isDebugEnabled()) { log.debug(title); log.debug("------------------------------------------------------------------------"); for (Iterator i = classpath.iterator(); i.hasNext();) { File path = ((Jar) i.next()).getSource(); log.debug(null == path ? "null" : path.toString()); }//from w w w.j a va 2 s .c o m log.debug("------------------------------------------------------------------------"); } }
From source file:org.apache.felix.bundleplugin.BundlePlugin.java
License:Apache License
protected static void dumpManifest(String title, Manifest manifest, Log log) { if (log.isDebugEnabled()) { log.debug(title); log.debug("------------------------------------------------------------------------"); for (Iterator i = manifest.getMainAttributes().entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); log.debug(entry.getKey() + ": " + entry.getValue()); }//from w w w. ja v a2s . c om log.debug("------------------------------------------------------------------------"); } }