1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugin.internal;
20
21 import com.google.inject.Binder;
22 import com.google.inject.Module;
23 import com.google.inject.name.Names;
24 import org.apache.maven.api.model.Plugin;
25 import org.apache.maven.api.xml.XmlNode;
26 import org.apache.maven.internal.xml.XmlNodeImpl;
27 import org.apache.maven.internal.xml.XmlPlexusConfiguration;
28 import org.codehaus.plexus.configuration.PlexusConfiguration;
29
30 class PluginConfigurationModule implements Module {
31
32 private final Plugin plugin;
33
34 PluginConfigurationModule(Plugin plugin) {
35 this.plugin = plugin;
36 }
37
38 @Override
39 public void configure(Binder binder) {
40 if (plugin.getKey() != null) {
41 XmlNode configuration = plugin.getConfiguration();
42 if (configuration == null) {
43 configuration = new XmlNodeImpl("configuration");
44 }
45 binder.bind(XmlNode.class)
46 .annotatedWith(Names.named(plugin.getKey()))
47 .toInstance(configuration);
48 binder.bind(PlexusConfiguration.class)
49 .annotatedWith(Names.named(plugin.getKey()))
50 .toInstance(XmlPlexusConfiguration.toPlexusConfiguration(configuration));
51 }
52 }
53 }