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.zalando.mojo.aspectj.MavenMessageHandler.java

License:Open Source License

/**
 * Constructs a MessageHandler with a Maven plugin logger.
 *
 * @param log                           The active Maven Log.
 * @param showDetailsForMessageKindList A List holding all AJC message types for which this MavenMessageHandler
 *                                      should emit details onto the Maven log (i.e. class name,
 *                                      line/row number etc.)
 *///from  w  w w. ja  v  a 2s.  c  o  m
public MavenMessageHandler(final Log log, final List<IMessage.Kind> showDetailsForMessageKindList) {

    // Check sanity
    // assert log != null : "Cannot handle null log argument.";
    // assert showDetailsForMessageKindList != null : "Cannot handle null showDetailsForMessageKindList argument.";
    if (log == null) {
        throw new NullPointerException("Cannot handle null log argument.");
    }
    if (showDetailsForMessageKindList == null) {
        throw new NullPointerException("Cannot handle null showDetailsForMessageKindList argument.");
    }

    // Assign internal state
    this.log = log;
    this.showDetailsForMessageKindList = showDetailsForMessageKindList;

    if (log.isInfoEnabled()) {
        log.info("Showing AJC message detail for messages of types: " + showDetailsForMessageKindList);
    }
}

From source file:edu.iu.ul.maven.plugins.fileweaver.Output.java

License:Apache License

/**
 * Assemble the file's parts and write out.
 * @param defaultPath place to put the output if not specified here.
 * @param executionProps properties to be merged with this file's own (may be null).
 * @param log a logger, if needed.//from  ww w  .  j  ava 2 s.c  o m
 * @throws MojoExecutionException on I/O errors.
 */
void build(File defaultPath, Map<Object, Object> executionProps, Log log) throws MojoExecutionException {
    Map<Object, Object> fileProps = new HashMap<Object, Object>();
    if (null != executionProps)
        fileProps.putAll(executionProps);
    if (null != properties)
        fileProps.putAll(properties);

    CharBuffer bupher = CharBuffer.allocate(BUFFER_SIZE);
    Writer output = null;
    try {
        output = open(defaultPath);

        int nParts = 0;
        for (Part part : parts) {
            Reader ir = new InterpolationFilterReader(part.getReader(), fileProps);
            bupher.clear();
            while (ir.read(bupher) >= 0) {
                bupher.flip();
                output.write(bupher.toString());
                bupher.clear();
            }
            nParts++;
        }
        output.close();
        log.info(String.format("Wove %s from %d parts.", finalPath, nParts));
    } catch (Exception e) {
        throw new MojoExecutionException("Could not write " + finalPath, e);
    }
}

From source file:edu.iu.ul.maven.plugins.fileweaver.Weave.java

License:Apache License

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

    Map<Object, Object> executionProps = new HashMap<Object, Object>();
    if (null != properties)
        executionProps.putAll(properties);

    int nFiles = 0;
    for (Output file : outputs) {
        file.build(outputPath, executionProps, log);
        nFiles++;/*from w w w. java 2  s  .c  o  m*/
    }
    log.info(String.format("%d files woven.", nFiles));
}

From source file:fr.husta.maven.plugin.ReleaseProjectVersionMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException {
    issueManagement = project.getIssueManagement();
    Log tempLog = getLog();
    if (issueManagement != null) {
        tempLog.debug("IssueManagement -> system = " + issueManagement.getSystem());
        tempLog.debug("IssueManagement -> url = " + issueManagement.getUrl());

        final String ISSUE_MNGT_MANTIS = "Mantis";
        if (issueManagement.getSystem() != null
                && ISSUE_MNGT_MANTIS.equals(issueManagement.getSystem()) == false) {
            tempLog.warn("IssueManagement -> system should be set to '" + ISSUE_MNGT_MANTIS + "'.");
        }//from ww  w  . ja v a  2  s  . c  o m
    }

    try {
        // connection to Mantis SOAP API
        MantisConnectPortType portType = MantisUtils.createConnector(getMantisSoapApiUrl());
        MantisConnector mantisConnector = new MantisConnector(portType);

        tempLog.debug("projectName = '" + projectName + "'");

        // find ProjectId from Name
        BigInteger projectId = mantisConnector.getProjectIdByName(login, password, projectName);

        tempLog.info("Project " + projectName + " has ID=" + projectId);

        String tempCurrentSnapshot = currentSnapshot;
        if (versionPrefix != null) {
            tempCurrentSnapshot = versionPrefix + "-" + tempCurrentSnapshot;
        }
        String tempReleaseVersion = releaseVersion;
        if (versionPrefix != null) {
            tempReleaseVersion = versionPrefix + "-" + tempReleaseVersion;
        }
        tempLog.info("Rename Version '" + tempCurrentSnapshot + "' to " + tempReleaseVersion);
        mantisConnector.renameVersion(tempLog, login, password, projectId, tempCurrentSnapshot,
                tempReleaseVersion);
        tempLog.info("Renamed Version '" + tempCurrentSnapshot + "' to " + tempReleaseVersion);
        // call to web service method
        String tempDevelopmentVersion = developmentVersion;
        if (versionPrefix != null) {
            tempDevelopmentVersion = versionPrefix + "-" + tempDevelopmentVersion;
        }
        tempLog.info("Create Version '" + tempDevelopmentVersion + "' in Mantis, releaseFlag=" + false);
        mantisConnector.addProjectVersion(login, password, projectId, tempDevelopmentVersion, false);
        tempLog.info("Version '" + tempDevelopmentVersion + "' created in Mantis, releaseFlag=" + false);

    } catch (ServiceException e) {
        tempLog.error(e.getMessage());
        throw new MojoExecutionException(e.getMessage(), e);
    } catch (RuntimeException e) {
        tempLog.error(e.getMessage());
        throw new MojoExecutionException(e.getMessage(), e);
    } catch (RemoteException e) {
        tempLog.error(e.getMessage());
        throw new MojoExecutionException(e.getMessage(), e);
    }

}

From source file:fr.jetoile.hadoopunit.HadoopBootstrapRemoteUtils.java

License:Apache License

public String getHadoopUnitPath(String hadoopUnitPath, Log log) {
    String hadoopUnitHome = System.getenv("HADOOP_UNIT_HOME");
    String res = "";
    if (hadoopUnitHome != null) {
        res = hadoopUnitHome;/* w w  w  .ja  v a 2s .com*/
        log.info("overriding property hadoopUnitPath with system environment variable" + hadoopUnitHome);
    } else {
        res = hadoopUnitPath;
    }
    log.info("is going to use:" + res);

    if (hadoopUnitPath == null) {
        log.error("hadoopUnitPath or HADOOP_UNIT_HOME should be set");
    }
    return res;
}

From source file:fr.opensagres.maven.plugins.noannotations.RemoveAnnotationsMojo.java

License:Apache License

/**
 * Scans a single directory.//from   ww w  .  j  a v  a 2  s. c  o m
 *
 * @param root Directory to scan
 * @throws MojoExecutionException in case of IO errors
 */
private void transform(File root) throws MojoExecutionException {
    final Log log = getLog();

    if (!root.exists()) {
        return;
    }

    log.info("scanning source file directory '" + root + "'");

    final DirectoryScanner directoryScanner = new DirectoryScanner();
    directoryScanner.setIncludes(includes);
    directoryScanner.setExcludes(excludes);
    directoryScanner.setBasedir(root);
    directoryScanner.scan();

    for (String fileName : directoryScanner.getIncludedFiles()) {
        final File file = new File(root, fileName);
        try {
            String content = FileUtils.readFileToString(file);
            String noAnnotations = cleanupAnnotations(content);
            File target = new File(noAnnotationsSourceFolder, fileName);
            FileUtils.writeStringToFile(target, noAnnotations);
        } catch (IOException e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }
    }
}

From source file:fr.synchrotron.soleil.ica.ci.maven.plugins.soleildependency.util.DependencyUtil.java

License:Apache License

/**
 * Writes the specified string to the log at info level.
 *
 * @param string the string to write/*from   w  w  w.  j  a  v a 2 s  .com*/
 * @throws IOException if an I/O error occurs
 */
public synchronized static void log(String string, Log log) throws IOException {
    BufferedReader reader = new BufferedReader(new StringReader(string));

    String line;

    while ((line = reader.readLine()) != null) {
        log.info(line);
    }

    reader.close();
}

From source file:info.naiv.lab.java.jmt.enumgen.maven.plugin.EnumGeneratorMojo.java

License:Open Source License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    final Log log = getLog();
    try {//from  w  w  w  .j  a v a  2s  .c o m
        final Path path = buildOutputDirectory();
        if (!Files.exists(path)) {
            Files.createDirectories(path);
        }

        final Charset charset = Charset.forName(encoding);
        final CompiledTemplate clsTempl = getClassTemplate();
        final EnumGenerator builder = new EnumGenerator(packageName, clsTempl);
        final Properties props = getProperties();
        if (!props.stringPropertyNames().isEmpty()) {
            log.info("properties found. ");
            CodeData code = builder.propertiesToCode(propertiesSourceEnumName, propertiesSourceFieldPrefix,
                    props);
            log.info("generate " + code.getName());
            writeCode(path, code, charset);
        }
        if (isNotBlank(enumSourceCsv)) {
            log.info("enumSourceCsv found. ");
            Multimap<String, EnumEntry> entries = EnumSource.createEnumEntries(Paths.get(enumSourceCsv),
                    charset, delimiter);
            for (String key : entries.keySet()) {
                CodeData code = builder.entriesToCode(key, entries.get(key));
                log.info("generate " + code.getName());
                writeCode(path, code, charset);
            }
        }
    } catch (IOException ex) {
        log.error(ex);
        throw new MojoFailureException("bean creation failed. ", ex);
    }
}

From source file:info.naiv.lab.java.jmt.pojogen.maven.plugin.PojoGeneratorMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    final Log log = getLog();
    try {/*from  w  w w. j a va 2 s.co m*/
        loadExternalDrivers(log);

        final Path path = buildOutputDirectory();
        if (Files.exists(path)) {
            // ???????.
            log.info(path + " is exists.");
            return;
        }

        final DataSource dataSource = new DriverManagerDataSource(url, username, password);
        final Charset charset = Charset.forName(encoding);
        final CompiledTemplate clsTempl = getClassTemplate();
        final PojoGenerator builder = new PojoGenerator(schema, packageName, classNameSuffix, clsTempl);
        final AntPathMatcher matcher = new AntPathMatcher();

        Files.createDirectories(path);
        JdbcUtils.extractDatabaseMetaData(dataSource, new DatabaseMetaDataCallback() {
            @Override
            public Object processMetaData(DatabaseMetaData dbmd) throws SQLException, MetaDataAccessException {
                List<String> tableNames = getTableNames(dbmd);
                for (String tableName : tableNames) {
                    if (isExcludeTarget(tableName)) {
                        log.info(tableName + " is exclude.");
                        continue;
                    }
                    CodeData code = builder.tableToBean(dbmd, tableName);
                    writeCode(path, code);
                }
                return null;
            }

            protected boolean isExcludeTarget(final String tableName) {
                if (isEmpty(excludeTables)) {
                    return false;
                }
                return Misc.contains(excludeTables, new Predicate1<String>() {
                    @Override
                    public boolean test(String obj) {
                        return matcher.match(obj, tableName);
                    }
                });
            }

            protected void writeCode(Path dir, CodeData code) {
                try {
                    Path file = dir.resolve(code.getClassName() + ".java");
                    try (BufferedWriter writer = Files.newBufferedWriter(file, charset)) {
                        writer.append(code.getCode());
                    }
                } catch (IOException ex) {
                    log.error(ex);
                }
            }

            protected List<String> getTableNames(DatabaseMetaData dbmd) throws SQLException {
                List<String> tableNames = new ArrayList<>();
                String sch = schema;
                if ("@null".equals(sch)) {
                    sch = null;
                }
                try (ResultSet rs = dbmd.getTables(null, sch, "%", new String[] { "TABLE", "VIEW" })) {
                    while (rs.next()) {
                        tableNames.add(rs.getString("TABLE_NAME"));
                    }
                }
                return tableNames;
            }
        });
    } catch (MetaDataAccessException | IOException | SQLException ex) {
        log.error(ex);
        throw new MojoFailureException("bean creation failed. ", ex);
    }

}

From source file:info.naiv.lab.java.jmt.pojogen.maven.plugin.PojoGeneratorMojo.java

License:Apache License

protected void loadExternalDrivers(Log log) throws IOException, SQLException {
    if (isNotBlank(externalJdbcDriversDir)) {
        Path driversPath = Paths.get(this.externalJdbcDriversDir).normalize();
        log.info("externalJdbcDriversDir:" + driversPath);
        if (Files.exists(driversPath)) {
            ExternalJdbcDriverLoader loader = new ExternalJdbcDriverLoader();
            Iterable<Driver> drivers = loader.load(Arrays.asList(driversPath));
            for (Driver driver : drivers) {
                log.info("load Driver:" + driver.getClass().getCanonicalName());
            }/*  w  w w .j  a  v a 2 s  . c om*/
        }
    }
}