【发布时间】:2014-05-29 12:23:40
【问题描述】:
我正在创建自己的 maven 原型,这是我使用的项目的通用模板。
在该模板中,我有许多“exec-maven-plugin”块,实际上每个项目都不同,这意味着在一个项目中我可能有 2 个“exec-maven-plugin”块,而在另一个我可能有 3 个或更多。
当他使用我创建的原型创建项目时,我希望它成为用户的驱动程序。例如,用户将被要求输入多个主类,并根据他选择输入的数量,创建许多“exec-maven-plugin”块。
例如,如果用户被要求提供他将拥有的主要课程,他可能会输入: com.domain.MyFirstMain, com.domainMySecondMain 因此 maven pom.xml 应该如下所示:
<profiles>
<profile>
<id>Main1</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<executable>java</executable>
<arguments>
<argument>com.domain.MyFirstMain</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>Main2</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<executable>java</executable>
<arguments>
<argument>com.domain.MySecondMain</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
有谁知道我是否可以在创建 maven 原型时实现这一点,或者唯一的方法是让用户在 pom.xml 中添加所需的块?
谢谢。
【问题讨论】:
标签: java maven maven-plugin maven-archetype