Search in sources :

Example 1 with PluginResolverFactory

use of com.buschmais.jqassistant.commandline.plugin.PluginResolverFactory 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 2 with PluginResolverFactory

use of com.buschmais.jqassistant.commandline.plugin.PluginResolverFactory in project jqa-commandline-tool by jQAssistant.

the class Main method getPluginRepository.

/**
 * Initialize the plugin repository.
 *
 * @param configuration
 *     The {@link CliConfiguration}
 * @return The repository.
 * @throws CliExecutionException
 *     If initialization fails.
 */
private PluginRepository getPluginRepository(CliConfiguration configuration) throws CliExecutionException {
    // create classloader for the plugins/ directory.
    ClassLoader pluginDirectoryClassLoader = createPluginClassLoader();
    PluginResolverFactory pluginResolverFactory = new PluginResolverFactory();
    PluginResolver pluginResolver = pluginResolverFactory.create(configuration);
    // create plugin classloader using classloader for plugins/ directory as parent, adding plugins to be resolved frol PluginResolver
    PluginClassLoader pluginClassLoader = pluginResolver.createClassLoader(pluginDirectoryClassLoader, configuration.plugins());
    PluginConfigurationReader pluginConfigurationReader = new PluginConfigurationReaderImpl(pluginClassLoader);
    return new PluginRepositoryImpl(pluginConfigurationReader);
}
Also used : PluginConfigurationReader(com.buschmais.jqassistant.core.plugin.api.PluginConfigurationReader) PluginResolverFactory(com.buschmais.jqassistant.commandline.plugin.PluginResolverFactory) PluginClassLoader(com.buschmais.jqassistant.core.plugin.api.PluginClassLoader) PluginResolver(com.buschmais.jqassistant.core.plugin.api.PluginResolver) PluginConfigurationReaderImpl(com.buschmais.jqassistant.core.plugin.impl.PluginConfigurationReaderImpl) PluginClassLoader(com.buschmais.jqassistant.core.plugin.api.PluginClassLoader) PluginRepositoryImpl(com.buschmais.jqassistant.core.plugin.impl.PluginRepositoryImpl)

Aggregations

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