Example usage for org.apache.maven.plugin MojoExecutionException MojoExecutionException

List of usage examples for org.apache.maven.plugin MojoExecutionException MojoExecutionException

Introduction

In this page you can find the example usage for org.apache.maven.plugin MojoExecutionException MojoExecutionException.

Prototype

public MojoExecutionException(String message, Throwable cause) 

Source Link

Document

Construct a new MojoExecutionException exception wrapping an underlying Throwable and providing a message.

Usage

From source file:com.btmatthews.maven.plugins.ldap.mojo.AbstractLDAPMojo.java

License:Apache License

/**
 * Connect to the LDAP directory server. The connection attempt will be retried {@link #connectionRetries} times
 * and the connection time is set to {@link #connectionTimeout}.
 *
 * @return The connection object.//from  w  ww  .j av  a 2s . c o m
 * @throws MojoExecutionException If the connection to the LDAP directory server failed.
 */
protected final LDAPConnection connect() throws MojoExecutionException {
    final LDAPConnection connection = new LDAPConnection();
    int i = 0;
    while (i < connectionRetries) {
        long start = System.currentTimeMillis();
        try {
            this.getLog().info("Attempting to connect to LDAP directory server (" + host + ":" + port + ")");
            connection.connect(host, port, connectionTimeout);
            break;
        } catch (final LDAPException e) {
            final String message = "Could not connect to LDAP directory server (" + host + ":" + port + ")";
            this.getLog().error(message, e);
            if (i++ < connectionRetries) {
                long time = System.currentTimeMillis() - start;
                if (time < connectionTimeout) {
                    try {
                        Thread.sleep(connectionTimeout - time);
                    } catch (final InterruptedException e1) {
                        throw new MojoExecutionException(message, e1);
                    }
                }
            } else {
                throw new MojoExecutionException(message, e);
            }
        }
    }
    try {
        connection.bind(authDn, passwd);
    } catch (final LDAPException e) {
        throw new MojoExecutionException("Could not bind to LDAP directory server as " + authDn, e);
    }
    return connection;
}

From source file:com.bugvm.maven.plugin.AbstractBugVMBuildMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {

    try {/*from   ww w . j a v a2  s. c o  m*/

        Config.Builder builder = configure(new Config.Builder()).skipInstall(false);

        if (getArchs() != null) {
            List<Arch> archs = new ArrayList<>();
            for (String s : getArchs().trim().split(":")) {
                archs.add(Arch.valueOf(s));
            }
            builder.archs(archs);
        }
        // builder.enableBitcode(enableBitcode);

        AppCompiler compiler = new AppCompiler(builder.build());
        compiler.build();
        if (shouldArchive()) {
            compiler.archive();
        } else {
            compiler.install();
        }

    } catch (IOException e) {
        if (shouldArchive()) {
            throw new MojoExecutionException("Failed to create archive", e);
        } else {
            throw new MojoExecutionException("Failed to install", e);
        }
    }
}

From source file:com.bugvm.maven.plugin.AbstractBugVMMojo.java

License:Apache License

protected AppCompiler build(OS os, Arch arch, String targetType)
        throws MojoExecutionException, MojoFailureException {

    getLog().info("Building BugVM app for: " + os + " (" + arch + ")");

    Config.Builder builder;/*from w w  w . ja  v  a 2 s . c o m*/
    try {
        builder = new Config.Builder();
    } catch (IOException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }

    configure(builder).os(os).arch(arch).targetType(targetType);

    // execute the BugVM build

    try {

        getLog().info("Compiling BugVM app, this could take a while, especially the first time round");
        AppCompiler compiler = new AppCompiler(builder.build());
        compiler.build();

        return compiler;

    } catch (IOException e) {
        throw new MojoExecutionException("Error building BugVM executable for app", e);
    }
}

From source file:com.bugvm.maven.plugin.AbstractBugVMMojo.java

License:Apache License

protected File unpackBugVMDist() throws MojoExecutionException {

    Artifact distTarArtifact = resolveBugVMDistArtifact();
    File distTarFile = distTarArtifact.getFile();
    File unpackBaseDir;//from w w  w  .j ava 2  s. co  m
    if (home != null) {
        unpackBaseDir = home;
    } else {
        // by default unpack into the local repo directory
        unpackBaseDir = new File(distTarFile.getParent(), "unpacked");
    }
    if (unpackBaseDir.exists() && distTarArtifact.isSnapshot()) {
        getLog().debug("Deleting directory for unpacked snapshots: " + unpackBaseDir);
        try {
            FileUtils.deleteDirectory(unpackBaseDir);
        } catch (IOException e) {
            throw new MojoExecutionException("Failed to delete " + unpackBaseDir, e);
        }
    }
    unpack(distTarFile, unpackBaseDir);
    File unpackedDir = new File(unpackBaseDir, "bugvm-" + getBugVMVersion());
    return unpackedDir;
}

From source file:com.bugvm.maven.plugin.AbstractIOSSimulatorMojo.java

License:Apache License

public void execute() throws MojoExecutionException, MojoFailureException {
    try {/*from   w w w .j  a  v  a 2 s. c om*/
        Arch arch = Arch.x86_64;
        if (super.arch != null && super.arch.equals(Arch.x86.toString())) {
            arch = Arch.x86;
        }

        AppCompiler compiler = build(OS.ios, arch, IOSTarget.TYPE);
        Config config = compiler.getConfig();
        IOSSimulatorLaunchParameters launchParameters = (IOSSimulatorLaunchParameters) config.getTarget()
                .createLaunchParameters();

        // select the device based on the (optional) SDK version and (optional) device type
        DeviceType deviceType = DeviceType.getBestDeviceType(arch, deviceFamily, deviceName, sdk);
        launchParameters.setDeviceType(deviceType);
        compiler.launch(launchParameters);

    } catch (Throwable t) {
        throw new MojoExecutionException("Failed to launch IOS Simulator", t);
    }
}

From source file:com.bugvm.maven.plugin.ActivateLicenseMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (licenseKey == null) {
        throw new MojoFailureException("Provide a license key to activate via -Dbugvm.licenseKey");
    }/*w  w w.  j av  a2  s  .co m*/

    try {
        Class clazz = ActivateLicenseMojo.class.getClassLoader().loadClass("com.bugvm.lm.LicenseManager");
        Method m = clazz.getMethod("main", String[].class);
        String[] args = { "activate", licenseKey };
        m.invoke(null, new Object[] { args });
    } catch (Throwable e) {
        throw new MojoExecutionException("Couldn't activate license", e);
    }
}

From source file:com.bugvm.maven.plugin.ConsoleMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {

    try {//from w  w  w  .j av  a 2 s.  c o  m

        Arch arch = Arch.getDefaultArch();
        if (super.arch != null) {
            arch = Arch.valueOf(super.arch);
        }

        AppCompiler compiler = build(OS.getDefaultOS(), arch, ConsoleTarget.TYPE);
        Config config = compiler.getConfig();
        LaunchParameters launchParameters = config.getTarget().createLaunchParameters();
        compiler.launch(launchParameters);

    } catch (Throwable t) {
        throw new MojoExecutionException("Failed to launch console application", t);
    }
}

From source file:com.bugvm.maven.plugin.DeactivateLicenseMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    try {//from ww w .ja va2s .com
        Class clazz = ActivateLicenseMojo.class.getClassLoader().loadClass("com.bugvm.lm.LicenseManager");
        Method m = clazz.getMethod("main", String[].class);
        String[] args = { "deactivate" };
        m.invoke(null, new Object[] { args });
    } catch (Throwable e) {
        throw new MojoExecutionException("Couldn't deactivate license", e);
    }
}

From source file:com.bugvm.maven.plugin.IOSDeviceMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {

    try {//from  w w  w . j  a va  2 s  . c  o m

        Arch arch = Arch.thumbv7;
        if (super.arch != null && super.arch.equals(Arch.arm64.toString())) {
            arch = Arch.arm64;
        }

        AppCompiler compiler = build(OS.ios, arch, IOSTarget.TYPE);
        Config config = compiler.getConfig();
        LaunchParameters launchParameters = config.getTarget().createLaunchParameters();
        compiler.launch(launchParameters);

    } catch (Throwable t) {
        throw new MojoExecutionException("Failed to launch IOS Device", t);
    }
}

From source file:com.butlerhq.extdoc.ExtDocReport.java

License:Apache License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    try {/*from   w  w  w. j  a  va2  s .c om*/
        generate(null, null);
    } catch (MavenReportException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}