use of com.buschmais.jqassistant.core.configuration.api.ConfigurationLoader 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);
}
use of com.buschmais.jqassistant.core.configuration.api.ConfigurationLoader 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);
}
Aggregations