Gradle application plugin with multiple main classes

前端 未结 4 1376
南方客
南方客 2021-02-20 04:55

I\'m using the gradle \'application\' plugin to start my application. This works well. Now I want to add the option to start a different main class in the same project. Can I ch

4条回答
  •  失恋的感觉
    2021-02-20 05:24

    You can directly configure the Application Plugin with properties:

    application {
        mainClassName = project.findProperty("chooseMain").toString()
    }
    

    And after in command line you can pass the name of the main class:

    ./gradlew run -PchooseMain=net.worcade.my.MainClass
    

提交回复
热议问题