Search in sources :

Example 21 with ConfigurationManager

use of org.walkmod.conf.ConfigurationManager in project walkmod-core by walkmod.

the class WalkModFacade method createConfig.

private Configuration createConfig(String[] chains, ConfigurationProvider... cp) throws InvalidConfigurationException {
    Configuration config = new ConfigurationImpl();
    try {
        DynamicConfigurationProvider prov = new DynamicConfigurationProvider(options, chains);
        prov.init(config);
        prov.load();
        ConfigurationManager cfgManager = new ConfigurationManager(config, cp);
        DynamicModulesConfigurationProvider prov2 = new DynamicModulesConfigurationProvider();
        prov2.init(config);
        prov2.load();
        config = cfgManager.getConfiguration();
        config.setParameters(options.getMutableCopyOfDynamicArgs());
    } catch (Exception e) {
        printConfigError(e);
    }
    return config;
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) DynamicConfigurationProvider(org.walkmod.conf.providers.DynamicConfigurationProvider) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) ConfigurationManager(org.walkmod.conf.ConfigurationManager) DynamicModulesConfigurationProvider(org.walkmod.conf.providers.DynamicModulesConfigurationProvider) WalkModException(org.walkmod.exceptions.WalkModException) IOException(java.io.IOException) InvalidConfigurationException(org.walkmod.exceptions.InvalidConfigurationException)

Example 22 with ConfigurationManager

use of org.walkmod.conf.ConfigurationManager in project walkmod-core by walkmod.

the class WalkModFacade method removeExcludesToChain.

/**
 * Removes a list of excludes rules into a chain
 *
 * @param chain
 *            Chain to apply the excludes list
 * @param excludes
 *            List of excludes
 * @param recursive
 *            If it necessary to set the parameter to all the submodules.
 * @param setToReader
 *            If it is added into the reader includes list
 * @param setToWriter
 *            If it is added into the writer includes list
 */
public void removeExcludesToChain(String chain, List<String> excludes, boolean recursive, boolean setToReader, boolean setToWriter) {
    long startTime = System.currentTimeMillis();
    Exception exception = null;
    if (cfg.exists()) {
        userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
        System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());
        try {
            ConfigurationManager manager = new ConfigurationManager(cfg, false);
            manager.getProjectConfigurationProvider().removeExcludesFromChain(chain, excludes, recursive, setToReader, setToWriter);
        } catch (Exception e) {
            exception = e;
        } finally {
            System.setProperty("user.dir", userDir);
            updateMsg(startTime, exception);
        }
    }
}
Also used : File(java.io.File) ConfigurationManager(org.walkmod.conf.ConfigurationManager) WalkModException(org.walkmod.exceptions.WalkModException) IOException(java.io.IOException) InvalidConfigurationException(org.walkmod.exceptions.InvalidConfigurationException)

Example 23 with ConfigurationManager

use of org.walkmod.conf.ConfigurationManager in project walkmod-core by walkmod.

the class WalkModFacade method addProviderConfig.

/**
 * Adds a new provider configuration into the configuration file
 *
 * @param providerCfg
 *            provider configuration to add.
 * @param recursive
 *            if the provider config is added recursively to all the submodules.
 * @throws Exception
 *             in case that the walkmod configuration file can't be read.
 */
public void addProviderConfig(ProviderConfig providerCfg, boolean recursive) throws Exception {
    long startTime = System.currentTimeMillis();
    Exception exception = null;
    if (!cfg.exists()) {
        init();
    }
    userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
    System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());
    try {
        ConfigurationManager manager = new ConfigurationManager(cfg, false);
        ProjectConfigurationProvider cfgProvider = manager.getProjectConfigurationProvider();
        cfgProvider.addProviderConfig(providerCfg, recursive);
    } catch (Exception e) {
        exception = e;
    } finally {
        System.setProperty("user.dir", userDir);
        updateMsg(startTime, exception);
    }
}
Also used : ProjectConfigurationProvider(org.walkmod.conf.ProjectConfigurationProvider) File(java.io.File) ConfigurationManager(org.walkmod.conf.ConfigurationManager) WalkModException(org.walkmod.exceptions.WalkModException) IOException(java.io.IOException) InvalidConfigurationException(org.walkmod.exceptions.InvalidConfigurationException)

Aggregations

ConfigurationManager (org.walkmod.conf.ConfigurationManager)23 IOException (java.io.IOException)21 File (java.io.File)20 InvalidConfigurationException (org.walkmod.exceptions.InvalidConfigurationException)20 WalkModException (org.walkmod.exceptions.WalkModException)20 ProjectConfigurationProvider (org.walkmod.conf.ProjectConfigurationProvider)12 Configuration (org.walkmod.conf.entities.Configuration)5 ConfigurationImpl (org.walkmod.conf.entities.impl.ConfigurationImpl)2 DynamicConfigurationProvider (org.walkmod.conf.providers.DynamicConfigurationProvider)2 DynamicModulesConfigurationProvider (org.walkmod.conf.providers.DynamicModulesConfigurationProvider)2 DateFormat (java.text.DateFormat)1 DecimalFormat (java.text.DecimalFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1 ConfigurationProvider (org.walkmod.conf.ConfigurationProvider)1 PluginConfig (org.walkmod.conf.entities.PluginConfig)1 IvyConfigurationProvider (org.walkmod.conf.providers.IvyConfigurationProvider)1