简体   繁体   English

是否可能在pom.xml中具有两个mainClass或能够在同一pom.xml中运行两个类?

[英]Is it possible to have two mainClass in the pom.xml or be able to run two classes in the same pom.xml?

I am working on a java project. 我正在研究Java项目。 We use Continuous Integration with maven 3, svn and Jenkins. 我们将持续集成与maven 3,svn和Jenkins结合使用。 We have one utility java project in which we've implemented some useful features. 我们有一个实用程序java项目,其中实现了一些有用的功能。 We build a jenkins tasks to run the mainClass in this project. 我们构建了一个jenkins任务来在该项目中运行mainClass。 Here is the code snippet on project pom.xml : 这是项目pom.xml上的代码片段:

<plugin>
           ..
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>com.ent.uti.Cleaner</mainClass>
                    <arguments>
                        <argument>value1</argument>
                        <argument>value2</argument>
                    </arguments>
                </configuration>
            </plugin>

This class is execute in jenkins task configuration : 此类在jenkins任务配置中执行:

mvn exec:java -o -f cleaner/pom.xml 

I am wondering if it is possible for me to implement some features in the same project and add another task in Jenkins ? 我想知道是否可以在同一项目中实现某些功能并在Jenkins中添加其他任务? Is it possible to have two main classes in the same pom.xml configuration ? 是否可以在同一pom.xml配置中具有两个主要类?

I know i could create another project and configure a mainClass in the pom. 我知道我可以创建另一个项目并在pom中配置mainClass。 I think doing so is not a good idea. 我认为这样做不是一个好主意。 The both task are independant so it's not suitable to run the both class one after another. 两个任务都是独立的,因此不适合一次又一次运行两个类。

Thanks for reading. 谢谢阅读。

You can use profiles for that purpose. 您可以为此使用配置文件。 All details are available here : http://www.jpeterson.com/2009/08/25/using-a-maven-profile-to-run-a-test-program/ 所有详细信息都可以在这里找到: http : //www.jpeterson.com/2009/08/25/using-a-maven-profile-to-run-a-test-program/

Then your command line will look like : 然后您的命令行将如下所示:

mvn -P program1 exec:java -o -f cleaner/pom.xml

mvn -P program2 exec:java -o -f cleaner/pom.xml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM