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:biz.gabrys.maven.plugin.util.io.LoggerUtils.java

License:Open Source License

/**
 * Logs (in debug mode) information whether {@link File#isFile() normal file} is included or excluded. Logged
 * message contains the file {@link File#getAbsolutePath() absolute path}.
 * @param logger the logger./*  w  w  w. j  a  va2  s .co m*/
 * @param file the included or excluded file.
 * @param included {@code true} whether file is included, otherwise {@code false}.
 * @since 1.2
 */
public static void debugInclusion(final Log logger, final File file, final boolean included) {
    if (logger.isDebugEnabled() && file.isFile()) {
        logger.debug((included ? "Include " : "Exclude ") + file.getAbsolutePath());
    }
}

From source file:biz.paluch.maven.configurator.FileTemplating.java

License:Open Source License

/**
 * Process files which match the template pattern. Creates a new file using the input file with property
 * replacement. Target filename is without the template name part.
 *
 * @param log//  w w w .j av  a2  s .  co m
 * @param root
 * @param processor
 * @throws IOException
 */
public static void processFiles(Log log, File root, TemplateProcessor processor) throws IOException {

    Iterator<File> iterator = FileUtils.iterateFiles(root, new RegexFileFilter(FILE_TEMPLATE_PATTERN),
            TrueFileFilter.TRUE);

    while (iterator.hasNext()) {
        File next = iterator.next();
        log.debug("Processing file " + next);
        try {
            processor.processFile(next, getTargetFile(next));
        } catch (IOException e) {
            throw new IOException("Cannot process file " + next.toString() + ": " + e.getMessage(), e);
        }
    }
}

From source file:com.actility.maven.plugin.cocoon.ClassifierTypeTranslator.java

License:Apache License

public Set<Artifact> translate(Set<Artifact> artifacts, Log log) {
    Set<Artifact> results = artifacts;

    log.debug("Translating Artifacts using Classifier: " + this.classifier + " and Type: " + this.type);
    results = new HashSet<Artifact>();
    for (Artifact artifact : artifacts) {
        // this translator must pass both type and classifier here so we
        // will use the
        // base artifact value if null comes in
        String useType = null;/*  ww  w.  j  ava 2 s  . c  om*/
        if (StringUtils.isNotEmpty(this.type)) {
            useType = this.type;
        } else {
            useType = artifact.getType();
        }

        String useClassifier = null;
        if (StringUtils.isNotEmpty(this.classifier)) {
            useClassifier = this.classifier;
        } else {
            useClassifier = artifact.getClassifier();
        }

        // Create a new artifact
        Artifact newArtifact = factory.createArtifactWithClassifier(artifact.getGroupId(),
                artifact.getArtifactId(), artifact.getVersion(), useType, useClassifier);

        // note the new artifacts will always have the scope set to null. We
        // should
        // reset it here so that it will pass other filters if needed
        newArtifact.setScope(artifact.getScope());

        results.add(newArtifact);
    }

    return results;
}

From source file:com.actility.maven.plugin.cocoon.DefaultArtifactsResolver.java

License:Apache License

public Set<Artifact> resolve(Set<Artifact> artifacts, Log log) throws MojoExecutionException {

    Set<Artifact> resolvedArtifacts = new HashSet<Artifact>();
    for (Artifact artifact : artifacts) {
        try {//  ww  w  . j  a  va 2 s .  c  om
            resolver.resolve(artifact, remoteRepositories, local);
            resolvedArtifacts.add(artifact);
        } catch (ArtifactResolutionException ex) {
            // an error occurred during resolution, log it an continue
            log.debug("error resolving: " + artifact.getId());
            log.debug(ex);
            if (stopOnFailure) {
                throw new MojoExecutionException("error resolving: " + artifact.getId(), ex);
            }
        } catch (ArtifactNotFoundException ex) {
            // not found, log it and continue
            log.debug("not found in any repository: " + artifact.getId());
            if (stopOnFailure) {
                throw new MojoExecutionException("not found in any repository: " + artifact.getId(), ex);
            }
        }
    }
    return resolvedArtifacts;
}

From source file:com.akathist.maven.plugins.launch4j.Launch4jMojo.java

License:Open Source License

/**
 * Just prints out how we were configured.
 *///  ww w  .  j a  v a2 s. c  o  m
private void printState() {
    Log log = getLog();

    log.debug("headerType = " + headerType);
    log.debug("outfile = " + outfile);
    log.debug("jar = " + jar);
    log.debug("dontWrapJar = " + dontWrapJar);
    log.debug("errTitle = " + errTitle);
    log.debug("downloadUrl = " + downloadUrl);
    log.debug("supportUrl = " + supportUrl);
    log.debug("cmdLine = " + cmdLine);
    log.debug("chdir = " + chdir);
    log.debug("priority = " + priority);
    log.debug("stayAlive = " + stayAlive);
    log.debug("icon = " + icon);
    log.debug("objs = " + objs);
    log.debug("libs = " + libs);
    log.debug("vars = " + vars);
    if (singleInstance != null) {
        log.debug("singleInstance.mutexName = " + singleInstance.mutexName);
        log.debug("singleInstance.windowTitle = " + singleInstance.windowTitle);
    } else {
        log.debug("singleInstance = null");
    }
    if (jre != null) {
        log.debug("jre.path = " + jre.path);
        log.debug("jre.minVersion = " + jre.minVersion);
        log.debug("jre.maxVersion = " + jre.maxVersion);
        log.debug("jre.jdkPreference = " + jre.jdkPreference);
        log.debug("jre.initialHeapSize = " + jre.initialHeapSize);
        log.debug("jre.initialHeapPercent = " + jre.initialHeapPercent);
        log.debug("jre.maxHeapSize = " + jre.maxHeapSize);
        log.debug("jre.maxHeapPercent = " + jre.maxHeapPercent);
        log.debug("jre.opts = " + jre.opts);
    } else {
        log.debug("jre = null");
    }
    if (classPath != null) {
        log.debug("classPath.mainClass = " + classPath.mainClass);
        log.debug("classPath.addDependencies = " + classPath.addDependencies);
        log.debug("classPath.jarLocation = " + classPath.jarLocation);
        log.debug("classPath.preCp = " + classPath.preCp);
        log.debug("classPath.postCp = " + classPath.postCp);
    } else {
        log.info("classpath = null");
    }
    if (splash != null) {
        log.debug("splash.file = " + splash.file);
        log.debug("splash.waitForWindow = " + splash.waitForWindow);
        log.debug("splash.timeout = " + splash.timeout);
        log.debug("splash.timoutErr = " + splash.timeoutErr);
    } else {
        log.debug("splash = null");
    }
    if (versionInfo != null) {
        log.debug("versionInfo.fileVersion = " + versionInfo.fileVersion);
        log.debug("versionInfo.txtFileVersion = " + versionInfo.txtFileVersion);
        log.debug("versionInfo.fileDescription = " + versionInfo.fileDescription);
        log.debug("versionInfo.copyright = " + versionInfo.copyright);
        log.debug("versionInfo.productVersion = " + versionInfo.productVersion);
        log.debug("versionInfo.txtProductVersion = " + versionInfo.txtProductVersion);
        log.debug("versionInfo.productName = " + versionInfo.productName);
        log.debug("versionInfo.companyName = " + versionInfo.companyName);
        log.debug("versionInfo.internalName = " + versionInfo.internalName);
        log.debug("versionInfo.originalFilename = " + versionInfo.originalFilename);
    } else {
        log.debug("versionInfo = null");
    }
    if (messages != null) {
        log.debug("messages.startupErr = " + messages.startupErr);
        log.debug("messages.bundledJreErr = " + messages.bundledJreErr);
        log.debug("messages.jreVersionErr = " + messages.jreVersionErr);
        log.debug("messages.launcherErr = " + messages.launcherErr);
        log.debug("messages.instanceAlreadyExistsMsg = " + messages.instanceAlreadyExistsMsg);
    } else {
        log.debug("messages = null");
    }
}

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

License:Apache License

/**
 * Take the compiler executable and try to find a JRE that contains that compiler.
 *
 * @param rawExecutable the executable with the complete path.
 * @param jreMap        the map with defined JRE's.
 * @param logger        the logger to log the error's
 * @return the found container or null if non found.
 *//*from w ww. ja v  a  2 s.  c  o  m*/
private String getContainerFromExecutable(String rawExecutable, Map jreMap, Log logger) {
    String foundContainer = null;
    if (rawExecutable != null) {
        String executable;
        try {
            executable = new File(rawExecutable).getCanonicalPath();
            logger.debug("detected executable: " + executable);
        } catch (Exception e) {
            return null;
        }
        File executableFile = new File(executable);
        while (executableFile != null) {
            foundContainer = (String) jreMap.get(executableFile.getPath());
            if (foundContainer != null) {
                logger.debug("detected classpathContainer from executable: " + foundContainer);
                return foundContainer;
            }
            executableFile = executableFile.getParentFile();
        }
    }
    return null;
}

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

License:Apache License

/**
 * Search the default JREContainer from eclipse for the current MavenProject
 *
 * @param workspaceLocation the location of the workspace.
 * @param project           the maven project the get the configuration
 * @param logger            the logger for errors
 *//* w  ww.ja  v  a 2s  . c  om*/
private void detectDefaultJREContainer(WorkspaceConfiguration workspaceConfiguration, MavenProject project,
        Log logger) {
    String defaultJREContainer = ReadWorkspaceLocations.CLASSPATHENTRY_DEFAULT;
    if (workspaceConfiguration.getWorkspaceDirectory() != null) {
        Map jreMap = readAvailableJREs(workspaceConfiguration.getWorkspaceDirectory(), logger);
        if (jreMap != null) {
            String foundContainer = getContainerFromExecutable(System.getProperty("maven.compiler.executable"),
                    jreMap, logger);
            if (foundContainer == null) {
                foundContainer = getContainerFromExecutable(
                        IdeUtils.getCompilerPluginSetting(project, "executable"), jreMap, logger);
            }
            if (foundContainer == null) {
                String sourceVersion = IdeUtils.getCompilerSourceVersion(project);
                foundContainer = (String) jreMap.get(sourceVersion);
                if (foundContainer != null) {
                    logger.debug("detected classpathContainer from sourceVersion(" + sourceVersion + "): "
                            + foundContainer);
                }
            }
            if (foundContainer == null) {
                foundContainer = getContainerFromExecutable(System.getProperty("java.home"), jreMap, logger);
            }
            if (foundContainer != null) {
                defaultJREContainer = foundContainer;
            }
        }
    }
    workspaceConfiguration.setDefaultClasspathContainer(defaultJREContainer);
}

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

License:Apache License

/**
 * Read the artefact information from the pom in the project location and the eclipse project name from the .project
 * file.//  w ww  .  ja v a2 s . c  o m
 *
 * @param projectLocation the location of the project
 * @param logger          the logger to report errors and debug info.
 * @return an {@link IdeDependency} or null.
 * @throws FileNotFoundException
 * @throws XmlPullParserException
 * @throws IOException
 */
private IdeDependency readArtefact(File projectLocation, Log logger)
        throws FileNotFoundException, XmlPullParserException, IOException {
    File projectFile = new File(projectLocation, ".project");
    String eclipseProjectName = projectLocation.getName();
    if (projectFile.exists()) {
        Xpp3Dom project = Xpp3DomBuilder.build(new FileReader(projectFile));
        eclipseProjectName = getValue(project, new String[] { "name" }, eclipseProjectName);
    }
    File pomFile = new File(projectLocation, "pom.xml");
    if (pomFile.exists()) {
        Xpp3Dom pom = Xpp3DomBuilder.build(new FileReader(pomFile));

        String artifact = getValue(pom, ReadWorkspaceLocations.ARTEFACT_ID, null);
        String group = getValue(pom, ReadWorkspaceLocations.GROUP_ID,
                getValue(pom, ReadWorkspaceLocations.PARENT_GROUP_ID, null));
        String version = getValue(pom, ReadWorkspaceLocations.VERSION,
                getValue(pom, ReadWorkspaceLocations.PARENT_VERSION, null));
        String packaging = getValue(pom, ReadWorkspaceLocations.PACKAGING, "jar");

        logger.debug("found workspace artefact " + group + ":" + artifact + ":" + version + " " + packaging
                + " (" + eclipseProjectName + ")" + " -> " + projectLocation.getAbsolutePath());
        return new IdeDependency(group, artifact, version, packaging, true, false, false, false, false, null,
                packaging, false, null, 0, eclipseProjectName);
    } else {
        logger.debug("ignored workspace project NO pom available " + projectLocation.getAbsolutePath());
        return null;
    }
}

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

License:Apache License

HashMap readDefinedServers(WorkspaceConfiguration workspaceConfiguration, Log logger) {
    HashMap detectedRuntimes = new HashMap();
    if (workspaceConfiguration.getWorkspaceDirectory() != null) {
        Xpp3Dom runtimesElement = null;//from  w  w w. ja v a  2  s  .  co  m
        try {
            File prefs = new File(workspaceConfiguration.getWorkspaceDirectory(),
                    ReadWorkspaceLocations.METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_SERVER_PREFS);
            if (prefs.exists()) {
                Properties properties = new Properties();
                properties.load(new FileInputStream(prefs));
                String runtimes = properties.getProperty(
                        ReadWorkspaceLocations.METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_PREFS_RUNTIMES_KEY);
                if (runtimes != null) {
                    runtimesElement = Xpp3DomBuilder.build(new StringReader(runtimes));
                }
            }
        } catch (Exception e) {
            logger.error("Could not read workspace wtp server runtimes preferences : " + e.getMessage());
        }

        if (runtimesElement != null) {
            Xpp3Dom[] runtimeArray = runtimesElement.getChildren("runtime");
            for (int index = 0; runtimeArray != null && index < runtimeArray.length; index++) {
                String id = runtimeArray[index].getAttribute("id");
                String name = runtimeArray[index].getAttribute("name");
                if (detectedRuntimes.isEmpty()) {
                    logger.debug("Using WTP runtime with id: \"" + id + "\" as default runtime");
                    detectedRuntimes.put("", id);
                }
                detectedRuntimes.put(id, name);
                logger.debug("Detected WTP runtime with id: \"" + id + "\" and name: \"" + name + "\"");
            }
        }
    }
    return detectedRuntimes;
}

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//  www  .  jav  a 2s.c  o  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;
}