Search in sources :

Example 1 with ExecDumpClient

use of org.jacoco.core.tools.ExecDumpClient in project jacoco by jacoco.

the class DumpTask method execute.

@Override
public void execute() throws BuildException {
    if (port <= 0) {
        throw new BuildException("Invalid port value", getLocation());
    }
    if (dump && destfile == null) {
        throw new BuildException("Destination file is required when dumping execution data", getLocation());
    }
    final ExecDumpClient client = new ExecDumpClient() {

        @Override
        protected void onConnecting(final InetAddress address, final int port) {
            log(format("Connecting to %s:%s", address, Integer.valueOf(port)));
        }

        @Override
        protected void onConnectionFailure(final IOException exception) {
            log(exception.getMessage());
        }
    };
    client.setDump(dump);
    client.setReset(reset);
    client.setRetryCount(retryCount);
    try {
        final ExecFileLoader loader = client.dump(address, port);
        if (dump) {
            log(format("Dumping execution data to %s", destfile.getAbsolutePath()));
            loader.save(destfile, append);
        }
    } catch (final IOException e) {
        throw new BuildException("Unable to dump coverage data", e, getLocation());
    }
}
Also used : ExecDumpClient(org.jacoco.core.tools.ExecDumpClient) BuildException(org.apache.tools.ant.BuildException) IOException(java.io.IOException) InetAddress(java.net.InetAddress) ExecFileLoader(org.jacoco.core.tools.ExecFileLoader)

Example 2 with ExecDumpClient

use of org.jacoco.core.tools.ExecDumpClient in project jacoco by jacoco.

the class Dump method execute.

@Override
public int execute(final PrintWriter out, final PrintWriter err) throws Exception {
    final ExecDumpClient client = new ExecDumpClient() {

        @Override
        protected void onConnecting(final InetAddress address, final int port) {
            out.printf("[INFO] Connecting to %s:%s.%n", address, Integer.valueOf(port));
        }

        @Override
        protected void onConnectionFailure(final IOException exception) {
            err.printf("[WARN] %s.%n", exception.getMessage());
        }
    };
    client.setReset(reset);
    client.setRetryCount(retrycount);
    final ExecFileLoader loader = client.dump(address, port);
    out.printf("[INFO] Writing execution data to %s.%n", destfile.getAbsolutePath());
    loader.save(destfile, true);
    return 0;
}
Also used : ExecDumpClient(org.jacoco.core.tools.ExecDumpClient) IOException(java.io.IOException) InetAddress(java.net.InetAddress) ExecFileLoader(org.jacoco.core.tools.ExecFileLoader)

Example 3 with ExecDumpClient

use of org.jacoco.core.tools.ExecDumpClient in project jacoco by jacoco.

the class DumpMojo method executeMojo.

@Override
public void executeMojo() throws MojoExecutionException {
    final ExecDumpClient client = new ExecDumpClient() {

        @Override
        protected void onConnecting(final InetAddress address, final int port) {
            getLog().info(format("Connecting to %s:%s", address, Integer.valueOf(port)));
        }

        @Override
        protected void onConnectionFailure(final IOException exception) {
            getLog().info(exception.getMessage());
        }
    };
    client.setDump(dump);
    client.setReset(reset);
    client.setRetryCount(retryCount);
    try {
        final ExecFileLoader loader = client.dump(address, port);
        if (dump) {
            getLog().info(format("Dumping execution data to %s", destFile.getAbsolutePath()));
            loader.save(destFile, append);
        }
    } catch (final IOException e) {
        throw new MojoExecutionException("Unable to dump coverage data", e);
    }
}
Also used : ExecDumpClient(org.jacoco.core.tools.ExecDumpClient) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException) InetAddress(java.net.InetAddress) ExecFileLoader(org.jacoco.core.tools.ExecFileLoader)

Aggregations

IOException (java.io.IOException)3 InetAddress (java.net.InetAddress)3 ExecDumpClient (org.jacoco.core.tools.ExecDumpClient)3 ExecFileLoader (org.jacoco.core.tools.ExecFileLoader)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 BuildException (org.apache.tools.ant.BuildException)1