If I have two maven plugins, where A depends on B and B has configuration parameters, how and where should I define configuration for B?
I could think of three solutions, which of one I know is not applicable, and I'm not sure which one works, or there are any more possiblities. Unfortunately, I couldn't find any example even for this simple case.
Try 1 (not possible)
Put <configuration> under dependencies. This is not possible as a <dependency> tag cannot contain a <configuration> tag (see xsd).
<plugin>
<groupId>A</groupId>
<artifactId>A</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>B</groupId>
<artifactId>B</artifactId>
<version>1.0.0</version>
<configuration>
<paramForB><param>bbb</param></paramForB>
</configuration>
</dependency>
</dependencies>
</plugin>
Try 2
Put the configuration parameter under the config of A.
<plugin>
<groupId>A</groupId>
<artifactId>A</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>B</groupId>
<artifactId>B</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<configuration>
<paramForB><param>bbb</param></paramForB>
</configuration>
</plugin>
Try 3
Introduce B as a separate plugin with the configuration I need.
<plugin>
<groupId>B</groupId>
<artifactId>B</artifactId>
<version>1.0.0</version>
<configuration>
<paramForB><param>bbb</param></paramForB>
</configuration>
</plugin>
<plugin>
<groupId>A</groupId>
<artifactId>A</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>B</groupId>
<artifactId>B</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>
Further questions (just curious)
- Also, what if
Bdepends onC. How should I configureC? - And if I have a maven plugin
Xwhich also depends onBbut would use it with other configuration: can I do that?