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:net.oneandone.maven.plugins.prerelease.core.WorkingCopy.java

License:Apache License

public void update(Log log) throws Failure {
    log.info(Subversion.launcher(directory, "update").exec());
}

From source file:net.oneandone.maven.plugins.prerelease.ProjectBase.java

License:Apache License

protected WorkingCopy checkedWorkingCopy() throws Exception {
    Log log;
    WorkingCopy workingCopy;/*from  w  w  w .  jav a2s .  c om*/

    log = getLog();
    log.info("checking working copy ...");
    workingCopy = WorkingCopy.load(basedir());
    if (log.isDebugEnabled()) {
        log.debug("revisions: " + workingCopy.revisions);
        log.debug("changes: " + workingCopy.changes);
    }
    workingCopy.check();
    return workingCopy;
}

From source file:net.onedaybeard.agrotera.maven.WeavingHuntress.java

License:Apache License

@Override
public void execute() throws MojoExecutionException {
    long start = System.currentTimeMillis();
    if (context != null && !context.hasDelta(sourceDirectory))
        return;//www  .j ava2s. c o m

    ProcessArtemis hunter = new ProcessArtemis(outputDirectory);
    List<ArtemisConfigurationData> processed = hunter.process();
    hunter.process();

    Log log = getLog();
    log.info(getSummary(processed, start));

    String formatPattern = "\t%s:%-" + findLongestClassName(processed)
            + "s  Req=%d One=%d Any=%d Not=%d RefSys=%d RefMan=%d";
    for (ArtemisConfigurationData meta : processed) {
        log.info(String.format(formatPattern, typeCharacter(meta), formatClassName(meta.current.getClassName()),
                meta.requires.size(), meta.requiresOne.size(), meta.optional.size(), meta.exclude.size(),
                meta.systems.size(), meta.managers.size()));
    }
}

From source file:net.radai.easyavro.maven.CodegenMojo.java

License:Open Source License

public void execute() throws MojoExecutionException, MojoFailureException {
    Log log = getLog();
    //check parameters
    supplementDefaultConfiguration();//from w ww  .  j  a va 2  s.com

    //find source files
    Set<Path> files = findIncludedFiles();
    if (files.isEmpty()) {
        log.warn("found no avro files");
        return;
    }
    log.info("using " + inputEncoding + " to parse " + files.size() + " avro file(s) and " + outputEncoding
            + " to generate java files");

    //generate java code from source files
    AvroCodeGenerator generator = new AvroCodeGenerator();
    generator.setInputEncoding(inputEncoding);
    generator.setOutputEncoding(outputEncoding);
    try {
        generator.generateSpecificClasses(files, outputPath.toPath());
    } catch (IOException e) {
        throw new MojoFailureException("unable to generate java classes from avro files", e);
    }

    //add generated java code to the current maven project
    project.addCompileSourceRoot(outputPath.toString());
}

From source file:net.revelc.code.formatter.FormatterMojo.java

License:Apache License

/**
 * Execute.//from   w w  w  . java 2 s .c  o m
 *
 * @throws MojoExecutionException the mojo execution exception
 * @see org.apache.maven.plugin.AbstractMojo#execute()
 */
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (this.skipFormatting) {
        getLog().info("Formatting is skipped");
        return;
    }

    long startClock = System.currentTimeMillis();

    if (StringUtils.isEmpty(this.encoding)) {
        this.encoding = ReaderFactory.FILE_ENCODING;
        getLog().warn("File encoding has not been set, using platform encoding (" + this.encoding
                + ") to format source files, i.e. build is platform dependent!");
    } else {
        try {
            "Test Encoding".getBytes(this.encoding);
        } catch (UnsupportedEncodingException e) {
            throw new MojoExecutionException("Encoding '" + this.encoding + "' is not supported");
        }
        getLog().info("Using '" + this.encoding + "' encoding to format source files.");
    }

    List<File> files = new ArrayList<>();
    try {
        if (this.directories != null) {
            for (File directory : this.directories) {
                if (directory.exists() && directory.isDirectory()) {
                    files.addAll(addCollectionFiles(directory));
                }
            }
        } else { // Using defaults of source main and test dirs
            if (this.sourceDirectory != null && this.sourceDirectory.exists()
                    && this.sourceDirectory.isDirectory()) {
                files.addAll(addCollectionFiles(this.sourceDirectory));
            }
            if (this.testSourceDirectory != null && this.testSourceDirectory.exists()
                    && this.testSourceDirectory.isDirectory()) {
                files.addAll(addCollectionFiles(this.testSourceDirectory));
            }
        }
    } catch (IOException e) {
        throw new MojoExecutionException("Unable to find files using includes/excludes", e);
    }

    int numberOfFiles = files.size();
    Log log = getLog();
    log.info("Number of files to be formatted: " + numberOfFiles);

    if (numberOfFiles > 0) {
        createCodeFormatter();
        ResultCollector rc = new ResultCollector();
        Properties hashCache = readFileHashCacheFile();

        String basedirPath = getBasedirPath();
        for (int i = 0, n = files.size(); i < n; i++) {
            File file = files.get(i);
            if (file.exists()) {
                formatFile(file, rc, hashCache, basedirPath);
            }
        }

        storeFileHashCache(hashCache);

        long endClock = System.currentTimeMillis();

        log.info("Successfully formatted: " + rc.successCount + " file(s)");
        log.info("Fail to format      : " + rc.failCount + " file(s)");
        log.info("Skipped            : " + rc.skippedCount + " file(s)");
        log.info("Approximate time taken: " + ((endClock - startClock) / 1000) + "s");
    }
}

From source file:net.riccardocossu.i18split.maven.I18splitMojo.java

License:Apache License

public void execute() throws MojoExecutionException {
    File f = new File(outputBasePath);

    if (!f.exists()) {
        f.mkdirs();//from ww w.  ja  v a  2 s . co m
    }

    BaseConfiguration conf = new BaseConfiguration();
    conf.addProperty(ConfigKeys.INPUT_DRIVER, inputPlugin);
    conf.addProperty(ConfigKeys.OUTPUT_DRIVER, outputPlugin);
    conf.addProperty(ConfigKeys.OUTPUT_BASE_PATH, outputBasePath);
    conf.addProperty(ConfigKeys.INPUT_BASE_PATH, inputBasePath);
    conf.addProperty(ConfigKeys.INPUT_ENCODING, inputEncoding);
    conf.addProperty(ConfigKeys.OUTPUT_ENCODING, outputEncoding);
    if (pluginsConfig != null) {
        @SuppressWarnings("unchecked")
        MapConfiguration mc = new MapConfiguration(pluginsConfig);
        conf.append(mc);
    }
    org.apache.maven.plugin.logging.Log log = getLog();
    Iterator<String> keys = conf.getKeys();
    while (keys.hasNext()) {
        String k = keys.next();
        log.info(String.format("%s = %s", k, conf.getProperty(k)));
    }
    Engine eng = new Engine(conf);
    eng.process();

}

From source file:net.sf.buildbox.maven.contentcheck.LicenseShowMojo.java

License:Open Source License

private List<MavenProject> getMavenProjectForDependencies()
        throws MojoExecutionException, MojoFailureException {
    DependencyNode dependencyTreeNode = resolveProject();
    MavenProject project = getMavenProject();
    Dependencies dependencies = new Dependencies(project, dependencyTreeNode, classesAnalyzer);
    Log log = getLog();
    RepositoryUtils repoUtils = new RepositoryUtils(log, wagonManager, settings, mavenProjectBuilder, factory,
            resolver, project.getRemoteArtifactRepositories(), project.getPluginArtifactRepositories(),
            localRepository, repositoryMetadataManager);
    Artifact projectArtifact = project.getArtifact();
    log.info(String.format("Resolving project %s:%s:%s dependencies", projectArtifact.getGroupId(),
            projectArtifact.getArtifactId(), projectArtifact.getVersion()));
    List<Artifact> allDependencies = dependencies.getAllDependencies();
    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 {/*from   w ww. j a  va2  s.co m*/
            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;
}

From source file:net.sf.taverna.t2.maven.plugins.Utils.java

License:Apache License

public static String uploadFile(File file, String resourceName, Wagon wagon, Log log)
        throws MojoExecutionException {
    String resourceUrl = getResourceUrl(wagon, resourceName);
    File digestFile = new File(file.getPath() + ".md5");
    try {/*w  w  w.j a v  a2  s. c o  m*/
        String digestString = DigestUtils.md5Hex(new FileInputStream(file));
        FileUtils.writeStringToFile(digestFile, digestString);
    } catch (IOException e) {
        throw new MojoExecutionException(String.format("Error generating digest for %1$s", file), e);
    }
    try {
        log.info(String.format("Uploading %1$s to %2$s", file, resourceUrl));
        wagon.put(file, resourceName);
        wagon.put(digestFile, resourceName + ".md5");
    } catch (TransferFailedException e) {
        throw new MojoExecutionException(String.format("Error transferring %1$s to %2$s", file, resourceUrl),
                e);
    } catch (ResourceDoesNotExistException e) {
        throw new MojoExecutionException(String.format("%1$s does not exist", resourceUrl), e);
    } catch (AuthorizationException e) {
        throw new MojoExecutionException(
                String.format("Authentication error transferring %1$s to %2$s", file, resourceUrl), e);
    }
    return resourceUrl;
}

From source file:net.sf.taverna.t2.maven.plugins.Utils.java

License:Apache License

public static void downloadFile(String resourceName, File file, Wagon wagon, Log log)
        throws MojoExecutionException, ResourceDoesNotExistException {
    String resourceUrl = getResourceUrl(wagon, resourceName);
    File digestFile = new File(file.getPath() + ".md5");
    try {/*from  w  ww  .  ja v  a2  s  . c  om*/
        log.info(String.format("Downloading %1$s to %2$s", resourceUrl, file));
        wagon.get(resourceName, file);
        wagon.get(resourceName + ".md5", digestFile);
    } catch (TransferFailedException e) {
        throw new MojoExecutionException(String.format("Error transferring %1$s to %2$s", resourceUrl, file),
                e);
    } catch (AuthorizationException e) {
        throw new MojoExecutionException(
                String.format("Authentication error transferring %1$s to %2$s", resourceUrl, file), e);
    }
    try {
        String digestString1 = DigestUtils.md5Hex(new FileInputStream(file));
        String digestString2 = FileUtils.readFileToString(digestFile);
        if (!digestString1.equals(digestString2)) {
            throw new MojoExecutionException(
                    String.format("Error downloading file: digsests not equal. (%1$s != %2$s)", digestString1,
                            digestString2));
        }
    } catch (IOException e) {
        throw new MojoExecutionException(String.format("Error checking digest for %1$s", file), e);
    }
}

From source file:net.sf.yal10n.svn.SVNUtil.java

License:Apache License

/**
 * Checkout from the given svn url to the destination directory.
 *
 * @param log the log/*  w ww .  j a  v  a2 s. c o  m*/
 * @param type the scm type
 * @param svnUrl the svn url
 * @param destination the destination
 * @return the current checked out version
 */
public String checkout(Log log, ScmType type, String svnUrl, String destination) {
    try {
        log.info("Updating " + svnUrl);

        String scmUrl = createScmSvnUrl(type, svnUrl);
        log.debug("Converted Url: " + scmUrl);

        ScmProvider scm = scmManager.getProviderByUrl(scmUrl);
        ScmRepository repository = scmManager.makeScmRepository(scmUrl);
        ScmProviderRepository providerRepository = repository.getProviderRepository();

        File dstPath = new File(destination);
        if (dstPath.exists() && !dstPath.isDirectory()) {
            throw new RuntimeException("Path is not a directory: " + dstPath);
        } else if (!dstPath.exists() && !dstPath.mkdirs()) {
            throw new RuntimeException("Couldn't create directory " + dstPath);
        }
        CheckOutScmResult checkOutResult = scm.checkOut(repository, new ScmFileSet(dstPath));
        checkResult(checkOutResult);
        String revision = checkOutResult.getRevision();
        if (revision == null) {
            InfoScmResult info = scm.info(providerRepository, new ScmFileSet(dstPath), null);
            checkResult(info);
            revision = info.getInfoItems().get(0).getRevision();
        }
        log.info("At revision " + revision);
        return revision;
    } catch (ScmException e) {
        throw new RuntimeException(e);
    }
}