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

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

Introduction

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

Prototype

void debug(Throwable error);

Source Link

Document

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

Usage

From source file:io.fabric8.maven.plugin.AbstractDeployMojo.java

License:Apache License

/**
 * Should we try to create an external URL for the given service?
 * <p/>//ww  w . java 2 s  . co m
 * By default lets ignore the kubernetes services and any service which does not expose ports 80 and 443
 *
 * @return true if we should create an OpenShift Route for this service.
 */
protected static boolean shouldCreateExternalURLForService(Log log, Service service, String id) {
    if ("kubernetes".equals(id) || "kubernetes-ro".equals(id)) {
        return false;
    }
    Set<Integer> ports = KubernetesHelper.getPorts(service);
    log.debug("Service " + id + " has ports: " + ports);
    if (ports.size() == 1) {
        String type = null;
        ServiceSpec spec = service.getSpec();
        if (spec != null) {
            type = spec.getType();
            if (Objects.equals(type, "LoadBalancer")) {
                return true;
            }
        }
        log.info("Not generating route for service " + id + " type is not LoadBalancer: " + type);
        return false;
    } else {
        log.info("Not generating route for service " + id
                + " as only single port services are supported. Has ports: " + ports);
        return false;
    }
}

From source file:io.fabric8.maven.plugin.AbstractDeployMojo.java

License:Apache License

protected void createIngress(Controller controller, KubernetesClient kubernetesClient,
        Collection<HasMetadata> collection) {
    String routeDomainPostfix = this.routeDomain;
    Log log = getLog();
    String namespace = clusterAccess.getNamespace();
    List<Ingress> ingressList = null;
    // lets get the routes first to see if we should bother
    try {//from   w w w.  ja va  2  s.  c  om
        IngressList ingresses = kubernetesClient.extensions().ingresses().inNamespace(namespace).list();
        if (ingresses != null) {
            ingressList = ingresses.getItems();
        }
    } catch (Exception e) {
        log.warn("Cannot load Ingress instances. Must be an older version of Kubernetes? Error: " + e, e);
        return;
    }
    List<Ingress> ingresses = new ArrayList<>();
    for (Object object : collection) {
        if (object instanceof Service) {
            Service service = (Service) object;
            if (!serviceHasIngressRule(ingressList, service)) {
                Ingress ingress = createIngressForService(routeDomainPostfix, namespace, service, log);
                if (ingress != null) {
                    ingresses.add(ingress);
                    log.info("Created ingress for " + namespace + ":" + KubernetesHelper.getName(service));
                } else {
                    log.debug("No ingress required for " + namespace + ":" + KubernetesHelper.getName(service));
                }
            } else {
                log.info("Already has ingress for service " + namespace + ":"
                        + KubernetesHelper.getName(service));
            }
        }
    }
    collection.addAll(ingresses);

}

From source file:io.fabric8.maven.plugin.mojo.build.ApplyMojo.java

License:Apache License

protected void createIngress(Controller controller, KubernetesClient kubernetesClient,
        Collection<HasMetadata> collection) {
    String routeDomainPostfix = this.routeDomain;
    Log log = getLog();
    String namespace = clusterAccess.getNamespace();
    List<Ingress> ingressList = null;
    // lets get the routes first to see if we should bother
    try {/*  ww  w.  ja va2 s.  c om*/
        IngressList ingresses = kubernetesClient.extensions().ingresses().inNamespace(namespace).list();
        if (ingresses != null) {
            ingressList = ingresses.getItems();
        }
    } catch (Exception e) {
        log.warn("Cannot load Ingress instances. Must be an older version of Kubernetes? Error: " + e, e);
        return;
    }
    List<Ingress> ingresses = new ArrayList<>();
    for (Object object : collection) {
        if (object instanceof Service) {
            Service service = (Service) object;
            if (!serviceHasIngressRule(ingressList, service)) {
                Ingress ingress = createIngressForService(routeDomainPostfix, namespace, service);
                if (ingress != null) {
                    ingresses.add(ingress);
                    log.info("Created ingress for " + namespace + ":" + KubernetesHelper.getName(service));
                } else {
                    log.debug("No ingress required for " + namespace + ":" + KubernetesHelper.getName(service));
                }
            } else {
                log.info("Already has ingress for service " + namespace + ":"
                        + KubernetesHelper.getName(service));
            }
        }
    }
    collection.addAll(ingresses);

}

From source file:io.sarl.maven.compiler.CompileMojo.java

License:Apache License

private void compileSARL() throws MojoExecutionException, MojoFailureException {
    final Log log = getLog();
    File outputDirectory = getOutput();
    log.info(Locale.getString(CompileMojo.class, "COMPILING_SARL")); //$NON-NLS-1$
    if (log.isDebugEnabled()) {
        final StringBuilder properties = new StringBuilder();
        buildPropertyString(properties);
        log.debug(properties.toString());
    }//from w ww  .j  a  va2s. co m
    // If output is not explicitly set try to read SARL prefs from eclipse .settings folder
    if (getDefaultOutput().equals(getOutput())) {
        final String settingsValue = readSarlEclipseSetting(getProject().getBuild().getSourceDirectory());
        if (settingsValue != null && !settingsValue.isEmpty()) {
            outputDirectory = new File(settingsValue);
            getLog().info(Locale.getString(CompileMojo.class, "OUTPUT_DIR_UPDATE", outputDirectory)); //$NON-NLS-1$
        }
    }
    final MavenProject project = getProject();
    final List<File> compileSourceRoots = new ArrayList<>();
    for (final String filename : project.getCompileSourceRoots()) {
        final File file = new File(filename);
        if (!file.equals(outputDirectory)) {
            compileSourceRoots.add(file);
        }
    }
    final List<File> classPath = getClassPath();
    project.addCompileSourceRoot(outputDirectory.getAbsolutePath());
    compile(classPath, compileSourceRoots, outputDirectory);
}

From source file:io.siddhi.doc.gen.core.utils.DocumentationUtils.java

License:Open Source License

/**
 * Executing a command.//from   w  w w. j a  v a  2  s. com
 *
 * @param command The command to be executed
 * @param logger  The maven plugin logger
 * @throws Throwable if any error occurs during the execution of the command
 */
private static void executeCommand(String[] command, Log logger) throws Throwable {
    List<String> executionOutputLines = getCommandOutput(command, logger);
    for (String executionOutputLine : executionOutputLines) {
        logger.debug(executionOutputLine);
    }
}

From source file:it.javalinux.sibilla.plugins.SibillaMojo.java

License:Open Source License

private void printDebugLogs(Log log, Configuration config) {
    if (log.isDebugEnabled()) {
        log.debug("Classpath:");
        for (String s : getClasspathElements()) {
            log.debug(" " + s);
        }/*from  w  ww. ja v a  2  s  . c o m*/
        log.debug("Source roots:");
        for (String root : getSourceRoots()) {
            log.debug(" " + root);
        }
        log.debug("Output directory:");
        log.debug(" " + getOutputDirectory());
        log.debug("Test classpath:");
        for (String s : getTestClasspathElements()) {
            log.debug(" " + s);
        }
        log.debug("Test source roots:");
        for (String root : getTestSourceRoots()) {
            log.debug(" " + root);
        }
        log.debug("Test output directory:");
        log.debug(" " + getTestOutputDirectory());
        log.debug("Classes under test changed since last run: ");
        for (File f : config.getChangedClassesUnderTest()) {
            log.debug(" " + f);
        }
        log.debug("Test classes changed since last run: ");
        for (File f : config.getChangedTestClasses()) {
            log.debug(" " + f);
        }
        log.debug("Provided Sibilla runner:");
        log.debug(" " + config.getRunner());
        log.debug("Provided Sibilla metadata serializer:");
        log.debug(" " + config.getSerializer());
    }
}

From source file:meme.singularsyntax.mojo.JavaflowEnhanceMojo.java

License:Open Source License

private void enhanceClassFiles(String outputDir, File backupDir, List<String> classFileNames)
        throws MojoExecutionException {

    Log log = getLog();
    ResourceTransformer transformer = new AsmClassTransformer();

    for (String classFileName : classFileNames) {
        try {//  w  w  w .j  a  v a2  s  .c  om
            File source = new File(outputDir, classFileName);
            File destination = new File(String.format(CLASSFILE_REWRITE_TEMPLATE, source.getAbsolutePath()));
            File backupClassFile = new File(backupDir, classFileName);

            if (backupClassFile.exists() && (source.lastModified() <= backupClassFile.lastModified())) {
                log.info(source + " is up to date");
                continue;
            }

            log.info(String.format("Enhancing class file bytecode for Javaflow: %s", source));
            RewritingUtils.rewriteClassFile(source, transformer, destination);

            if (backupClassFile.exists()) {
                log.debug(String.format("Backup for original class file %s already exists - removing it",
                        backupClassFile));
                backupClassFile.delete();
            }

            log.debug(String.format("Renaming original class file from %s to %s", source, backupClassFile));
            FileUtils.moveFile(source, backupClassFile);

            log.debug(String.format("Renaming rewritten class file from %s to %s", destination, source));
            FileUtils.moveFile(destination, source);

            backupClassFile.setLastModified(source.lastModified());

        } catch (IOException e) {
            throw new MojoExecutionException(e.getMessage());
        }
    }
}

From source file:net.eckenfels.mavenplugins.lockdeps.LockDependenciesMojo.java

License:Apache License

public void execute() throws MojoExecutionException {
    Log log = getLog();

    log.debug("Now scanning dependencies..." + project);

    Set<Artifact> deps = project.getArtifacts();
    for (Artifact a : deps) {
        ArtifactRepository rep = a.getRepository();
        log.info("artifact: " + a.getId() + " (" + a.getScope() + ") from " + a.getDownloadUrl() + " "
                + a.getFile() + " repid=" + ((rep != null) ? rep.getId() : null));
    }/*w ww  .j  a va 2 s.  co  m*/

    deps = project.getPluginArtifacts();
    for (Artifact a : deps) {
        log.info("plugin artifact: " + a.getId() + " (" + a.getScope() + ") from " + a.getDownloadUrl() + " "
                + a.getFile());
    }
}

From source file:net.eckenfels.mavenplugins.lockdeps.VerifyMojo.java

License:Apache License

public void execute() throws MojoExecutionException {
    final Log log = getLog();

    if (lockFile == null) {
        lockFile = new File(".dependencies.lock");
    }//from ww  w  .  j  a va 2 s.  c  o m

    if (currentFile == null) {
        currentFile = new File(".dependencies.current");
    }

    if (!lockFile.exists()) {
        if (createCurrent) {
            log.info("We do not have a lockfile " + lockFile + " will create " + currentFile);
            try {
                ProjectScanner projectScanner = new ProjectScanner(project, "SHA-1");
                projectScanner.scan();
                projectScanner.writeTo(currentFile);
            } catch (IOException ioe) {
                throw new MojoExecutionException("I/O Error while scanning artifacts", ioe);
            } catch (NoSuchAlgorithmException nsa) {
                throw new MojoExecutionException("Cannot use algorithm SHA-1", nsa);
            }
        }
    } else {
        log.debug("Found version lockfile " + lockFile + " will compare hashes...");
        //readDependencies(project);
        //readLockfile();
    }
}

From source file:net.kozelka.contentcheck.mojo.LicenseShowMojo.java

License:Open Source License

private List<MavenProject> getMavenProjectForDependencies()
        throws MojoExecutionException, MojoFailureException {
    final DependencyNode dependencyTreeNode = resolveProject();
    final Dependencies dependencies = new Dependencies(project, dependencyTreeNode, classesAnalyzer);
    final Log log = getLog();
    final RepositoryUtils repoUtils = new RepositoryUtils(log, wagonManager, settings, mavenProjectBuilder,
            factory, resolver, project.getRemoteArtifactRepositories(), project.getPluginArtifactRepositories(),
            localRepository, repositoryMetadataManager);
    final Artifact projectArtifact = project.getArtifact();
    log.info(String.format("Resolving project %s:%s:%s dependencies", projectArtifact.getGroupId(),
            projectArtifact.getArtifactId(), projectArtifact.getVersion()));
    final List<Artifact> allDependencies = dependencies.getAllDependencies();
    final List<MavenProject> mavenProjects = new ArrayList<MavenProject>();
    for (Artifact artifact : allDependencies) {
        log.debug(String.format("Resolving project information for %s:%s:%s", artifact.getGroupId(),
                artifact.getArtifactId(), artifact.getVersion()));
        try {//w  w  w .j av a  2 s . co  m
            final MavenProject mavenProject = repoUtils.getMavenProjectFromRepository(artifact);
            mavenProjects.add(mavenProject);
        } catch (ProjectBuildingException e) {
            throw new MojoFailureException(
                    String.format("Cannot get project information for artifact %s:%s:%s from repository",
                            artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()),
                    e);
        }
    }
    return mavenProjects;
}