List of usage examples for org.apache.maven.plugin.logging Log isDebugEnabled
boolean isDebugEnabled();
From source file:org.xolstice.maven.plugin.protobuf.Protoc.java
License:Open Source License
/** * Logs execution parameters on debug level to the specified logger. * All log messages will be prefixed with "{@value #LOG_PREFIX}". * * @param log a logger.//from ww w. jav a2 s .c o m */ public void logExecutionParameters(final Log log) { if (log.isDebugEnabled()) { log.debug(LOG_PREFIX + "Executable: "); log.debug(LOG_PREFIX + ' ' + executable); if (protoPathElements != null && !protoPathElements.isEmpty()) { log.debug(LOG_PREFIX + "Protobuf import paths:"); for (final File protoPathElement : protoPathElements) { log.debug(LOG_PREFIX + ' ' + protoPathElement); } } if (javaOutputDirectory != null) { log.debug(LOG_PREFIX + "Java output directory:"); log.debug(LOG_PREFIX + ' ' + javaOutputDirectory); if (plugins.size() > 0) { log.debug(LOG_PREFIX + "Plugins for Java output:"); for (final ProtocPlugin plugin : plugins) { log.debug(LOG_PREFIX + ' ' + plugin.getId()); } } } if (pluginDirectory != null) { log.debug(LOG_PREFIX + "Plugin directory:"); log.debug(LOG_PREFIX + ' ' + pluginDirectory); } if (javaNanoOutputDirectory != null) { log.debug(LOG_PREFIX + "Java Nano output directory:"); log.debug(LOG_PREFIX + ' ' + javaNanoOutputDirectory); } if (cppOutputDirectory != null) { log.debug(LOG_PREFIX + "C++ output directory:"); log.debug(LOG_PREFIX + ' ' + cppOutputDirectory); } if (pythonOutputDirectory != null) { log.debug(LOG_PREFIX + "Python output directory:"); log.debug(LOG_PREFIX + ' ' + pythonOutputDirectory); } if (descriptorSetFile != null) { log.debug(LOG_PREFIX + "Descriptor set output file:"); log.debug(LOG_PREFIX + ' ' + descriptorSetFile); log.debug(LOG_PREFIX + "Include imports:"); log.debug(LOG_PREFIX + ' ' + includeImportsInDescriptorSet); } log.debug(LOG_PREFIX + "Protobuf descriptors:"); for (final File protoFile : protoFiles) { log.debug(LOG_PREFIX + ' ' + protoFile); } final List<String> cl = buildProtocCommand(); if (cl != null && !cl.isEmpty()) { log.debug(LOG_PREFIX + "Command line options:"); log.debug(LOG_PREFIX + Joiner.on(' ').join(cl)); } } }
From source file:org.xolstice.maven.plugin.protobuf.ProtocPlugin.java
License:Open Source License
/** * Validate the state of this plugin specification. * * @param log a logger instance for diagnostic output. * @throws IllegalStateException if properties are incorrect or are missing *///from ww w. j a v a 2 s .c o m public void validate(final Log log) { checkState(id != null, "id must be set in protocPlugin definition"); checkState(groupId != null, "groupId must be set in protocPlugin definition"); checkState(artifactId != null, "artifactId must be set in protocPlugin definition"); checkState(version != null, "version must be set in protocPlugin definition"); checkState(mainClass != null, "mainClass must be set in protocPlugin definition"); checkState(javaHome != null && new File(javaHome).isDirectory(), "javaHome is invalid: " + javaHome); if (Os.isFamily(Os.FAMILY_WINDOWS)) { // If winJvmDataModel isn't set explicitly, try to guess the architecture // by looking at the directories in the JDK/JRE javaHome points at. // If that fails, try to figure out from the currently running JVM. if (winJvmDataModel != null) { checkState( winJvmDataModel.equals(WIN_JVM_DATA_MODEL_32) || winJvmDataModel.equals(WIN_JVM_DATA_MODEL_64), "winJvmDataModel must be '32' or '64'"); } else if (archDirectoryExists("amd64")) { winJvmDataModel = WIN_JVM_DATA_MODEL_64; if (log.isDebugEnabled()) { log.debug("detected 64-bit JVM from directory structure"); } } else if (archDirectoryExists("i386")) { winJvmDataModel = WIN_JVM_DATA_MODEL_32; if (log.isDebugEnabled()) { log.debug("detected 32-bit JVM from directory structure"); } } else if (System.getProperty(DATA_MODEL_SYSPROP) != null) { winJvmDataModel = System.getProperty(DATA_MODEL_SYSPROP); if (log.isDebugEnabled()) { log.debug( "detected " + winJvmDataModel + "-bit JVM from system property " + DATA_MODEL_SYSPROP); } } else { winJvmDataModel = WIN_JVM_DATA_MODEL_32; if (log.isDebugEnabled()) { log.debug("defaulting to 32-bit JVM"); } } } }
From source file:uk.org.raje.maven.plugin.msbuild.LoggingHandler.java
License:Apache License
/** * Set the Maven logger that will output the messages generated by the Java logger specified in {@link * LoggingHandler#LoggingHandler(name)}. * @param log the Maven logger that will output the messages generated by the Java logger *//*from ww w .j a v a 2 s. c om*/ public void setLog(Log log) { this.mavenLogger = log; //Match the log level of the Java logger with that set in the Maven logger if (log.isDebugEnabled()) { javaLogger.setLevel(Level.FINE); } else if (log.isInfoEnabled()) { javaLogger.setLevel(Level.INFO); } else if (log.isWarnEnabled()) { javaLogger.setLevel(Level.WARNING); } else { javaLogger.setLevel(Level.SEVERE); } }
From source file:vitkin.sfdc.mojo.wsdl.WsdlDownloadlMojo.java
License:Apache License
/** * Download the WSDL.//from w w w. j a va2s.c o m * * @param client HTTP client. * @param resourceServer URL of the resource server from where to download. * * @throws MojoExecutionException */ private void downloadWsdl(final HttpClient client, final String resourceServer) throws MojoExecutionException { final Log logger = getLog(); final String baseUrl = resourceServer + '/' + wsdlUri; logger.info("Getting WSDL from " + baseUrl); final HttpGet wsdlRequest = new HttpGet(baseUrl); try { final HttpResponse response = client.execute(wsdlRequest); final int code = response.getStatusLine().getStatusCode(); if (code != HttpStatus.SC_OK) { throw new MojoExecutionException("Failed getting the WSDL! Got HTTP Code " + code); } PrintWriter pw = null; BufferedReader br = null; try { if (filename == null) { logger.info("No filename defined. Using default one from server..."); final Header header = response.getFirstHeader("Content-Disposition"); if (header == null) { if (logger.isDebugEnabled()) { debugResponse(response); } throw new MojoExecutionException("Couldn't get filename from server!"); } final HeaderElement[] elements = header.getElements(); filename = elements[0].getParameterByName("filename").getValue(); } if (!outputDirectory.exists()) { outputDirectory.mkdirs(); } final File wsdlFile = new File(outputDirectory, filename); logger.info("Saving WSDL to '" + wsdlFile + "'..."); br = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); pw = new PrintWriter(wsdlFile); for (String line = br.readLine(); line != null; line = br.readLine()) { pw.println(line); } } catch (IOException ex) { throw new MojoExecutionException("Failed saving the WSDL!", ex); } catch (IllegalStateException ex) { throw new MojoExecutionException("Failed saving the WSDL!", ex); } catch (ParseException ex) { throw new MojoExecutionException("Failed saving the WSDL!", ex); } finally { try { if (br != null) { br.close(); } if (pw != null) { pw.close(); } } catch (IOException ex) { logger.warn(ex.getMessage(), ex); } } } catch (IOException ex) { throw new MojoExecutionException("Cannot get WSDL!", ex); } }
From source file:vitkin.sfdc.mojo.wsdl.WsdlDownloadlMojo.java
License:Apache License
/** * Tell if a session is older than an hour. * * @param client HTTP client for which to attempt deducing if the session has * expired.//from ww w . j a va 2 s .c o m * * @return String The resource server for the session if the session hasn't * expired. Null otherwise. */ private String getResourceServer(InnerHttpClient client) { Log logger = getLog(); // Cookie 'oid' expiry date is supposed to be in 2 years in the future from // the date of creation of the cookie. final Calendar cal = GregorianCalendar.getInstance(); cal.add(Calendar.YEAR, 2); cal.add(Calendar.HOUR, -1); final Date futureDate = cal.getTime(); if (logger.isDebugEnabled()) { logger.debug("Future date: " + futureDate); } String resourceServer = null; for (Cookie cookie : client.getCookieStore().getCookies()) { final String name = cookie.getName(); if ("oid".equals(name)) { final Date expiryDate = cookie.getExpiryDate(); if (logger.isDebugEnabled()) { logger.debug("Expiry date: " + expiryDate); } if (futureDate.before(expiryDate)) { resourceServer = "https://" + cookie.getDomain(); } break; } } return resourceServer; }