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.jahia.utils.maven.plugin.support.MavenAetherHelperUtils.java

License:Open Source License

public static Set<PackageInfo> getJarPackages(File jarFile, boolean optionalJar, String version,
        ParsingContext parsingContext, Log log) {
    JarInputStream jarInputStream = null;
    Set<PackageInfo> packageInfos = new LinkedHashSet<PackageInfo>();
    if (jarFile == null) {
        log.warn("File is null !");
        return packageInfos;
    }//w  w  w .ja  v  a  2 s  . c  o m
    if (!jarFile.exists()) {
        log.warn("File " + jarFile + " does not exist !");
        return packageInfos;
    }
    log.debug("Scanning JAR " + jarFile + "...");
    try {
        jarInputStream = new JarInputStream(new FileInputStream(jarFile));
        JarEntry jarEntry = null;
        while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
            String jarPackageName = jarEntry.getName().replaceAll("/", ".");
            if (jarPackageName.endsWith(".")) {
                jarPackageName = jarPackageName.substring(0, jarPackageName.length() - 1);
            }
            if (jarPackageName.startsWith("META-INF") || jarPackageName.startsWith("WEB-INF")
                    || jarPackageName.startsWith("OSGI-INF")) {
                continue;
            }
            packageInfos.addAll(PackageUtils.getPackagesFromClass(jarPackageName, optionalJar, version,
                    jarFile.getCanonicalPath(), parsingContext));
        }
    } catch (IOException e) {
        log.error(e);
        ;
    } finally {
        IOUtils.closeQuietly(jarInputStream);
    }
    return packageInfos;
}

From source file:org.janus_project.janus_maven_plugin.util.Utils.java

License:Open Source License

/**
 * Replies the dependency files for an OSGi module.
 * // w w  w . ja v a2  s  .c o  m
 * @param log
 *            - logger used to output errors if any
 * @param artifacts
 *            - the set of artificats, we wants to determine their dependencies
 * @param excludedArtifacts  - the list of excluded artifacts
 * @return a list of file correspodning to the dependencies of the specfied set of artifacts
 */
public static Set<File> getOsgiDependencyFiles(Log log, Set<Artifact> artifacts,
        List<String> excludedArtifacts) {
    Set<File> result = new HashSet<File>();
    Iterator<Artifact> i = artifacts.iterator();
    Artifact a;

    if (excludedArtifacts != null && excludedArtifacts.size() > 0) {
        while (i.hasNext()) {
            a = i.next();
            if (isOSGiBundle(a.getFile())) {
                if (!excludedArtifacts.contains(a.getArtifactId())) {// verify if the dependencies is not in the excluded artifiacts
                    result.add(a.getFile());
                    log.warn("Copying " + a.toString()); //$NON-NLS-1$ 
                } else {
                    log.warn("Excluding " + a.toString()); //$NON-NLS-1$ 
                }
            } else {
                StringBuilder buffer = new StringBuilder();
                buffer.append("Ignoring Artifact ["); //$NON-NLS-1$
                buffer.append(a.getGroupId());
                buffer.append(":"); //$NON-NLS-1$
                buffer.append(a.getArtifactId());
                buffer.append(":"); //$NON-NLS-1$
                buffer.append(a.getVersion());
                buffer.append("] because it does not contain a Manifest. It can not be an OSGi bundle."); //$NON-NLS-1$
                log.warn(buffer.toString());
            }
        }
    } else {
        while (i.hasNext()) {
            a = i.next();
            if (isOSGiBundle(a.getFile())) {
                result.add(a.getFile());
            } else {
                StringBuilder buffer = new StringBuilder();
                buffer.append("Ignoring Artifact ["); //$NON-NLS-1$
                buffer.append(a.getGroupId());
                buffer.append(":"); //$NON-NLS-1$
                buffer.append(a.getArtifactId());
                buffer.append(":"); //$NON-NLS-1$
                buffer.append(a.getVersion());
                buffer.append("] because it does not contain a Manifest. It can not be an OSGi bundle."); //$NON-NLS-1$
                log.warn(buffer.toString());
            }
        }
    }

    return result;
}

From source file:org.jasig.maven.notice.AbstractNoticeMojo.java

License:Apache License

public final void execute() throws MojoExecutionException, MojoFailureException {
    final Log logger = this.getLog();

    if (this.skipChecks) {
        logger.info("NOTICE file checks are skipped.");
        return;//from w  w  w .  ja va 2 s. c  om
    }

    if (licenseLookup != null && licenseLookup.length > 0) {
        logger.warn("'licenseLookup' configuration property is deprecated use 'licenseMapping' instead");
        if (licenseMapping != null && licenseMapping.length > 0) {
            throw new MojoFailureException(
                    "Both 'licenseMapping' and 'licenseLookup' configuration properties configured. Only one may be used.");
        }
        licenseMapping = licenseLookup;
    }

    //Check if NOTICE for child modules should be generated
    if (!this.generateChildNotices && !this.project.isExecutionRoot()) {
        return;
    }

    final ResourceFinder finder = this.getResourceFinder();

    final LicenseLookupHelper licenseLookupHelper = new LicenseLookupHelper(logger, finder, licenseMapping);

    final List<?> remoteArtifactRepositories = project.getRemoteArtifactRepositories();

    final LicenseResolvingNodeVisitor visitor = new LicenseResolvingNodeVisitor(logger, licenseLookupHelper,
            remoteArtifactRepositories, this.mavenProjectBuilder, this.localRepository);

    this.parseProject(this.project, visitor);

    //Check for any unresolved artifacts
    final Set<Artifact> unresolvedArtifacts = visitor.getUnresolvedArtifacts();
    this.checkUnresolved(unresolvedArtifacts);

    //Convert the resovled notice data into a String
    final Map<String, String> resolvedLicenses = visitor.getResolvedLicenses();
    final String noticeLines = this.generateNoticeLines(resolvedLicenses);
    final String noticeTemplateContents = this.readNoticeTemplate(finder);

    //Replace the template placeholder with the generated notice data
    final String noticeContents = noticeTemplateContents
            .replaceAll(Pattern.quote(this.noticeTemplatePlaceholder), noticeLines);

    //Let the subclass deal with the generated NOTICE file
    this.handleNotice(finder, noticeContents);
}

From source file:org.jbehave.site.JBehaveMojo.java

License:Apache License

@Override
protected void executeReport(Locale arg0) throws MavenReportException {
    Log log = getLog();
    if (sourceDirectory.exists()) {
        FreemarkerViewGenerator view = new FreemarkerViewGenerator();
        view.generateReportsView(sourceDirectory, getFormats(), getViewResources());
        ReportsCount count = view.getReportsCount();
        log.info("Generated " + count.getStories() + " stories with " + count.getScenarios() + " scenarios");
        log.info("Stories: " + (count.getStories() - count.getStoriesNotAllowed() - count.getStoriesPending())
                + " success " + count.getStoriesPending() + " pending " + count.getStoriesNotAllowed()
                + " not allowed");
        log.info("Scenarios: "
                + (count.getScenarios() - count.getScenariosNotAllowed() - count.getScenariosPending()
                        + count.getScenariosFailed())
                + " success " + count.getScenariosPending() + " pending " + count.getScenariosFailed()
                + " failed " + count.getScenariosNotAllowed() + " not allowed");
        external = true;/*from w ww  .  j  ava 2 s. c  o  m*/
        try {
            unpackViewResource();
            copyCss();
        } catch (IOException e) {
            log.warn(e);
        } catch (NoSuchElementException e) {
            log.warn(e);
        } catch (NullPointerException e) {
            log.warn(e);
        }
    } else {
        log.info("No story to report.");
        Sink sink = getSink();
        sink.body();
        sink.section1();
        sink.sectionTitle1();
        sink.text("No story to report.");
        sink.sectionTitle1_();
        sink.section1_();
        sink.body_();
        sink.flush();
        sink.close();
        external = false;
    }
}

From source file:org.jboss.maven.plugins.qstools.AbstractProjectWalker.java

License:Apache License

@SuppressWarnings("unchecked")
public void walk(WalkType walkType, MavenProject project, MavenSession mavenSession,
        List<MavenProject> reactorProjects, Log log, Map<String, List<Violation>> results)
        throws QSToolsException {
    this.mavenSession = mavenSession;
    this.log = log;
    try {//  w ww  . jav  a2s .co m
        List<String> ignoredQuickstarts = (List<String>) context.get(Constants.IGNORED_QUICKSTARTS_CONTEXT);
        if (configurationProvider.getQuickstartsRules(project.getGroupId()).isCheckerIgnored(this.getClass())) {
            setCheckerMessage("This checker is ignored for this groupId in config file.");
        } else {
            for (MavenProject mavenProject : reactorProjects) {
                if (!ignoredQuickstarts.contains(mavenProject.getBasedir().getName())) {
                    Document doc = PositionalXMLReader.readXML(new FileInputStream(mavenProject.getFile()));
                    switch (walkType) {
                    case CHECK:
                        checkProject(mavenProject, doc, results);
                        break;
                    case FIX:
                        fixProject(mavenProject, doc);
                        break;
                    default:
                        break;
                    }
                } else {
                    log.warn("Ignoring " + mavenProject.getBasedir().getName()
                            + ". It is listed on .quickstarts_ignore file");
                }
            }
        }
    } catch (Exception e) {
        // Any other exception is a problem.
        throw new QSToolsException(e);
    }
}

From source file:org.jboss.maven.plugins.qstools.checkers.AbstractProjectChecker.java

License:Apache License

@Override
@SuppressWarnings("unchecked")
public Map<String, List<Violation>> check(MavenProject project, MavenSession mavenSession,
        List<MavenProject> reactorProjects, Log log) throws QSCheckerException {
    this.mavenSession = mavenSession;
    this.log = log;
    Map<String, List<Violation>> results = new TreeMap<String, List<Violation>>();
    try {// w  ww. jav  a  2 s.c o  m
        List<String> ignoredQuickstarts = (List<String>) context.get(Constants.IGNORED_QUICKSTARTS_CONTEXT);
        for (MavenProject mavenProject : reactorProjects) {
            if (!ignoredQuickstarts.contains(mavenProject.getBasedir().getName())) {
                Document doc = PositionalXMLReader.readXML(new FileInputStream(mavenProject.getFile()));
                if (configurationProvider.getQuickstartsRules(project.getGroupId()).isCheckerIgnored(this)) {
                    String msg = "Skiping %s for %s:%s";
                    log.warn(String.format(msg, this.getClass().getSimpleName(), project.getGroupId(),
                            project.getArtifactId()));
                } else {
                    processProject(mavenProject, doc, results);
                }
            } else {
                log.debug("Ignoring " + mavenProject.getBasedir().getName()
                        + ". It is listed on .quickstarts_ignore file");
            }
        }
        if (violationsQtd > 0) {
            log.info("There are " + violationsQtd + " checkers errors");
        }
    } catch (Exception e) {
        // Any other exception is a problem.
        throw new QSCheckerException(e);
    }
    return results;
}

From source file:org.jboss.provisioning.wildfly.build.FeatureSpecFilter.java

License:Apache License

private static boolean sameCapabilities(Set<CapabilitySpec> standaloneCaps, Set<CapabilitySpec> domainCaps,
        Log log) {
    final Set<String> domain = domainCaps.stream().map(CapabilitySpec::toString)
            .map(s -> s.startsWith("$profile.") ? s.substring(9) : s).collect(Collectors.toSet());
    final Set<String> capabilities = standaloneCaps.stream().map(CapabilitySpec::toString)
            .filter(s -> !domain.contains(s)).collect(Collectors.toSet());
    capabilities.forEach(s -> log.warn("We haven't found the capability " + s + " in domain spec"));
    return capabilities.isEmpty();
}

From source file:org.jboss.provisioning.wildfly.build.FeatureSpecFilter.java

License:Apache License

private static boolean samePackages(FeatureSpec standalone, FeatureSpec domain, Log log) {
    if (standalone.hasFeatureDeps() && domain.hasFeatureDeps()) {
        Set<FeatureDependencySpec> packages = standalone.getFeatureDeps().stream()
                .filter(s -> !domain.getFeatureDeps().contains(s)).collect(Collectors.toSet());
        packages.forEach(s -> log.warn("We haven't found the package " + s + " in domain spec"));
        return packages.isEmpty();
    }//from  ww w. ja  v a2s  .  c o  m
    return standalone.hasFeatureDeps() == domain.hasFeatureDeps();
}

From source file:org.jboss.provisioning.wildfly.build.ModuleXmlVersionResolver.java

License:Apache License

private static StartElement convertArtifactElement(XMLEventFactory eventFactory, StartElement artifactElement,
        Map<String, Artifact> artifacts, Log log) {
    List<Attribute> attributes = new ArrayList<>();
    Iterator<?> iter = artifactElement.getAttributes();
    while (iter.hasNext()) {
        Attribute attribute = (Attribute) iter.next();
        if ("name".equals(attribute.getName().getLocalPart())) {
            String artifactName = attribute.getValue();
            String artifactCoords = getArtifactCoordinates(artifactName);
            if (artifactCoords != null) {
                Artifact artifact = artifacts.get(artifactCoords);
                if (artifact == null) {
                    log.warn("Couldn't find an artifact in the dependencies to reolve " + artifactCoords);
                    attributes.add(attribute);
                } else {
                    StringJoiner joiner = new StringJoiner(":");
                    joiner.add(artifact.getGroupId());
                    joiner.add(artifact.getArtifactId());
                    joiner.add(artifact.getVersion());
                    if (artifact.hasClassifier()) {
                        joiner.add(artifact.getClassifier());
                    }//from  w  w w  .  j  a  v a2  s.c  om
                    attributes.add(eventFactory.createAttribute(attribute.getName(), joiner.toString()));
                }
            } else {
                attributes.add(attribute);
            }
        } else {
            attributes.add(attribute);
        }
    }
    return eventFactory.createStartElement(artifactElement.getName(), attributes.iterator(),
            artifactElement.getNamespaces());
}

From source file:org.kaazing.license.maven.plugin.VerifyNotice.java

License:Open Source License

/**
 * Recursively load all dependencies of this project (not in the test scope) and adds them to the mavenDependencies
 * @param mavenDependencies/*from   w  ww  . j ava 2s.  c  o m*/
 * @param project
 */
private void loadAllDepenencyProject(Set<MavenProject> mavenDependencies, MavenProject project) {
    Log log = getLog();

    if (!mavenDependencies.contains(project)) {
        Set<Artifact> artifacts = getDependencyArtifacts(project);
        // artifacts.addAll(getTestDependencies(project));
        for (Artifact artifact : artifacts) {
            // if (artifact != null) {
            try {
                MavenProject depProject = mavenProjectBuilder.buildFromRepository(artifact,
                        remoteArtifactRepositories, localRepository, true);
                loadAllDepenencyProject(mavenDependencies, depProject);
                mavenDependencies.add(depProject);
            } catch (ProjectBuildingException e) {
                log.warn("Could not find a pom for the artifact: " + artifact.getGroupId() + ":"
                        + artifact.getArtifactId());
                continue;
            }
            // }
        }
    }
    return;
}