Search in sources :

Example 1 with ExecutionModeProvider

use of org.walkmod.conf.providers.ExecutionModeProvider in project walkmod-core by walkmod.

the class WalkModFacade method run.

private void run(List<File> result, WalkmodCommand command, ExecutionModeEnum execMode, String... chains) throws InvalidConfigurationException {
    userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
    System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());
    Configuration config = null;
    if (cfg.exists()) {
        if (options.isVerbose()) {
            log.info(cfg.getAbsoluteFile() + " [ok]");
        }
        config = readConfig(locateConfigurationProvider(), new ExecutionModeProvider(execMode));
    } else {
        config = createConfig(chains, locateConfigurationProvider(), new ExecutionModeProvider(execMode));
    }
    try {
        config.executeModuleChains(options, command, chains);
    } catch (Exception e) {
        System.setProperty("user.dir", userDir);
        if (options.isVerbose()) {
            if (!options.isPrintErrors()) {
                log.error(cfg.getAbsolutePath() + " is invalid. Please, execute walkmod with -e to see the details.");
            } else {
                log.error("Invalid configuration", e);
            }
            if (options.isThrowException()) {
                RuntimeException re = new RuntimeException();
                re.setStackTrace(e.getStackTrace());
                throw re;
            }
        } else {
            throw new InvalidConfigurationException(e);
        }
    }
    config.execute(userDir, options, chains);
    result.addAll(Summary.getInstance().getWrittenFiles());
    System.setProperty("user.dir", userDir);
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) File(java.io.File) ExecutionModeProvider(org.walkmod.conf.providers.ExecutionModeProvider) WalkModException(org.walkmod.exceptions.WalkModException) IOException(java.io.IOException) InvalidConfigurationException(org.walkmod.exceptions.InvalidConfigurationException) InvalidConfigurationException(org.walkmod.exceptions.InvalidConfigurationException)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 Configuration (org.walkmod.conf.entities.Configuration)1 ExecutionModeProvider (org.walkmod.conf.providers.ExecutionModeProvider)1 InvalidConfigurationException (org.walkmod.exceptions.InvalidConfigurationException)1 WalkModException (org.walkmod.exceptions.WalkModException)1