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

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

Introduction

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

Prototype

void info(Throwable error);

Source Link

Document

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

Usage

From source file:de.felixschulze.maven.plugins.xcode.helper.ProcessHelper.java

License:Apache License

public static void killSimulatorProcess(Log log) throws MojoExecutionException {
    try {//www  .j  a v a 2s.  co  m
        log.info("Shutdown iPhone Simulator.");
        ProcessHelper.killSimulatorProcess();
    } catch (IOException e) {
        throw new MojoExecutionException("Error while shutdown simulator: ", e);
    }
}

From source file:de.hwbllmnn.maven.DistMojo.java

License:GNU General Public License

public void execute() throws MojoExecutionException, MojoFailureException {
    Log log = getLog();
    File basedir = project.getBasedir();
    File target = new File(basedir, "target/dist");

    if (!target.isDirectory() && !target.mkdirs()) {
        log.warn("Could not create target directory: " + target);
    }/* ww w.  jav  a2s  . c  o  m*/

    List<Artifact> artifacts = new LinkedList<Artifact>();
    @SuppressWarnings("unchecked")
    List<Object> modules = project.getCollectedProjects();
    if (includeProjectArtifacts) {
        modules.add(project);
    }
    for (Object o : modules) {
        MavenProject module = (MavenProject) o;
        List<?> arts = module.getAttachedArtifacts();
        for (Object obj : arts) {
            artifacts.add((Artifact) obj);
        }
        if (!includeOnlyAttachedArtifacts) {
            artifacts.add(module.getArtifact());
        }
    }

    log.info("Collected artifacts: " + artifacts);

    for (Artifact a : artifacts) {
        File file = a.getFile();
        if (file == null) {
            log.warn("Skipping non-existing artifact: " + a);
            continue;
        }
        try {
            copyFile(file, new File(target, file.getName()));
            log.info("Copied artifact " + file.getName());
        } catch (IOException e) {
            log.warn("Could not copy artifact: " + file);
        }
    }
}

From source file:de.jiac.micro.reflect.ServiceContextGenerator.java

License:Open Source License

public static void generateContexts(Log logger, File outputFolder, ReducedClassInfo[] classes)
        throws IOException {
    for (ReducedClassInfo rci : classes) {
        Class<?> cls = rci.getClassDescriptor().getClazz();
        if ((rci.mask & IFilter.CONTEXT) != 0 && !cls.getName().equals(ServiceFilter.ISERVICE_CLASS_NAME)) {

            StringBuilder contextName = new StringBuilder(cls.getName().replace('$', '_'));
            int dot = contextName.lastIndexOf(".");
            contextName.insert(dot < 0 ? 0 : dot + 1, EMULATION_CLASS_PREFIX);

            logger.info("generate context: " + contextName);

            File packageFolder = outputFolder;
            String packStr = null;
            if (dot > 0) {
                packStr = contextName.substring(0, dot);
                packageFolder = new File(outputFolder, packStr.replace('.', File.separatorChar));
            }//from  w  w w .ja v a  2  s .  c  o  m

            if (!packageFolder.exists()) {
                packageFolder.mkdirs();
            }

            String clsName = contextName.substring(dot < 0 ? 0 : dot + 1);

            File contextFile = new File(packageFolder, clsName + ".java");
            contextFile.createNewFile();

            PrintStream out = new PrintStream(new FileOutputStream(contextFile));
            generateContext(out, packStr, clsName, rci);
            out.flush();
            out.close();
        }
    }
}

From source file:de.jpdigital.maven.plugins.hibernate4ddl.EntityFinder.java

License:Open Source License

/**
 * Creates an {@code EntityFinder} for the provided package.
 *
 * @param project     The Maven project in which the calling Mojo is
 *                    executed. Can be {@code null}.
 * @param log         An Maven log object for creating output.
 * @param packageName The name of the package in the class should look for
 *                    entities.//w w w. j av  a2  s .  c  o m
 *
 * @return An {@code EntityFinder} instance.
 *
 * @throws MojoFailureException If the {@link Reflections} instance needed
 *                              by the {@code EntityFinder} can't be
 *                              created.
 */
public static EntityFinder forPackage(final MavenProject project, final Log log, final String packageName)
        throws MojoFailureException {
    final Reflections reflections;
    if (project == null) {
        reflections = new Reflections(ClasspathHelper.forPackage(packageName));
    } else {
        final List<String> classPathElems;
        try {
            classPathElems = project.getCompileClasspathElements();
        } catch (DependencyResolutionRequiredException ex) {
            throw new MojoFailureException("Failed to resolve project classpath.", ex);
        }
        final List<URL> classPathUrls = new ArrayList<>();
        for (final String classPathElem : classPathElems) {
            log.info(String.format("Adding classpath elemement '%s'...", classPathElem));
            classPathUrls.add(classPathElemToUrl(classPathElem));
        }

        log.info("Classpath URLs:");
        for (final URL url : classPathUrls) {
            log.info(String.format("\t%s", url.toString()));
        }

        //Here we have to do some classloader magic to ensure that the Reflections instance
        //uses the correct class loader. Which is the one which has access to the compiled 
        //classes
        final ClassLoader classLoader = AccessController.doPrivileged(new ClassLoaderCreator(classPathUrls));

        reflections = new Reflections(ClasspathHelper.forPackage(packageName, classLoader));

    }

    return new EntityFinder(reflections);
}

From source file:de.jpdigital.maven.plugins.hibernate5ddl.EntityFinder.java

License:Open Source License

/**
 * Creates an {@code EntityFinder} for the provided package.
 *
 * @param project     The Maven project in which the calling Mojo is
 *                    executed. Can be {@code null}.
 * @param log         An Maven log object for creating output.
 * @param packageName The name of the package in the class should look for
 *                    entities./*from  w w  w.ja  v a 2  s .  c  o m*/
 *
 * @return An {@code EntityFinder} instance.
 *
 * @throws MojoFailureException If the {@link Reflections} instance needed
 *                              by the {@code EntityFinder} can't be
 *                              created.
 */
@SuppressWarnings("unchecked")
public static EntityFinder forPackage(final MavenProject project, final Log log, final String packageName)
        throws MojoFailureException {
    final Reflections reflections;
    if (project == null) {
        reflections = new Reflections(ClasspathHelper.forPackage(packageName));
    } else {
        final List<String> classPathElems;
        try {
            classPathElems = project.getCompileClasspathElements();
        } catch (DependencyResolutionRequiredException ex) {
            throw new MojoFailureException("Failed to resolve project classpath.", ex);
        }
        final List<URL> classPathUrls = new ArrayList<>();
        for (final String classPathElem : classPathElems) {
            log.info(String.format("Adding classpath elemement '%s'...", classPathElem));
            classPathUrls.add(classPathElemToUrl(classPathElem));
        }

        log.info("Classpath URLs:");
        for (final URL url : classPathUrls) {
            log.info(String.format("\t%s", url.toString()));
        }

        //Here we have to do some classloader magic to ensure that the Reflections instance
        //uses the correct class loader. Which is the one which has access to the compiled 
        //classes
        final ClassLoader classLoader = AccessController.doPrivileged(new ClassLoaderCreator(classPathUrls));

        reflections = new Reflections(ClasspathHelper.forPackage(packageName, classLoader));

    }

    return new EntityFinder(reflections);
}

From source file:de.kaiserpfalzEdv.maven.apacheds.ApacheDsLifecycle.java

License:Apache License

public void init(final Log logger) throws Exception {
    logger.info("Initializing Apache Directory Server ...");

    this.logger = logger;

    DirectoryServiceFactory directoryFactory = new DefaultDirectoryServiceFactory();
    directory = directoryFactory.getDirectoryService();

    if (workingDirectory != null) {
        directory.setInstanceLayout(new InstanceLayout(workingDirectory));
    }/*from   w  w  w  . j a v  a  2  s.  co m*/

    logger.debug(directory.getInstanceLayout().toString());

    directoryFactory.init("LDAP Integration Tester");

    loadLdapSchema(logger);

    ldapServer = new LdapServer();
    ldapServer.setTransports(new TcpTransport(port));
    ldapServer.setDirectoryService(directory);

    server = new ApacheDS(ldapServer);

    loadAdditionalPartitions();

    if (preload != null) {
        logger.info("Setting LDIF preload to: " + preload);
        server.setLdifDirectory(preload);
    }
}

From source file:de.kaiserpfalzEdv.maven.apacheds.ApacheDsLifecycle.java

License:Apache License

private void loadLdapSchema(final Log logger) throws Exception {
    if (schema != null) {
        schemaDirectories.add(schema);//from   ww  w .j  a v  a 2  s  .c o  m
    }

    if (!schemaDirectories.isEmpty()) {
        logger.info("Loading schema: " + schemaDirectories);

        LdifLoader loader = new LdifLoader(directory.getSession(), directory.getSchemaPartition());
        loader.loadLdifs(logger, schemaDirectories);
    }
}

From source file:de.kaiserpfalzEdv.maven.apacheds.ApacheDsLifecycle.java

License:Apache License

public void start(final Log logger) throws Exception {
    logger.info("Starting Apache Directory Server ...");

    if (!directory.isStarted()) {
        directory.startup();//from   www .  j  a  v a 2s.co m
    }

    if (preload != null) {
        server.loadLdifs();
    }

    if (!ldapServer.isStarted()) {
        ldapServer.start();
    }
}

From source file:de.kaiserpfalzEdv.maven.apacheds.ApacheDsLifecycle.java

License:Apache License

public void stop(final Log logger) throws Exception {
    if (isStarted()) {
        logger.info("Stopping Apache Directory Server ...");

        server.shutdown();/*from  w w w  . j a va2  s.  c o m*/
    } else {
        logger.warn("No Apache Directory Server to be stopped!");
    }
}

From source file:de.sisao.maven.Deployer.java

License:Open Source License

void deployResource(File resource, String autodeployTarget, Log log) {

    this.log = log;

    String targetFilePath;/*ww w  .java2s .c  o m*/

    // do not deploy directory resources!
    if (!(resource instanceof File))
        return;

    File file = resource;
    sourceFileName = file.getName();
    sourceFilePath = file.getPath();
    sourceFilePathAbsolute = file.getAbsolutePath();

    // we do not deploy files from the source directories
    // skip source files like /src/main/java/*
    for (String value : IGNORE_DIRECTORIES) {
        if (sourceFilePath.contains(value)) {
            log.info("Skipping resource: " + sourceFilePath + " because it contains: " + value);
            return;
        }
    }

    if ("".equals(hotdeployTarget))
        hotdeployTarget = null;
    if ("".equals(autodeployTarget))
        autodeployTarget = null;

    // check for an missing/invalid confiugration
    if (autodeployTarget == null && hotdeployTarget == null) {
        // no message is needed here!
        return;
    }

    // check if a .ear or .war file should be autodeplyed....
    if ((sourceFileName.endsWith(".ear") || sourceFileName.endsWith(".war"))) {
        // verify if target autodeploy folder exists!
        if (autodeployTarget == null || autodeployTarget.isEmpty()) {
            return; // no op..
        }

        if (!autodeployTarget.endsWith("/"))
            autodeployTarget += "/";
        File targetTest = new File(autodeployTarget);
        if (!targetTest.exists()) {
            log.error("autodeploy directory '" + autodeployTarget
                    + "' dose not exist. Please check your manik properties for this project.");
            return;
        }

        // verify if sourceFileName includes a maven /target folder pattern
        if (sourceFilePath.indexOf("/target/") > -1) {
            // in this case only root artifacts will be copied. No .war
            // files included in a /target sub folder!
            if (sourceFilePath.indexOf('/', sourceFilePath.indexOf("/target/") + 8) > -1)
                return; // no op!

        }

        targetFilePath = autodeployTarget + sourceFileName;

        // disable hotdeploy mode!
        hotDeployMode = false;

    } else {
        // Hotdepoyment mode!
        if (hotdeployTarget == null)
            // no hotdeployTarget defined
            return;

        // optimize path....
        if (!hotdeployTarget.endsWith("/"))
            hotdeployTarget += "/";

        // compute the target path....
        targetFilePath = computeTarget();

        // enable hotdeploy mode!
        hotDeployMode = true;
    }

    // if the target file was not computed return....
    if (targetFilePath == null)
        return;

    // check if Autodeploy or Hotdeploy
    if (hotDeployMode) {
        // HOTDEPLOY MODE

        long lStart = System.currentTimeMillis();
        copySingleResource(file, targetFilePath);

        long lTime = System.currentTimeMillis() - lStart;
        // log message..
        if (sourceFileName.endsWith(".ear") || sourceFileName.endsWith(".war"))
            log.info("[AUTODEPLOY]: " + sourceFilePath + " in " + lTime + "ms");
        else
            log.info("[HOTDEPLOY]: " + sourceFilePath + " in " + lTime + "ms");

    } else {
        // AUTODEPLOY MODE

        long lStart = System.currentTimeMillis();
        // check if a .ear or .war file should be autodeplyed in exploded
        // format!...
        if (!explodeArtifact) {
            copySingleResource(file, targetFilePath);
        } else {

            // find extension
            int i = sourceFilePathAbsolute.lastIndexOf(".");
            String sDirPath = sourceFilePathAbsolute.substring(0, i) + "/";
            try {
                File srcFolder = new File(sDirPath);
                File destFolder = new File(targetFilePath);

                copyFolder(srcFolder, destFolder);
            } catch (IOException e) {
                log.info("[AUTODEPLOY]: error - " + e.getMessage());
            }

        }

        // if wildfly support then tough the .deploy file
        if (wildflySupport) {
            try {
                String sDeployFile = targetFilePath + ".dodeploy";
                File deployFile = new File(sDeployFile);
                if (!deployFile.exists())
                    new FileOutputStream(deployFile).close();
                deployFile.setLastModified(System.currentTimeMillis());

            } catch (FileNotFoundException e) {
                // console.println("[AUTODEPLOY]: error - " +
                // e.getMessage());
            } catch (IOException e) {
                // console.println("[AUTODEPLOY]: error - " +
                // e.getMessage());
            }
        }

        long lTime = System.currentTimeMillis() - lStart;
        log.info("[AUTODEPLOY]: " + sourceFilePath + " in " + lTime + "ms");
    }

}