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(CharSequence content, Throwable error);

Source Link

Document

Send a message (and accompanying exception) to the user in the error error level.
The error's stacktrace will be output when this error level is enabled.

Usage

From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.reader.ReadWorkspaceLocations.java

License:Apache License

/**
 * Read the JRE definition configured in the workspace. They will be put in a HashMap with as key there path and as
 * value the JRE constant. a second key is included with the JRE version as a key.
 *
 * @param workspaceLocation the workspace location
 * @param logger            the logger to error messages
 * @return the map with found jre's//from w w w . j a  va 2  s.co m
 */
private HashMap readAvailableJREs(File workspaceLocation, Log logger) {
    Xpp3Dom vms;
    try {
        File prefs = new File(workspaceLocation,
                ReadWorkspaceLocations.METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_LAUNCHING_PREFS);
        if (!prefs.exists()) {
            return null;
        }
        Properties properties = new Properties();
        properties.load(new FileInputStream(prefs));
        vms = Xpp3DomBuilder.build(new StringReader(properties
                .getProperty(ReadWorkspaceLocations.METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_PREFS_VM_KEY)));
    } catch (Exception e) {
        logger.error("Could not read workspace JRE preferences", e);
        return null;
    }

    HashMap jreMap = new HashMap();
    jreMap.put("1.2", CLASSPATHENTRY_STANDARD + "J2SE-1.2");
    jreMap.put("1.3", CLASSPATHENTRY_STANDARD + "J2SE-1.3");
    jreMap.put("1.4", CLASSPATHENTRY_STANDARD + "J2SE-1.4");
    jreMap.put("1.5", CLASSPATHENTRY_STANDARD + "J2SE-1.5");
    jreMap.put("5", jreMap.get("1.5"));
    jreMap.put("1.6", CLASSPATHENTRY_STANDARD + "JavaSE-1.6");
    jreMap.put("6", jreMap.get("1.6"));
    String defaultJRE = vms.getAttribute("defaultVM").trim();
    Xpp3Dom[] vmTypes = vms.getChildren("vmType");
    for (int vmTypeIndex = 0; vmTypeIndex < vmTypes.length; vmTypeIndex++) {
        String typeId = vmTypes[vmTypeIndex].getAttribute("id");
        Xpp3Dom[] vm = vmTypes[vmTypeIndex].getChildren("vm");
        for (int vmIndex = 0; vmIndex < vm.length; vmIndex++) {
            try {
                String path = vm[vmIndex].getAttribute("path");
                String name = vm[vmIndex].getAttribute("name");
                String vmId = vm[vmIndex].getAttribute("id").trim();
                String classpathEntry = MessageFormat.format(ReadWorkspaceLocations.CLASSPATHENTRY_FORMAT,
                        new Object[] { typeId, name });
                String jrePath = new File(path).getCanonicalPath();
                File rtJarFile = new File(new File(jrePath), "jre/lib/rt.jar");
                if (!rtJarFile.exists()) {
                    logger.warn(Messages.getString("EclipsePlugin.invalidvminworkspace", jrePath));
                    continue;
                }
                JarFile rtJar = new JarFile(rtJarFile);
                String version = rtJar.getManifest().getMainAttributes().getValue("Specification-Version");
                if (defaultJRE.endsWith("," + vmId)) {
                    jreMap.put(jrePath, ReadWorkspaceLocations.CLASSPATHENTRY_DEFAULT);
                    jreMap.put(version, ReadWorkspaceLocations.CLASSPATHENTRY_DEFAULT);
                    logger.debug("Default Classpath Container version: " + version + "  location: " + jrePath);
                } else if (!jreMap.containsKey(jrePath)) {
                    if (!jreMap.containsKey(version)) {
                        jreMap.put(version, classpathEntry);
                    }
                    jreMap.put(jrePath, classpathEntry);
                    logger.debug("Additional Classpath Container version: " + version + " " + classpathEntry
                            + " location: " + jrePath);
                } else {
                    logger.debug("Ignored (duplicated) additional Classpath Container version: " + version + " "
                            + classpathEntry + " location: " + jrePath);
                }
            } catch (IOException e) {
                logger.warn("Could not interpret entry: " + vm[vmIndex].toString());
            }
        }
    }
    return jreMap;
}

From source file:com.betfair.cougar.codegen.IDLReader.java

License:Apache License

public void init(Document iddDoc, Document extensionDoc, final String service, String packageName,
        final String basedir, final String genSrcDir, final Log log, final String outputDir, boolean client,
        boolean server) throws Exception {

    try {/* w w w  . j a v  a 2s .com*/
        output = new File(basedir, genSrcDir);
        if (outputDir != null) {
            iDDOutputDir = new File(basedir + "/" + outputDir);
            if (!iDDOutputDir.exists()) {
                if (!iDDOutputDir.mkdirs()) {
                    throw new IllegalArgumentException(
                            "IDD Output Directory " + iDDOutputDir + " could not be created");
                }
            }
            if (!iDDOutputDir.isDirectory() || (!iDDOutputDir.canWrite())) {
                throw new IllegalArgumentException("IDD Output Directory " + iDDOutputDir
                        + " is not a directory or cannot be written to.");
            }
        }
        config = new Configuration();
        config.setClassForTemplateLoading(IDLReader.class, "/templates");

        config.setStrictSyntaxMode(true);
        this.log = log;
        this.packageName = packageName;
        this.service = service;
        this.client = client;
        this.server = server || !client; // server must be true if client if false.

        dataModel = NodeModel.wrap(iddDoc.cloneNode(true));

        if (extensionDoc != null) {
            NodeModel extensionModel = NodeModel.wrap(extensionDoc);
            mergeExtensionsIntoDocument(getRootNode(dataModel), getRootNode(extensionModel));
            removeUndefinedOperations(getRootNode(dataModel), getRootNode(extensionModel));
        }
        if (log.isDebugEnabled()) {
            log.debug(serialize());
        }
    } catch (final Exception e) {
        log.error("Failed to initialise FTL", e);
        throw e;
    }
}

From source file:com.github.lucapino.confluence.AbstractConfluenceMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    Log log = getLog();
    // Run only at the execution root
    if (runOnlyAtExecutionRoot && !isThisTheExecutionRoot()) {
        log.info("Skipping the announcement mail in this project because it's not the Execution Root");
    } else {/* www.  j  av a  2  s .c  om*/
        if (isSkip()) {
            log.info("Skipping Plugin execution.");
            return;
        }
        try {
            loadUserCredentials();
            doExecute();
        } catch (Exception e) {
            log.error("Error when executing mojo", e);
        }
    }
}

From source file:com.github.lucapino.jira.AbstractJiraMojo.java

License:Apache License

@Override
public final void execute() throws MojoExecutionException, MojoFailureException {
    Log log = getLog();
    // Run only at the execution root
    if (runOnlyAtExecutionRoot && !isThisTheExecutionRoot()) {
        getLog().info("Skipping the announcement mail in this project because it's not the Execution Root");
    } else {//from   w ww .j ava2s .  co  m
        if (isSkip()) {
            log.info("Skipping Plugin execution.");
            return;
        }
        try {
            initJiraClient();
            doExecute();
            jiraClient.getRestClient().close();
        } catch (Exception e) {
            log.error("Error when executing mojo", e);
            // XXX: Por enquanto nao faz nada.
        }
    }
}

From source file:com.github.paulmoloney.maven.plugins.enforcer.AbstractToolChainAwareRule.java

License:Apache License

/**
 * Determines a path to a tool based on environment variables and subdirectory searches
 * @param tool/*from  w w  w . java  2 s .c o m*/
 * @param log
 * @param sysProperty
 * @param subDirs1
 * @param envArgs
 * @param subDirs2
 * @return The path to a tool or null if one is not found
 */
protected String findToolExecutable(String tool, Log log, String sysProperty, String[] subDirs1,
        String[] envArgs, String[] subDirs2) {
    log.warn("Falling back to env lookup for specified tool");

    String command = tool;
    try {
        Properties env = new Properties();
        env.putAll(getSession().getSystemProperties());
        env.putAll(getSession().getUserProperties());
        int envLen = null != env ? envArgs.length : 0;
        command = findExecutable(tool, env.getProperty(sysProperty), subDirs1);

        if (command == null) {
            if (null != envArgs) {
                for (int i = 0; i < envLen && executable == null; i++) {
                    command = findExecutable(tool, env.getProperty(envArgs[i]), subDirs2);
                    if (command != null) {
                        break;
                    }
                }
            }
        }
        log.warn("Using executable: " + command);
    } catch (IOException e) {
        log.error("Unable to find executable", e);
    }

    return command;
}

From source file:com.github.randomcodeorg.netmaven.netmaven.NetMavenSetupMojo.java

protected File dowanloadIKVM(Log log) throws MojoExecutionException {
    try {/*from   w w  w. jav a 2 s .c  om*/
        log.info("Downloading the IKVM executables...");
        File tmpFile = File.createTempFile("mvn", ".zip");
        log.debug("Temporary file will be at '" + tmpFile.getAbsolutePath() + "'");
        tmpFile.deleteOnExit();
        URL resource = new URL(IKVM_DOWNLOAD_DIR);
        ReadableByteChannel rbc = Channels.newChannel(resource.openStream());
        FileOutputStream fos = new FileOutputStream(tmpFile);
        fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
        fos.flush();
        fos.close();
        rbc.close();
        log.info("Download completed!");
        return tmpFile;
    } catch (IOException e) {
        log.error("An I/O error occured during the download of the IKVM library.", e);
        throw new MojoExecutionException("AnI/O error occured during the download of the IKVM library.", e);
    }
}

From source file:com.qq.tars.maven.util.ArchiveEntryUtils.java

License:Open Source License

public static void applyPermissionsWithJvm(final File file, final String mode, final Log logger) {
    final FilePermission filePermission = FilePermissionUtils.getFilePermissionFromMode(mode, logger);

    Method method;/* ww  w  .j a  v  a 2 s.c  om*/
    try {
        method = File.class.getMethod("setReadable", new Class[] { Boolean.TYPE, Boolean.TYPE });

        method.invoke(file, new Object[] { Boolean.valueOf(filePermission.isReadable()),
                Boolean.valueOf(filePermission.isOwnerOnlyReadable()) });

        method = File.class.getMethod("setExecutable", new Class[] { Boolean.TYPE, Boolean.TYPE });
        method.invoke(file, new Object[] { Boolean.valueOf(filePermission.isExecutable()),
                Boolean.valueOf(filePermission.isOwnerOnlyExecutable()) });

        method = File.class.getMethod("setWritable", new Class[] { Boolean.TYPE, Boolean.TYPE });
        method.invoke(file, new Object[] { Boolean.valueOf(filePermission.isWritable()),
                Boolean.valueOf(filePermission.isOwnerOnlyWritable()) });
    } catch (final Exception e) {
        logger.error("error calling dynamically file permissons with jvm " + e.getMessage(), e);
        throw new RuntimeException("error calling dynamically file permissons with jvm " + e.getMessage(), e);
    }
}

From source file:com.spoledge.audao.maven.GeneratorMojo.java

License:Apache License

private void generate() throws MojoExecutionException {
    Log log = getLog();

    String targetName = dbType.toUpperCase();

    log.info("AuDAO Generating from '" + src + "', to '" + dest + "', target '" + targetName + "'");

    try {//from  www  . j  a va2  s.c om
        Target target = Target.valueOf(targetName);
        InputStreamReader xmlReader = new InputStreamReader(new FileInputStream(src), "UTF-8");

        Output output = dest.getName().endsWith(".zip") ? new ZipFileOutput(dest) : new FileOutput(dest);

        Generator g = new Generator(target);
        g.setIsDebugEnabled(debug);
        g.validate(xmlReader);

        xmlReader = new InputStreamReader(new FileInputStream(src), "UTF-8");

        if (enableResources != null) {
            for (ResourceType res : enableResources) {
                g.setResourceEnabled(res, true);
            }

            if (generateDtoGwtSerializer) {
                g.setResourceEnabled(ResourceType.DTO_GWT_SERIALIZER, generateDtoGwtSerializer);
            }
        } else {
            g.setAllResourcesEnabled(true);
            g.setResourceEnabled(ResourceType.DTO_GWT_SERIALIZER, generateDtoGwtSerializer);
        }

        g.generate(pkg, xmlReader, output);

        output.finish();
    } catch (GeneratorException e) {
        if (e.isWarningOnly()) {
            log.warn(e.toString());
        } else {
            List<? extends Exception> exceptions = e.getExceptions();
            List<GeneratorException.Type> types = e.getTypes();

            for (int i = 0; i < exceptions.size(); i++) {
                switch (types.get(i)) {
                case WARNING:
                    log.warn(exceptions.get(i).toString());
                    break;

                case ERROR:
                    log.error("Error: ", exceptions.get(i));
                    break;

                default:
                    log.error("Fatal error:", exceptions.get(i));
                    break;

                }
            }

            throw new MojoExecutionException("Error (" + exceptions.size() + " nested errors)", e);
        }
    } catch (Exception e) {
        throw new MojoExecutionException("Error", e);
    }
}

From source file:com.spotify.docker.DockerBuildInformation.java

License:Apache License

private void updateGitInformation(Log log) {
    try {/*from ww w  .  j a  v  a 2  s  .  c o m*/
        final Repository repo = new Git().getRepo();
        if (repo != null) {
            this.repo = repo.getConfig().getString("remote", "origin", "url");
            final ObjectId head = repo.resolve("HEAD");
            if (head != null && !isNullOrEmpty(head.getName())) {
                this.commit = head.getName();
            }
        }
    } catch (IOException e) {
        log.error("Failed to read Git information", e);
    }
}

From source file:croche.maven.plugin.jira.AbstractJiraMojo.java

License:Apache License

public final void execute() throws MojoExecutionException, MojoFailureException {
    Log log = getLog();
    if (isSkip()) {
        log.info("Skipping Plugin execution.");
        return;/*from   w ww.ja  v a  2  s. c  om*/
    }
    try {
        JiraSoapService jiraService = getJiraSoapService();
        loadUserInfoFromSettings();
        log.debug("Logging in JIRA");
        String loginToken = jiraService.login(this.jiraUser, this.jiraPassword);
        log.debug("Logged in JIRA");
        try {
            doExecute(jiraService, loginToken);
        } finally {
            log.debug("Logging out from JIRA");
            jiraService.logout(loginToken);
            log.debug("Logged out from JIRA");
        }
    } catch (Exception e) {
        log.error("Error when executing mojo", e);
    }
}