Search in sources :

Example 1 with ConfigurationLoaderImpl

use of com.buschmais.jqassistant.core.configuration.impl.ConfigurationLoaderImpl in project jqa-core-framework by jQAssistant.

the class AbstractPluginIT method createConfiguration.

/**
 * Load configuration for ITs.
 *
 * @return The  configuration.
 */
private Configuration createConfiguration(PropertiesConfigBuilder propertiesConfigBuilder) {
    ConfigurationLoader configurationLoader = new ConfigurationLoaderImpl(ConfigurationLoader.getDefaultConfigurationDirectory(getClassesDirectory(this.getClass())));
    PropertiesConfigSource propertiesConfigSource = propertiesConfigBuilder.build();
    return configurationLoader.load(Configuration.class, propertiesConfigSource);
}
Also used : PropertiesConfigSource(io.smallrye.config.PropertiesConfigSource) ConfigurationLoaderImpl(com.buschmais.jqassistant.core.configuration.impl.ConfigurationLoaderImpl) ConfigurationLoader(com.buschmais.jqassistant.core.configuration.api.ConfigurationLoader)

Example 2 with ConfigurationLoaderImpl

use of com.buschmais.jqassistant.core.configuration.impl.ConfigurationLoaderImpl in project jqa-commandline-tool by jQAssistant.

the class CliPluginResolverIT method resolve.

@Test
void resolve() {
    Map<String, String> configurationProperties = new HashMap<>();
    configurationProperties.put("jqassistant.plugins[0].group-id", "org.jqassistant.contrib.plugin");
    configurationProperties.put("jqassistant.plugins[0].artifact-id", "jqassistant-docker-plugin");
    configurationProperties.put("jqassistant.plugins[0].version", "1.11.0");
    PropertiesConfigSource testConfigSource = new PropertiesConfigSource(configurationProperties, "TestConfigSource", 110);
    ConfigurationLoaderImpl configurationLoader = new ConfigurationLoaderImpl(new File("src/test/resources"));
    CliConfiguration cliConfiguration = configurationLoader.load(CliConfiguration.class, testConfigSource);
    PluginResolverFactory pluginResolverFactory = new PluginResolverFactory();
    PluginResolver pluginResolver = pluginResolverFactory.create(cliConfiguration);
    PluginClassLoader pluginClassLoader = pluginResolver.createClassLoader(PluginResolverFactory.class.getClassLoader(), cliConfiguration.plugins());
    assertThat(pluginClassLoader).isNotNull();
}
Also used : PropertiesConfigSource(io.smallrye.config.PropertiesConfigSource) HashMap(java.util.HashMap) PluginResolverFactory(com.buschmais.jqassistant.commandline.plugin.PluginResolverFactory) ConfigurationLoaderImpl(com.buschmais.jqassistant.core.configuration.impl.ConfigurationLoaderImpl) PluginResolver(com.buschmais.jqassistant.core.plugin.api.PluginResolver) File(java.io.File) CliConfiguration(com.buschmais.jqassistant.commandline.configuration.CliConfiguration) PluginClassLoader(com.buschmais.jqassistant.core.plugin.api.PluginClassLoader) Test(org.junit.jupiter.api.Test)

Example 3 with ConfigurationLoaderImpl

use of com.buschmais.jqassistant.core.configuration.impl.ConfigurationLoaderImpl in project jqa-commandline-tool by jQAssistant.

the class Main method interpretCommandLine.

/**
 * Parse the command line and execute the requested task.
 *
 * @param commandLine
 *            The command line.
 * @param options
 *            The known options.
 * @throws CliExecutionException
 *             If an error occurs.
 */
private void interpretCommandLine(CommandLine commandLine, Options options, TaskFactory taskFactory) throws CliExecutionException {
    if (commandLine.hasOption(OPTION_HELP)) {
        printUsage(options, null);
        System.exit(1);
    }
    List<String> taskNames = commandLine.getArgList();
    if (taskNames.isEmpty()) {
        printUsage(options, "A task must be specified, i.e. one  of " + gatherTaskNames(taskFactory));
        System.exit(1);
    }
    PropertiesConfigBuilder propertiesConfigBuilder = new PropertiesConfigBuilder("TaskConfigSource", 110);
    List<Task> tasks = new ArrayList<>();
    for (String taskName : taskNames) {
        Task task = taskFactory.fromName(taskName);
        try {
            task.withStandardOptions(commandLine, propertiesConfigBuilder);
            task.withOptions(commandLine, propertiesConfigBuilder);
        } catch (CliConfigurationException e) {
            printUsage(options, e.getMessage());
            System.exit(1);
        }
        if (task == null) {
            printUsage(options, "Unknown task " + taskName);
        }
        tasks.add(task);
    }
    File workingDirectory = new File(".");
    ConfigurationLoader configurationLoader = new ConfigurationLoaderImpl(workingDirectory);
    CliConfiguration configuration = configurationLoader.load(CliConfiguration.class, propertiesConfigBuilder.build());
    PluginRepository pluginRepository = getPluginRepository(configuration);
    Map<String, Object> properties = readProperties(commandLine);
    executeTasks(tasks, configuration, pluginRepository, properties);
}
Also used : PluginRepository(com.buschmais.jqassistant.core.plugin.api.PluginRepository) ConfigurationLoaderImpl(com.buschmais.jqassistant.core.configuration.impl.ConfigurationLoaderImpl) PropertiesConfigBuilder(com.buschmais.jqassistant.core.configuration.api.PropertiesConfigBuilder) ConfigurationLoader(com.buschmais.jqassistant.core.configuration.api.ConfigurationLoader) CliConfiguration(com.buschmais.jqassistant.commandline.configuration.CliConfiguration)

Example 4 with ConfigurationLoaderImpl

use of com.buschmais.jqassistant.core.configuration.impl.ConfigurationLoaderImpl in project jqa-maven-plugin by jQAssistant.

the class ConfigurationProvider method getConfiguration.

/**
 * Return the Configuration.
 *
 * @param executionRoot
 *     The Session execution root.
 * @param configurationDirectory
 *     The optional configuration directory.
 * @param configSources
 *     Additional {@link ConfigSource}s.
 * @return The {@link Configuration}.
 */
public synchronized Configuration getConfiguration(File executionRoot, Optional<File> configurationDirectory, ConfigSource... configSources) {
    if (configurationLoader == null) {
        File effectiveConfigurationDirectory = configurationDirectory.orElse(ConfigurationLoader.getDefaultConfigurationDirectory(executionRoot));
        configurationLoader = new ConfigurationLoaderImpl(effectiveConfigurationDirectory);
    }
    return configurationLoader.load(Configuration.class, configSources);
}
Also used : ConfigurationLoaderImpl(com.buschmais.jqassistant.core.configuration.impl.ConfigurationLoaderImpl) File(java.io.File)

Aggregations

ConfigurationLoaderImpl (com.buschmais.jqassistant.core.configuration.impl.ConfigurationLoaderImpl)4 CliConfiguration (com.buschmais.jqassistant.commandline.configuration.CliConfiguration)2 ConfigurationLoader (com.buschmais.jqassistant.core.configuration.api.ConfigurationLoader)2 PropertiesConfigSource (io.smallrye.config.PropertiesConfigSource)2 File (java.io.File)2 PluginResolverFactory (com.buschmais.jqassistant.commandline.plugin.PluginResolverFactory)1 PropertiesConfigBuilder (com.buschmais.jqassistant.core.configuration.api.PropertiesConfigBuilder)1 PluginClassLoader (com.buschmais.jqassistant.core.plugin.api.PluginClassLoader)1 PluginRepository (com.buschmais.jqassistant.core.plugin.api.PluginRepository)1 PluginResolver (com.buschmais.jqassistant.core.plugin.api.PluginResolver)1 HashMap (java.util.HashMap)1 Test (org.junit.jupiter.api.Test)1