Example usage for org.apache.maven.plugin.logging Log error

List of usage examples for org.apache.maven.plugin.logging Log error

Introduction

In this page you can find the example usage for org.apache.maven.plugin.logging Log error.

Prototype

void error(Throwable error);

Source Link

Document

Send an exception to the user in the error error level.
The stack trace for this exception will be output when this error level is enabled.

Usage

From source file:org.jboss.ws.plugins.tools.AbstractWsConsumeMojo.java

License:Open Source License

public void execute() throws MojoExecutionException {
    Log log = getLog();
    if (wsdls == null) {
        getLog().info("No wsdl URL / file specified, nothing to do.");
        return;/*ww w. java  2s . c  o m*/
    }

    if (verbose) {
        log.info("Classpath:");
        for (String s : getClasspathElements()) {
            log.info(" " + s);
        }
    }

    ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
    try {
        URLClassLoader loader = getMavenClasspathAwareClassLoader();
        Thread.currentThread().setContextClassLoader(loader);

        WSContractConsumerParams params = new WSContractConsumerParams();
        params.setAdditionalCompilerClassPath(new LinkedList<String>(getClasspathElements()));
        params.setBindingFiles(bindingFiles);
        params.setCatalog(catalog);
        params.setAdditionalHeaders(additionalHeaders);
        params.setExtension(extension);
        params.setGenerateSource(generateSource);
        params.setLoader(loader);
        params.setNoCompile(noCompile);
        params.setOutputDirectory(getOutputDirectory());
        params.setSourceDirectory(sourceDirectory);
        params.setTarget(target);
        params.setTargetPackage(targetPackage);
        params.setWsdlLocation(wsdlLocation);
        params.setEncoding(encoding);
        params.setArgLine(argLine);
        params.setFork(fork);

        File manifestOnlyJar = createJar(getClasspathElements(), "");
        params.setManifestOnlyJar(manifestOnlyJar);

        WSContractDelegate delegate = new WSContractDelegate(getLog());

        for (String wsdl : wsdls) {
            try {
                delegate.runConsumer(params, wsdl);
            } catch (MalformedURLException mue) {
                log.error("Skipping invalid wsdl reference: " + wsdl);
            } catch (Exception e) {
                throw new MojoExecutionException("Error while running wsconsume", e);
            }
        }
        updateProjectSourceRoots();
    } catch (java.io.IOException ioe) {
        throw new MojoExecutionException("Error while running wsconsume", ioe);
    } finally {
        Thread.currentThread().setContextClassLoader(origLoader);
    }
}

From source file:org.junite2.MyMojo.java

License:Apache License

protected void execute(JUnitEETest test) throws Exception {
    StringBuffer arguments = new StringBuffer();
    boolean done;
    String sessionCookie;// ww  w  .ja  v  a  2s .  co m
    URL requestUrl;
    URLConnection con;
    Log log = getLog();

    arguments.append(url).append("?output=xml");

    if (threaded) {
        log.debug("Threaded mode");
        arguments.append("&thread=true");
    }

    if (test.getResource() != null) {
        arguments.append("&resource=").append(test.getResource());
    }
    if (test.getRunall()) {
        arguments.append("&all=true");
    } else if (test.getName() != null) {
        arguments.append("&suite=").append(URLEncoder.encode(test.getName()));
    } else {
        throw new Exception("You must specify the test name or runall attribute");
    }
    if (!test.getFiltertrace()) {
        arguments.append("&filterTrace=false");
    }

    log.debug("url is " + arguments.toString());

    InputStream in = null;
    requestUrl = new URL(arguments.toString());

    try {

        con = requestUrl.openConnection();
        sessionCookie = con.getHeaderField("Set-Cookie");
        log.debug("Session cookie : " + sessionCookie);

        if (sessionCookie != null) {
            int index = sessionCookie.indexOf(';');
            if (index != -1) {
                sessionCookie = sessionCookie.substring(0, index);
            }
        }
        in = con.getInputStream();
        done = parseResult(in, test);
    } catch (MojoExecutionException me) {
        throw me;
    } catch (Exception e) {

        throw new Exception("Error accessing url " + requestUrl.toString(), e);
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {
            }
            ;
        }
    }

    try {
        while (!done) {
            try {
                log.debug("Sleeping ... ");
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                // continue work
            }
            //log("Get xml again using URL " + requestUrl, Project.MSG_DEBUG);
            con = requestUrl.openConnection();
            if (sessionCookie != null) {
                con.setRequestProperty("Cookie", sessionCookie);
            }
            in = con.getInputStream();
            try {
                done = parseResult(in, test);

            } catch (MojoExecutionException me) {
                throw me;
            } catch (Throwable thr) {
                log.debug(thr);
                throw new MojoExecutionException(thr.getMessage());
            } finally {

                try {
                    in.close();
                } catch (IOException e) {
                }
                ;
            }
        }

    } catch (Exception e) {
        log.error("Failed to execute test: " + e.getMessage());
        throw new Exception(e);
    }
}

From source file:org.kie.maven.plugin.CompilerHelper.java

License:Apache License

public String getCompilationID(Map<String, Object> kieMap, Log log) {
    Object compilationIDObj = kieMap.get("compilation.ID");
    if (compilationIDObj != null) {
        return compilationIDObj.toString();
    } else {//  w  ww . j a va 2  s.  c om
        log.error("compilation.ID key not present in the shared map using thread name:"
                + Thread.currentThread().getName());
        return Thread.currentThread().getName();
    }
}

From source file:org.kiji.maven.plugins.hbase.PluginMiniHBaseClusterSingleton.java

License:Apache License

/**
 * Stops the HBase cluster and blocks until is has been shutdown completely.
 *
 * @param log The maven log.//w  w w .j  av  a 2s.c  o m
 */
public void stop(final Log log) {
    if (null == _miniCluster) {
        log.error("Attempted to stop a cluster, but no cluster was ever started in this process.");
        return;
    }

    log.info("Stopping the HBase cluster thread...");
    _miniHBaseClusterThread.stopClusterGracefully();
    while (_miniHBaseClusterThread.isAlive()) {
        try {
            _miniHBaseClusterThread.join();
        } catch (final InterruptedException e) {
            log.debug("HBase cluster thread interrupted.");
        }
    }
    log.info("HBase cluster thread stopped.");
}

From source file:org.mule.devkit.maven.AbstractGitHubMojo.java

License:Open Source License

/**
 * Log given message at error level//from w ww.java  2  s. co  m
 *
 * @param message
 */
protected void error(String message) {
    Log log = getLog();
    if (log != null) {
        log.error(message);
    }
}

From source file:org.mule.tools.apikit.input.MuleConfigParser.java

License:Open Source License

public MuleConfigParser(Log log, Set<File> yamlPaths, Map<File, InputStream> streams, APIFactory apiFactory) {
    this.apiFactory = apiFactory;
    for (Entry<File, InputStream> fileStreamEntry : streams.entrySet()) {
        InputStream stream = fileStreamEntry.getValue();
        File file = fileStreamEntry.getKey();
        try {// w w  w.  j a va2s . co  m
            parseMuleConfigFile(file, stream, yamlPaths);
            stream.close();
        } catch (Exception e) {
            log.error("Error parsing Mule xml config file: [" + file + "]. Reason: " + e.getMessage());
            log.debug(e);
        }
    }
}

From source file:org.mule.tools.apikit.input.MuleDomainParser.java

License:Open Source License

public MuleDomainParser(Log log, InputStream domainStream) {

    if (domainStream != null) {
        try {//from   www  .  j  a  va  2s  .c o m
            parseMuleDomainFile(domainStream);
        } catch (Exception e) {
            log.error("Error parsing Mule domain file. Reason: " + e.getMessage());
            log.debug(e);
        }
    }
}

From source file:org.openehealth.ipf.labs.maven.dsldoc.descriptor.AbstractDslRenderer.java

License:Apache License

protected File createTargetDescriptorFile(JavaClass cls, File outputDirectory, Log log) {
    File target = getTargetFile(outputDirectory, cls);
    if (!target.getParentFile().exists()) {
        boolean created = target.getParentFile().mkdirs();
        if (!created) {
            log.error("Unable to create the directory structure for DSL metadata "
                    + target.getParentFile().getAbsolutePath());
        }/*from  w ww .  j  ava 2 s.  com*/
    }
    return target;
}

From source file:org.phpmaven.phpdoc.impl.AbstractPhpdocSupport.java

License:Apache License

/**
 * Writes an ini log file.//www . ja  v a  2s  . com
 * @param log log
 * @param request request
 * @param phpDocConfigFile phpdoc config file
 * @param generatedPhpDocConfigFile 
 * @throws IOException io exception
 * @throws PhpCoreException php core exception
 */
protected void writeIni(Log log, IPhpdocRequest request, File phpDocConfigFile, File generatedPhpDocConfigFile)
        throws IOException, PhpCoreException {
    final Properties properties = new Properties();
    if (phpDocConfigFile.isFile()) {
        log.debug("generating phpdoc using config from " + phpDocConfigFile.getAbsolutePath());
        properties.load(new FileInputStream(phpDocConfigFile));
    } else {
        log.debug("config file " + phpDocConfigFile.getAbsolutePath() + " not found. ignoring.");
    }

    final Iterator<IPhpdocEntry> iter = request.getEntries().iterator();
    final IPhpdocEntry entry = iter.next();
    if (entry.getType() == EntryType.FILE) {
        log.error("Report generation for files not supported.");
        // TODO support it
        throw new PhpCoreException("Report generation for files not supported.");
    }
    if (iter.hasNext()) {
        log.error("Report generation for multiple source folders not supported.");
        // TODO support it
        throw new PhpCoreException("Report generation for multiple folders not supported.");
    }

    properties.put("directory", entry.getFile().getAbsolutePath());
    properties.put("target", request.getReportFolder().getAbsolutePath());

    this.writePropFile(properties, "[Parse Data]", generatedPhpDocConfigFile);
}

From source file:org.phpmaven.phpdoc.impl.AbstractPhpdocSupport.java

License:Apache License

/**
 * Writes a xml log file./*  w  w  w . j  a  v  a 2s .  co m*/
 * @param log log
 * @param request request
 * @param phpDocConfigFile phpdoc config file
 * @param generatedPhpDocConfigFile 
 * @throws IOException io exception
 * @throws PhpCoreException php core exception
 */
protected void writeXml(Log log, IPhpdocRequest request, File phpDocConfigFile, File generatedPhpDocConfigFile)
        throws IOException, PhpCoreException {

    // TODO read xml input file
    //        final Properties properties = new Properties();
    //        if (phpDocConfigFile.isFile()) {
    //            log.debug("generating phpdoc using config from " + phpDocConfigFile.getAbsolutePath());
    //            properties.load(new FileInputStream(phpDocConfigFile));
    //        } else {
    //            log.debug("config file " + phpDocConfigFile.getAbsolutePath() + " not found. ignoring.");
    //        }

    final StringBuffer buffer = new StringBuffer();
    buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
    buffer.append("<phpdocumentor>\n");
    buffer.append("<transformer>\n");
    buffer.append("<target>" + request.getReportFolder().getAbsolutePath() + "</target>\n");
    buffer.append("</transformer>\n");
    final Iterator<IPhpdocEntry> iter = request.getEntries().iterator();
    final IPhpdocEntry entry = iter.next();
    if (entry.getType() == EntryType.FILE) {
        log.error("Report generation for files not supported.");
        // TODO support it
        throw new PhpCoreException("Report generation for files not supported.");
    }
    if (iter.hasNext()) {
        log.error("Report generation for multiple source folders not supported.");
        // TODO support it
        throw new PhpCoreException("Report generation for multiple folders not supported.");
    }
    buffer.append("<files>\n");
    buffer.append("<directory>" + entry.getFile().getAbsolutePath() + "</directory>\n");
    buffer.append("</files>\n");
    buffer.append("</phpdocumentor>\n");

    generatedPhpDocConfigFile.getParentFile().mkdirs();
    final FileWriter fileWriter = new FileWriter(generatedPhpDocConfigFile);
    fileWriter.append(buffer.toString());
    fileWriter.close();
}