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

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

Introduction

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

Prototype

void warn(Throwable error);

Source Link

Document

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

Usage

From source file:org.acmsl.queryj.tools.maven.AntProjectAdapter.java

License:Open Source License

/**
 * See {@link Project#log(Task, String, int)}.
 * @param task the task.//from   ww  w  .  j  a  va 2s .com
 * @param message the message.
 * @param msgLevel either {@link Project#MSG_ERR}, {@link Project#MSG_WARN},
 * {@link Project#MSG_INFO}, {@link Project#MSG_VERBOSE}, or {@link Project#MSG_DEBUG}.
 * @param log the {@link Log} instance.
 */
protected void log(@NotNull final Task task, @NotNull final String message, final int msgLevel,
        @NotNull final Log log) {
    @NotNull
    final String t_strMessage = "[" + task.getTaskName() + "] " + message;

    switch (msgLevel) {
    case MSG_ERR:
        log.error(t_strMessage);
        break;
    case MSG_WARN:
        log.warn(t_strMessage);
        break;
    case MSG_VERBOSE:
    case MSG_DEBUG:
        log.debug(t_strMessage);
        break;
    default:
        log.info(t_strMessage);
        break;
    }
}

From source file:org.acmsl.queryj.tools.maven.AntProjectAdapter.java

License:Open Source License

/**
 * See {@link Project#log(Target, String, int)}.
 * @param target the target.//from ww  w  .  jav a 2s  .co m
 * @param message the message.
 * @param msgLevel either {@link Project#MSG_ERR}, {@link Project#MSG_WARN},
 * {@link Project#MSG_INFO}, {@link Project#MSG_VERBOSE}, or {@link Project#MSG_DEBUG}.
 * @param log the {@link Log} instance.
 */
protected void log(@NotNull final Target target, @NotNull final String message, final int msgLevel,
        @NotNull final Log log) {
    @NotNull
    final String t_strMessage = "[" + target.getName() + "] " + message;

    switch (msgLevel) {
    case MSG_ERR:
        log.error(t_strMessage);
        break;
    case MSG_WARN:
        log.warn(t_strMessage);
        break;
    case MSG_VERBOSE:
    case MSG_DEBUG:
        log.debug(t_strMessage);
        break;
    default:
        log.info(t_strMessage);
        break;
    }
}

From source file:org.acmsl.queryj.tools.maven.CommonsLoggingMavenLogAdapter.java

License:Open Source License

/**
 * <p> Log a message with warn log level. </p>
 * @param message log this message.//from w ww. j av a2 s  .c  o  m
 * @param mavenLog the actual {@link Log} used for logging.
 */
protected void warn(@NotNull final Object message, @NotNull final Log mavenLog) {
    mavenLog.warn(message.toString());
}

From source file:org.acmsl.queryj.tools.maven.CommonsLoggingMavenLogAdapter.java

License:Open Source License

/**
 * <p> Log a message with warn log level. </p>
 * @param warn the warn to log.//from  w  ww .  j  av  a 2 s .co m
 * @param mavenLog the actual {@link Log} used for logging.
 */
protected void warn(@NotNull final Throwable warn, @NotNull final Log mavenLog) {
    mavenLog.warn(warn);
}

From source file:org.acmsl.queryj.tools.maven.QueryJMojo.java

License:Open Source License

/**
 * Executes QueryJ via Maven2./*from   w ww. jav a2 s .com*/
 * @param log the Maven log.
 * @param version the QueryJ version.
 * @throws MojoExecutionException if the process fails.
 */
protected void execute(@NotNull final Log log, final String version) throws MojoExecutionException {
    boolean running = false;

    @Nullable
    final File outputDirPath = getOutputDir();

    @Nullable
    final QueryJTask task;

    if (outputDirPath != null) {
        //initialize directories
        @NotNull
        final File outputDir = outputDirPath.getAbsoluteFile();

        if ((!outputDir.exists()) && (!outputDir.mkdirs())) {
            log.warn("Cannot create output folder: " + outputDir);
        }

        //execute task
        task = buildTask(version, log);

        log.info("Running QueryJ " + version);

        task.execute();

        running = true;
    } else {
        log.error("outputDir is null");
    }

    if (!running) {
        log.error("NOT running QueryJ " + version);
        throw new MojoExecutionException("QueryJ could not start");
    }
}

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;
    }/*  ww  w. jav  a 2s. co  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 {/*w  w w. j a va  2s .  c om*/
        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.felix.bundleplugin.BundlePlugin.java

License:Apache License

protected static void includeMavenResources(MavenProject currentProject, Analyzer analyzer, Log log) {
    // pass maven resource paths onto BND analyzer
    final String mavenResourcePaths = getMavenResourcePaths(currentProject);
    final String includeResource = (String) analyzer.getProperty(Analyzer.INCLUDE_RESOURCE);
    if (includeResource != null) {
        if (includeResource.indexOf(MAVEN_RESOURCES) >= 0) {
            // if there is no maven resource path, we do a special treatment and replace
            // every occurance of MAVEN_RESOURCES and a following comma with an empty string
            if (mavenResourcePaths.length() == 0) {
                String cleanedResource = removeTagFromInstruction(includeResource, MAVEN_RESOURCES);
                if (cleanedResource.length() > 0) {
                    analyzer.setProperty(Analyzer.INCLUDE_RESOURCE, cleanedResource);
                } else {
                    analyzer.unsetProperty(Analyzer.INCLUDE_RESOURCE);
                }//from   w w  w  .ja  v  a2s.  c  om
            } else {
                String combinedResource = StringUtils.replace(includeResource, MAVEN_RESOURCES,
                        mavenResourcePaths);
                analyzer.setProperty(Analyzer.INCLUDE_RESOURCE, combinedResource);
            }
        } else if (mavenResourcePaths.length() > 0) {
            log.warn(Analyzer.INCLUDE_RESOURCE + ": overriding " + mavenResourcePaths + " with "
                    + includeResource + " (add " + MAVEN_RESOURCES
                    + " if you want to include the maven resources)");
        }
    } else if (mavenResourcePaths.length() > 0) {
        analyzer.setProperty(Analyzer.INCLUDE_RESOURCE, mavenResourcePaths);
    }
}

From source file:org.apache.felix.bundleplugin.BundlePlugin.java

License:Apache License

protected void mergeMavenManifest(MavenProject currentProject, Jar jar, String[] removeHeaders, Log log)
        throws IOException {
    boolean addMavenDescriptor = true;

    try {//  w w  w. ja va  2s.  c om
        /*
         * Grab customized manifest entries from the maven-jar-plugin configuration
         */
        MavenArchiveConfiguration archiveConfig = JarPluginConfiguration
                .getArchiveConfiguration(currentProject);
        String mavenManifestText = new MavenArchiver().getManifest(currentProject, archiveConfig).toString();
        addMavenDescriptor = archiveConfig.isAddMavenDescriptor();

        Manifest mavenManifest = new Manifest();

        // First grab the external manifest file (if specified)
        File externalManifestFile = archiveConfig.getManifestFile();
        if (null != externalManifestFile && externalManifestFile.exists()) {
            InputStream mis = new FileInputStream(externalManifestFile);
            mavenManifest.read(mis);
            mis.close();
        }

        // Then apply the customized entries from the jar plugin
        mavenManifest.read(new StringInputStream(mavenManifestText));

        if (!archiveConfig.isManifestSectionsEmpty()) {
            /*
             * Add customized manifest sections (for some reason MavenArchiver doesn't do this for us)
             */
            List sections = archiveConfig.getManifestSections();
            for (Iterator i = sections.iterator(); i.hasNext();) {
                ManifestSection section = (ManifestSection) i.next();
                Attributes attributes = new Attributes();

                if (!section.isManifestEntriesEmpty()) {
                    Map entries = section.getManifestEntries();
                    for (Iterator j = entries.entrySet().iterator(); j.hasNext();) {
                        Map.Entry entry = (Map.Entry) j.next();
                        attributes.putValue((String) entry.getKey(), (String) entry.getValue());
                    }
                }

                mavenManifest.getEntries().put(section.getName(), attributes);
            }
        }

        Attributes mainMavenAttributes = mavenManifest.getMainAttributes();
        mainMavenAttributes.putValue("Created-By", "Apache Maven Bundle Plugin");

        // apply -removeheaders to the custom manifest
        for (int i = 0; i < removeHeaders.length; i++) {
            for (Iterator j = mainMavenAttributes.keySet().iterator(); j.hasNext();) {
                if (j.next().toString().matches(removeHeaders[i].trim())) {
                    j.remove();
                }
            }
        }

        /*
         * Overlay generated bundle manifest with customized entries
         */
        Manifest bundleManifest = jar.getManifest();
        bundleManifest.getMainAttributes().putAll(mainMavenAttributes);
        bundleManifest.getEntries().putAll(mavenManifest.getEntries());
        jar.setManifest(bundleManifest);
    } catch (Exception e) {
        log.warn("Unable to merge Maven manifest: " + e.getLocalizedMessage());
    }

    if (addMavenDescriptor) {
        doMavenMetadata(currentProject, jar);
    }
}

From source file:org.apache.felix.obrplugin.ObrIndex.java

License:Apache License

public void execute() throws MojoExecutionException {
    Log log = getLog();
    try {/*from   w  w w  .j  av  a2 s. co  m*/
        log.info("Indexing...");

        String repo = mavenRepository;
        if (repo == null) {
            repo = localRepository.getBasedir();
        }
        URI mavenRepoUri = new File(repo).toURI();

        URI repositoryXml = ObrUtils.findRepositoryXml(repo, obrRepository);

        log.info("Repository:   " + mavenRepoUri);
        log.info("OBR xml:      " + repositoryXml);
        log.info("URL template: " + urlTemplate);

        List<File> files = new ArrayList<File>();
        findAllJars(new File(repo), files);

        DataModelHelperImpl dmh = new DataModelHelperImpl();
        RepositoryImpl repository;

        File obrRepoFile = new File(repositoryXml);
        if (obrRepoFile.isFile()) {
            repository = (RepositoryImpl) dmh.repository(repositoryXml.toURL());
        } else {
            repository = new RepositoryImpl();
        }

        for (File file : files) {
            try {
                ResourceImpl resource = (ResourceImpl) dmh.createResource(file.toURI().toURL());
                if (resource != null) {
                    repository.addResource(resource);
                    doTemplate(mavenRepoUri, file, resource);
                    log.info("Adding resource: " + file);
                } else {
                    log.info("Ignoring non OSGi bundle: " + file);
                }
            } catch (Exception e) {
                log.warn("Error processing bundle: " + file + " " + e.getMessage());
            }
        }
        Writer writer = new FileWriter(obrRepoFile);
        try {
            dmh.writeRepository(repository, writer);
        } finally {
            writer.close();
        }
    } catch (Exception e) {
        log.warn("Exception while updating local OBR: " + e.getLocalizedMessage(), e);
    }
}