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

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

Introduction

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

Prototype

boolean isDebugEnabled();

Source Link

Usage

From source file:apparat.embedding.maven.MavenLogAdapter.java

License:Open Source License

/**
 * Maps the level of a given Maven log to a corresponding
 * Apparat log level./*from  w  w w . j  av a  2s . c o m*/
 *
 * @param log The current Maven log.
 * @return The corresponding Apparat log level.
 */
public static LogLevel mapLevelOf(final org.apache.maven.plugin.logging.Log log) {
    //
    // We return an instance of a Scala case object here.
    //

    if (log.isDebugEnabled()) {
        return Debug$.MODULE$;
    } else if (log.isInfoEnabled()) {
        return Info$.MODULE$;
    } else if (log.isWarnEnabled()) {
        return Warning$.MODULE$;
    } else if (log.isErrorEnabled()) {
        return Error$.MODULE$;
    } else {
        return Off$.MODULE$;
    }
}

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.//from   w  w w .  ja va 2 s . c om
 * @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:com.ariht.maven.plugins.config.ConfigGenerationMojo.java

License:Apache License

/**
 * Clear target io and create new scripts and config io.
 *///from   w w w  .ja  v  a  2  s  .  co  m
public void execute() throws MojoExecutionException, MojoFailureException {
    final Log log = getLog();
    Preconditions.checkNotNull(log);

    final ConfigGeneratorParameters parameters = new ConfigGeneratorParametersBuilder(log)
            .withEncoding(encoding).withTemplatesBasePath(templatesBasePath)
            .withFiltersBasePath(filtersBasePath).withExternalFilterBasePaths(externalFilterBasePaths)
            .withOutputBasePath(outputBasePath).isWithLogOutput(logOutput)
            .withTemplatesToIgnore(templatesToIgnore).withFiltersToIgnore(filtersToIgnore)
            .withFilterSourcePropertyName(filterSourcePropertyName).withPropertyPrefix(propertyPrefix)
            .withPropertySuffix(propertySuffix).isWithFailOnMissingProperty(failOnMissingProperty).build();
    if (log.isDebugEnabled()) {
        log.debug("configGeneratorParameters: [" + parameters.toString() + "]");
    }

    final ConfigGeneratorImpl configGenerator = new ConfigGeneratorImpl(log, parameters);
    if (log.isDebugEnabled()) {

    }
    configGenerator.processFiltersIntoTemplates();

}

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 {//from  ww  w. j  a va  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.codetroopers.maven.mergeprops.MergeProperty.java

License:Apache License

static boolean checkKeys(final String propertyFileName, final String[] excludeKeyCheck, final String fileName,
        final Log log) throws MojoExecutionException, MojoFailureException {
    if (propertyFileName == null) {
        throw new NullPointerException("PropertyFileName can not be null ! ");
    }//from ww w .jav  a 2s.  c om
    // Do not reuse the existing inputstream as the load method forwards it and there is no reset() in FIS
    String prefixToConsider = extractFilePrefix(propertyFileName);
    if (log.isDebugEnabled()) {
        log.debug("Prefix to consider : " + prefixToConsider);
    }
    if (excludeKeyCheck != null) {
        for (String s : excludeKeyCheck) {
            if (prefixToConsider.matches(s)) {
                log.info("Found propertyFileName without prefix checking, including... [" + propertyFileName
                        + "]");
                return true;
            }
        }
    }
    Properties props = new Properties();
    InputStream input = null;
    try {
        input = new FileInputStream(fileName);
        props.load(input);
        return !containsInvalidPrefix(prefixToConsider, props);
    } catch (IOException e) {
        throw new MojoExecutionException("Could not read from file: " + propertyFileName, e);
    } finally {
        if (input != null) {
            try {
                input.close();
            } catch (IOException ioe) {
                //do nothing
            }
        }
    }
}

From source file:com.codspire.mojo.artifactlookup.ArtifactLookupMojo.java

License:Apache License

/**
 * Searches the local artifacts specified through "artifactLocation" in
 * "remoteArtifactRepositories" or "repositoryUrl" and generates the search
 * results.//from  w  w  w.ja  v  a 2 s.  c  o  m
 * 
 */
protected void lookupArtifacts() {
    Log log = getLog();

    validateRemoteArtifactRepositories();
    validateArtifactLocation();

    List<String> remoteArtifactRepositoriesURL = getRemoteArtifactRepositoriesURL();

    log.info(artifactLocation.getAbsolutePath() + " is file = " + artifactLocation.isFile());

    if (log.isDebugEnabled()) {
        log.debug("Remote Artifact Repositories");
        log.debug((remoteArtifactRepositories != null) ? remoteArtifactRepositories.toString()
                : "remoteArtifactRepositories is null");
    }

    LookupForDependency lookupForDependency = new LookupForDependency(artifactLocation, recursive,
            remoteArtifactRepositoriesURL, outputDirectory, log);
    lookupForDependency.process();
}

From source file:com.edugility.h2.maven.plugin.AbstractH2Mojo.java

License:Open Source License

/**
 * Returns a {@link ProcessBuilder} that can be used and reused to
 * spawn new fully configured H2 TCP servers.
 *
 * <p>This method never returns {@code null}.</p>
 *
 * <h2>Design Notes</h2>/*  w  ww .  j a v  a2s. c  o m*/
 *
 * <p>At the moment, the implementation of this method returns a new
 * {@link ProcessBuilder} in all cases, but this behavior should not
 * be relied upon.</p>
 *
 * @return a {@link ProcessBuilder}; never {@code null}
 */
protected ProcessBuilder getServerSpawner() {
    final List<String> args = this.getServerArguments();
    assert args != null;

    // A spawned server should never run as a daemon.
    args.remove("-tcpDaemon");
    args.remove("-pgDaemon");
    args.remove("-webDaemon");

    int argumentIndex = 0;

    File java = this.getJava();
    if (java == null) {
        java = new File(new File(new File(System.getProperty("java.home")), "bin"), "java");
    }
    args.add(argumentIndex++, java.getAbsolutePath());

    final String[] javaOptions = this.getJavaOptions();
    if (javaOptions != null && javaOptions.length > 0) {
        for (final String option : javaOptions) {
            if (option != null && !option.trim().isEmpty()) {
                args.add(argumentIndex++, option);
            }
        }
    }

    args.add(argumentIndex++, "-cp");
    final File fileLocation = this.getH2();
    assert fileLocation != null;
    args.add(argumentIndex++, fileLocation.getAbsolutePath());

    args.add(argumentIndex++, Server.class.getName());

    final Log log = this.getLog();
    if (log != null && log.isDebugEnabled()) {
        log.debug("Process arguments: " + args);
    }
    return new ProcessBuilder(args);
}

From source file:com.edugility.jaxb.maven.plugin.GenerateXmlAdapterMojo.java

License:Open Source License

/**
 * Reads the {@linkplain #getImplementations() implementations map}
 * and generates the appropriate {@link XmlAdapter} source code in
 * the {@linkplain #getDirectory() specified directory}.
 *
 * @exception MojoExecutionException if an error occurs
 *///from   www .j a v  a  2s.c  om
@Override
public void execute() throws MojoExecutionException {
    final Log log = this.getLog();

    XmlAdapterGenerator generator = this.getXmlAdapterGenerator();
    if (generator == null) {
        generator = new XmlAdapterGenerator();
    }

    File directory = this.getDirectory();
    if (directory == null) {
        directory = generator.getDirectory();
        if (directory == null) {
            throw new MojoExecutionException("No directory set", new IllegalStateException("No directory set"));
        }
    } else if (!directory.exists()) {
        if (!directory.mkdirs()) {
            throw new MojoExecutionException(String.format("Could not create directory path %s", directory),
                    new IOException(String.format("Could not create directory path %s", directory)));
        }
    }
    assert directory.isDirectory();
    assert directory.canWrite();

    generator.setDirectory(directory);

    final Map<String, String> implementations = this.getImplementations();
    if (implementations != null && !implementations.isEmpty()) {
        final Set<Entry<String, String>> entrySet = implementations.entrySet();
        if (entrySet != null && !entrySet.isEmpty()) {
            final String xmlAdapterPackage = this.getXmlAdapterPackage();
            for (final Entry<String, String> entry : entrySet) {
                if (entry != null) {
                    String interfaceName = entry.getKey();
                    if (interfaceName != null) {
                        interfaceName = interfaceName.trim();
                        if (!interfaceName.isEmpty()) {
                            String className = entry.getValue();
                            if (className != null) {
                                className = className.trim();
                                if (!className.isEmpty()) {
                                    try {
                                        final File file = generator.generate(xmlAdapterPackage, interfaceName,
                                                className);
                                        if (log != null && log.isDebugEnabled()) {
                                            log.debug(String.format(
                                                    "Generated %s in package %s, adapting %s to %s", file,
                                                    xmlAdapterPackage, interfaceName, className));
                                        }
                                    } catch (final IOException kaboom) {
                                        throw new MojoExecutionException(
                                                "Encountered an IOException during XMLAdapter generation",
                                                kaboom);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

}

From source file:com.edugility.jpa.maven.plugin.AbstractJPAMojo.java

License:Open Source License

/**
 * Scans the supplied {@link Set} of {@link URL}s and as a
 * convenience returns the supplied {@link AnnotationDB} that
 * contains the scanned annotation information.
 *
 * <p>This method may return {@code null} if the supplied {@code db}
 * is {@code null}.</p>/* w w w .j a va2  s.co  m*/
 *
 * @param db the {@link AnnotationDB} used to {@linkplain
 * org.scannotation.AnnotationDB#scanArchives(URL[]) perform the
 * scan}; if {@code null} then no scanning operation will take place
 *
 * @param urls the {@link Set} of {@link URL}s to scan; if {@code
 * null}, then no scanning operation will take place
 *
 * @return the {@code db} parameter
 *
 * @exception IOException if an error occurs during scanning
 *
 * @see org.scannotation.AnnotationDB#scanArchives(URL[])
 */
private final AnnotationDB scan(AnnotationDB db, final Set<URL> urls) throws IOException {
    if (db != null && urls != null && !urls.isEmpty()) {
        final Log log = this.getLog();
        if (log != null && log.isDebugEnabled()) {
            log.debug("Scanning the following URLs: " + urls);
        }
        db.clear();
        db.scanArchives(urls.toArray(new URL[urls.size()]));
    }
    return db;
}

From source file:com.edugility.jpa.maven.plugin.ListEntityClassnamesMojo.java

License:Open Source License

/**
 * Validates and "absolutizes" the supplied {@link File} and returns
 * the corrected version./* www. j av a2 s.c om*/
 *
 * <p>The return value of this method is guaranteed to be a {@link
 * File} that is:</p>
 *
 * <ul>
 *
 * <li>non-{@code null}</li>
 *
 * <li>{@linkplain File#isAbsolute() absolute}</li>
 *
 * <li>existent and {@linkplain File#canWrite() writable} or
 * non-existent and {@linkplain File#getParentFile() parented} by a
 * directory that is existent and writable</li>
 *
 * </ul>
 *
 * <p>If the supplied {@link File} is a relative {@link File}, then
 * it will be made absolute by prepending it with the following
 * platform-neutral path: <tt>${{@link Build#getDirectory()
 * project.build.directory}}/generated-test-sources/jpa-maven-plugin/</tt></p>
 *
 * @param outputFile the {@link File} to validate
 *
 * @return the "absolutized" and validated value of the {@code
 * outputFile} parameter; never {@code null}
 *
 * @exception FileException if the supplied {@code outputFile} did
 * not pass validation
 */
final File initializeOutputFile(File outputFile) throws FileException {
    if (outputFile == null) {
        final File projectBuildDirectory = new File(this.getProjectBuildDirectoryName());
        final File outputDirectory = new File(projectBuildDirectory, DEFAULT_SUBDIR_PREFIX);
        this.validateOutputDirectory(outputDirectory);
        outputFile = new File(outputDirectory, DEFAULT_OUTPUT_FILENAME);
    } else {
        if (!outputFile.isAbsolute()) {
            final File projectBuildDirectory = new File(this.getProjectBuildDirectoryName());
            final File outputDirectory = new File(projectBuildDirectory, DEFAULT_SUBDIR_PREFIX);
            this.validateOutputDirectory(outputDirectory);
            outputFile = new File(outputDirectory, outputFile.getPath());
        }
        if (outputFile.isDirectory()) {
            final File outputDirectory = outputFile;
            this.validateOutputDirectory(outputDirectory);
            outputFile = new File(outputDirectory, DEFAULT_OUTPUT_FILENAME);
        } else if (outputFile.exists()) {
            if (!outputFile.isFile()) {
                throw new NotNormalFileException(outputFile);
            } else if (!outputFile.canWrite()) {
                throw new NotWritableFileException(outputFile);
            } else {
                this.validateOutputDirectory(outputFile.getParentFile());
            }
        } else {
            this.validateOutputDirectory(outputFile.getParentFile());
        }
    }
    assert outputFile != null;
    assert outputFile.isAbsolute();
    final Log log = this.getLog();
    if (log != null && log.isDebugEnabled()) {
        log.debug(String.format("Output file initialized to %s", outputFile));
    }
    return outputFile;
}