简体   繁体   中英

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. We use Continuous Integration with maven 3, svn and Jenkins. We have one utility java project in which we've implemented some useful features. We build a jenkins tasks to run the mainClass in this project. Here is the code snippet on project 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 :

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 ? Is it possible to have two main classes in the same pom.xml configuration ?

I know i could create another project and configure a mainClass in the pom. 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/

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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