org.codehaus.plexus.component.configurator.ComponentConfigurationException Java Examples
The following examples show how to use
org.codehaus.plexus.component.configurator.ComponentConfigurationException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OptionallyConfigurableComponentConverter.java From jdmn with Apache License 2.0 | 6 votes |
private OptionallyConfigurableMojoComponent configureCompoundComponent(OptionallyConfigurableMojoComponent component, PlexusConfiguration configuration) throws ComponentConfigurationException { PlexusConfiguration name = configuration.getChild(OptionallyConfigurableMojoComponent.ELEMENT_NAME, false); if (name == null || name.getValue() == null) { throw new ComponentConfigurationException(String.format( "Cannot configure component; \"%s\" property must be provided", OptionallyConfigurableMojoComponent.ELEMENT_NAME)); } component.setName(name.getValue()); PlexusConfiguration config = configuration.getChild(OptionallyConfigurableMojoComponent.ELEMENT_CONFIGURATION, false); if (config != null) { component.setConfiguration(generateConfigurationMap(config)); } return component; }
Example #2
Source File: IncludeProjectDependenciesComponentConfigurator.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private static void addProjectDependenciesToClassRealm( final ExpressionEvaluator expressionEvaluator, final ClassRealm containerRealm) throws ComponentConfigurationException { final List<String> runtimeClasspathElements; try { // noinspection unchecked runtimeClasspathElements = (List<String>) expressionEvaluator.evaluate( "${project.runtimeClasspathElements}"); } catch (ExpressionEvaluationException e) { throw new ComponentConfigurationException( "There was a problem evaluating: ${project.runtimeClasspathElements}", e); } // Add the project dependencies to the ClassRealm final URL[] urls = buildURLs(runtimeClasspathElements); for (URL url : urls) { containerRealm.addConstituent(url); } }
Example #3
Source File: IncludeProjectDependenciesComponentConfigurator.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Nonnull private static URL[] buildURLs(@Nonnull final List<String> runtimeClasspathElements) throws ComponentConfigurationException { // Add the projects classes and dependencies final List<URL> urls = new ArrayList<>(runtimeClasspathElements.size()); for (String element : runtimeClasspathElements) { try { URL url = new File(element).toURI().toURL(); urls.add(url); } catch (MalformedURLException e) { throw new ComponentConfigurationException( "Unable to access project dependency: " + element, e); } } return urls.toArray(new URL[urls.size()]); }
Example #4
Source File: IncludeProjectDependenciesComponentConfigurator.java From protostuff-compiler with Apache License 2.0 | 6 votes |
private void addProjectDependenciesToClassRealm(ExpressionEvaluator expressionEvaluator, ClassRealm realm) throws ComponentConfigurationException { List<String> runtimeClasspathElements; try { // noinspection unchecked runtimeClasspathElements = (List<String>) expressionEvaluator .evaluate("${project.runtimeClasspathElements}"); } catch (ExpressionEvaluationException e) { throw new ComponentConfigurationException( "There was a problem evaluating: ${project.runtimeClasspathElements}", e); } // Add the project dependencies to the ClassRealm final URL[] urls = buildUrls(runtimeClasspathElements); for (URL url : urls) { realm.addURL(url); } }
Example #5
Source File: IncludeProjectDependenciesComponentConfigurator.java From protostuff with Apache License 2.0 | 6 votes |
private URL[] buildURLs(List<String> runtimeClasspathElements) throws ComponentConfigurationException { // Add the projects classes and dependencies List<URL> urls = new ArrayList<URL>(runtimeClasspathElements.size()); for (String element : runtimeClasspathElements) { try { final URL url = new File(element).toURI().toURL(); urls.add(url); } catch (MalformedURLException e) { throw new ComponentConfigurationException("Unable to access project dependency: " + element, e); } } // Add the plugin's dependencies (so Trove stuff works if Trove isn't on return urls.toArray(new URL[urls.size()]); }
Example #6
Source File: IncludeProjectDependenciesComponentConfigurator.java From protostuff with Apache License 2.0 | 6 votes |
private void addProjectDependenciesToClassRealm(ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm) throws ComponentConfigurationException { List<String> runtimeClasspathElements; try { // noinspection unchecked runtimeClasspathElements = (List<String>) expressionEvaluator .evaluate("${project.runtimeClasspathElements}"); } catch (ExpressionEvaluationException e) { throw new ComponentConfigurationException( "There was a problem evaluating: ${project.runtimeClasspathElements}", e); } // Add the project dependencies to the ClassRealm final URL[] urls = buildURLs(runtimeClasspathElements); for (URL url : urls) { containerRealm.addConstituent(url); } }
Example #7
Source File: OptionallyConfigurableComponentConverter.java From jdmn with Apache License 2.0 | 5 votes |
@Override public Object fromConfiguration(ConverterLookup lookup, PlexusConfiguration configuration, Class<?> type, Class<?> enclosingType, ClassLoader loader, ExpressionEvaluator evaluator, ConfigurationListener listener) throws ComponentConfigurationException { OptionallyConfigurableMojoComponent component; if (configuration == null) { throw new ComponentConfigurationException("Cannot instantiate component from null configuration"); } // Instantiate the type as defined in Mojo configuration try { component = (OptionallyConfigurableMojoComponent)type.newInstance(); } catch (InstantiationException | IllegalAccessException ex) { throw new ComponentConfigurationException(String.format( "Cannot instantiate configurable component type \"%s\" (%s)", type.getName(), ex.getMessage()), ex); } if (component == null) { throw new ComponentConfigurationException(String.format( "Failed to instantiate new configurable component type \"%s\"", type.getName())); } // Verify that we are deserializing the expected content type if (!configuration.getName().equals(component.getElementName())) { throw new ComponentConfigurationException(String.format( "Invalid component element \"%s\"; component definition accepts only \"%s\" elements", configuration.getName(), component.getElementName())); } // Deserialize from either simple or compound data depending on structure of the input configuration if (configuration.getChildCount() == 0) { return configureSimpleComponent(component, configuration); } else { return configureCompoundComponent(component, configuration); } }
Example #8
Source File: IncludeProjectDependenciesComponentConfigurator.java From swagger-maven-plugin with Apache License 2.0 | 5 votes |
private URL[] buildURLs(List<String> runtimeClasspathElements) throws ComponentConfigurationException { // Add the projects classes and dependencies List<URL> urls = new ArrayList<URL>(runtimeClasspathElements.size()); for (String element : runtimeClasspathElements) { try { final URL url = new File(element).toURI().toURL(); urls.add(url); } catch (MalformedURLException e) { throw new ComponentConfigurationException("Unable to access project dependency: " + element, e); } } // Add the plugin's dependencies (so Trove stuff works if Trove isn't on return urls.toArray(new URL[urls.size()]); }
Example #9
Source File: IncludeProjectDependenciesComponentConfigurator.java From swagger-maven-plugin with Apache License 2.0 | 5 votes |
private void addProjectDependenciesToClassRealm(ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm) throws ComponentConfigurationException { List<String> compileClasspathElements; try { //noinspection unchecked compileClasspathElements = (List<String>) expressionEvaluator.evaluate("${project.compileClasspathElements}"); } catch (ExpressionEvaluationException e) { throw new ComponentConfigurationException("There was a problem evaluating: ${project.compileClasspathElements}", e); } // Add the project dependencies to the ClassRealm final URL[] urls = buildURLs(compileClasspathElements); for (URL url : urls) { containerRealm.addConstituent(url); } }
Example #10
Source File: IncludeProjectDependenciesComponentConfigurator.java From swagger-maven-plugin with Apache License 2.0 | 5 votes |
@Override public void configureComponent(Object component, PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm, ConfigurationListener listener) throws ComponentConfigurationException { addProjectDependenciesToClassRealm(expressionEvaluator, containerRealm); ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter(); converter.processConfiguration(converterLookup, component, containerRealm.getClassLoader(), configuration, expressionEvaluator, listener); }
Example #11
Source File: MojoConfigurator.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
@Override public void configureComponent(final Object mojoInstance, // final PlexusConfiguration pluginConfigurationFromMaven, // final ExpressionEvaluator evaluator, // final ClassRealm realm, // final ConfigurationListener listener) throws ComponentConfigurationException { super.configureComponent(mojoInstance, pluginConfigurationFromMaven, evaluator, realm, listener); }
Example #12
Source File: MojoConfigurationProcessor.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
String determineGoal(String className, PluginDescriptor pluginDescriptor) throws ComponentConfigurationException { List<MojoDescriptor> mojos = pluginDescriptor.getMojos(); for (MojoDescriptor mojo : mojos) { if (className.equals(mojo.getImplementation())) { return mojo.getGoal(); } } throw new ComponentConfigurationException("Cannot find the goal implementation with " + className); }
Example #13
Source File: MojoConfigurationProcessor.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
Xpp3Dom convert(PlexusConfiguration c) throws ComponentConfigurationException { try { return Xpp3DomBuilder.build(new StringReader(c.toString())); } catch (Exception e) { throw new ComponentConfigurationException("Failure converting PlexusConfiguration to Xpp3Dom.", e); } }
Example #14
Source File: MojoConfigurationProcessor.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
/** * Extract the Mojo specific configuration from the incoming plugin configuration from Maven by looking at an enclosing element with the goal name. Use this and merge it with the default Mojo * configuration and use this to apply values to the Mojo. * * @param goal * @param pluginConfigurationFromMaven * @param defaultMojoConfiguration * @return * @throws ComponentConfigurationException */ PlexusConfiguration extractAndMerge(String goal, PlexusConfiguration pluginConfigurationFromMaven, PlexusConfiguration defaultMojoConfiguration) throws ComponentConfigurationException { // // We need to extract the specific configuration for this goal out of the POM configuration // PlexusConfiguration mojoConfigurationFromPom = new XmlPlexusConfiguration("configuration"); for (PlexusConfiguration element : pluginConfigurationFromMaven.getChildren()) { if (element.getName().equals(goal)) { for (PlexusConfiguration goalConfigurationElements : element.getChildren()) { mojoConfigurationFromPom.addChild(goalConfigurationElements); } } } return new XmlPlexusConfiguration(Xpp3Dom.mergeXpp3Dom(convert(mojoConfigurationFromPom), convert(defaultMojoConfiguration))); }
Example #15
Source File: MojoConfigurationProcessor.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
public PlexusConfiguration mojoConfigurationFor(Object mojoInstance, PlexusConfiguration pluginConfigurationFromMaven) throws ComponentConfigurationException { try (InputStream is = mojoInstance.getClass().getResourceAsStream("/META-INF/maven/plugin.xml")) { PluginDescriptor pd = pluginDescriptorBuilder.build(new InputStreamReader(is, "UTF-8")); // closes input stream too String goal = determineGoal(mojoInstance.getClass().getName(), pd); PlexusConfiguration defaultMojoConfiguration = pd.getMojo(goal).getMojoConfiguration(); PlexusConfiguration mojoConfiguration = extractAndMerge(goal, pluginConfigurationFromMaven, defaultMojoConfiguration); return mojoConfiguration; } catch (Exception e) { throw new ComponentConfigurationException(e); } }
Example #16
Source File: IncludeProjectDependenciesComponentConfigurator.java From protostuff with Apache License 2.0 | 5 votes |
public void configureComponent(Object component, PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm, ConfigurationListener listener) throws ComponentConfigurationException { addProjectDependenciesToClassRealm(expressionEvaluator, containerRealm); converterLookup.registerConverter(new ClassRealmConverter(containerRealm)); ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter(); converter.processConfiguration(converterLookup, component, containerRealm.getClassLoader(), configuration, expressionEvaluator, listener); }
Example #17
Source File: IncludeProjectDependenciesComponentConfigurator.java From protostuff-compiler with Apache License 2.0 | 5 votes |
private URL[] buildUrls(List<String> runtimeClasspathElements) throws ComponentConfigurationException { // Add the projects classes and dependencies List<URL> urls = new ArrayList<>(runtimeClasspathElements.size()); for (String element : runtimeClasspathElements) { try { final URL url = new File(element).toURI().toURL(); urls.add(url); } catch (MalformedURLException e) { throw new ComponentConfigurationException("Unable to access project dependency: " + element, e); } } // Add the plugin's dependencies (so Trove stuff works if Trove isn't on return urls.toArray(new URL[urls.size()]); }
Example #18
Source File: IncludeProjectDependenciesComponentConfigurator.java From protostuff-compiler with Apache License 2.0 | 5 votes |
@Override public void configureComponent(Object component, PlexusConfiguration configuration, ExpressionEvaluator evaluator, ClassRealm realm, ConfigurationListener listener) throws ComponentConfigurationException { addProjectDependenciesToClassRealm(evaluator, realm); converterLookup.registerConverter(new ClassRealmConverter(realm)); ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter(); converter.processConfiguration(converterLookup, component, realm.getParentClassLoader(), configuration, evaluator, listener); }
Example #19
Source File: IncludeProjectDependenciesComponentConfigurator.java From incubator-hivemall with Apache License 2.0 | 5 votes |
public void configureComponent(final Object component, final PlexusConfiguration configuration, final ExpressionEvaluator expressionEvaluator, final ClassRealm containerRealm, final ConfigurationListener listener) throws ComponentConfigurationException { addProjectDependenciesToClassRealm(expressionEvaluator, containerRealm); converterLookup.registerConverter(new ClassRealmConverter(containerRealm)); ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter(); converter.processConfiguration(converterLookup, component, containerRealm.getClassLoader(), configuration, expressionEvaluator, listener); }
Example #20
Source File: DMNTransformerComponentConfigurationTest.java From jdmn with Apache License 2.0 | 5 votes |
@Test(expected = ComponentConfigurationException.class) public void testMissingComponentName() throws Exception { PlexusConfiguration config = new DefaultPlexusConfiguration(OptionallyConfigurableMojoComponent.ELEMENT_CONFIGURATION) .addChild("key1", "value1") .addChild("key2", "value2"); PlexusConfiguration configuration = generateComponentConfiguration(null, ELEMENT_NAME, config); parseConfiguration(configuration, DMNTransformerComponent.class); Assert.fail("Test is expected to fail; mandatory component name was not provided"); }
Example #21
Source File: DMNMojoComponentConfigurator.java From jdmn with Apache License 2.0 | 5 votes |
@Override public void configureComponent(final Object component, final PlexusConfiguration configuration, final ExpressionEvaluator evaluator, final ClassRealm realm, final ConfigurationListener listener) throws ComponentConfigurationException { // Register custom type conversion for optionally-configurable types, i.e. those which can be specified as a // simple string or as a components with a name and configuration converterLookup.registerConverter(new OptionallyConfigurableComponentConverter()); super.configureComponent(component, configuration, evaluator, realm, listener); }
Example #22
Source File: SchemaGeneratorMojoTest.java From jsonschema-generator with Apache License 2.0 | 5 votes |
/** * Unit test that will generate from a maven pom file fragment and expect a ComponentConfigurationException. * * @param testCaseName Name of the test case and file name prefix of the example {@code pom.xml} * @throws Exception In case something goes wrong */ @Test(expected = ComponentConfigurationException.class) @Parameters public void testPomConfigurationErrors(String testCaseName) throws Exception { File testCaseLocation = new File("src/test/resources/error-test-cases"); executePom(new File(testCaseLocation, testCaseName + "-pom.xml")); }
Example #23
Source File: PojoGenerationConfigTest.java From springmvc-raml-plugin with Apache License 2.0 | 4 votes |
@Test(expected = ComponentConfigurationException.class) public void testUnknownParameterConfig() throws Exception { @SuppressWarnings("unused") final SpringMvcEndpointGeneratorMojo mojo = (SpringMvcEndpointGeneratorMojo) configureMojo("unknown", "invalid"); }
Example #24
Source File: MojoConfigurationProcessor.java From takari-lifecycle with Eclipse Public License 1.0 | 4 votes |
PlexusConfiguration mergePlexusConfiguration(PlexusConfiguration dominant, PlexusConfiguration recessive) throws ComponentConfigurationException { return new XmlPlexusConfiguration(Xpp3Dom.mergeXpp3Dom(convert(dominant), convert(recessive))); }
Example #25
Source File: AbstractMojoConfigurationTest.java From jdmn with Apache License 2.0 | 4 votes |
protected OptionallyConfigurableMojoComponent parseConfiguration(PlexusConfiguration configuration, Class<?> target) throws ComponentConfigurationException { return (OptionallyConfigurableMojoComponent)converter.fromConfiguration(null, configuration, target, null, null, null, null); }