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.codetroopers.maven.mergeprops.MergeProperty.java

License:Apache License

private Map<String, Properties> loadFiles() throws MojoExecutionException, MojoFailureException {
    Map<String, Properties> outMap = new LinkedHashMap<String, Properties>();
    for (String propertyFileName : merge.getFileNames(directory)) {
        InputStream input = null;
        try {// w ww.  j  av  a2  s. c  o m
            String locale = extractLocaleFromFileName(propertyFileName);
            final String fullFilePath = directory + File.separator + propertyFileName;
            input = new FileInputStream(fullFilePath);
            final boolean b = checkKeys(propertyFileName, merge.getExcludeKeyCheck(), fullFilePath, log);

            if (log.isDebugEnabled()) {
                log.debug("Should include properties : " + b);
            }
            if (b) {
                getMergedPropertiesForLocale(outMap, locale).load(input);
            }
        } catch (FileNotFoundException e) {
            throw new MojoExecutionException("Could not find file: " + propertyFileName, e);
        } catch (IOException e) {
            throw new MojoExecutionException("Could not read from file: " + propertyFileName, e);
        } finally {
            if (input != null) {
                try {
                    input.close();
                } catch (IOException e) {
                    // nothing to do
                }
            }
        }
    }
    return outMap;
}

From source file:com.codetroopers.maven.mergeprops.MergeProperty.java

License:Apache License

static boolean checkKeys(final String propertyFileName, final String[] excludeKeyCheck, final String fileName,
        final Log log) throws MojoExecutionException, MojoFailureException {
    if (propertyFileName == null) {
        throw new NullPointerException("PropertyFileName can not be null ! ");
    }// w  ww.jav  a 2 s.com
    // Do not reuse the existing inputstream as the load method forwards it and there is no reset() in FIS
    String prefixToConsider = extractFilePrefix(propertyFileName);
    if (log.isDebugEnabled()) {
        log.debug("Prefix to consider : " + prefixToConsider);
    }
    if (excludeKeyCheck != null) {
        for (String s : excludeKeyCheck) {
            if (prefixToConsider.matches(s)) {
                log.info("Found propertyFileName without prefix checking, including... [" + propertyFileName
                        + "]");
                return true;
            }
        }
    }
    Properties props = new Properties();
    InputStream input = null;
    try {
        input = new FileInputStream(fileName);
        props.load(input);
        return !containsInvalidPrefix(prefixToConsider, props);
    } catch (IOException e) {
        throw new MojoExecutionException("Could not read from file: " + propertyFileName, e);
    } finally {
        if (input != null) {
            try {
                input.close();
            } catch (IOException ioe) {
                //do nothing
            }
        }
    }
}

From source file:com.cognifide.aet.plugins.maven.RunTestSuiteMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException {
    validateConfiguration();/* w ww  .j av a  2 s  . com*/
    try {
        TestSuiteRunner testSuiteRunner = new TestSuiteRunner(endpointDomain,
                mavenProject.getBuild().getDirectory(), timeout, domain, xUnit);
        testSuiteRunner.runTestSuite(testSuite);

    } catch (AETException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}