Is it possible to specify multiple main classes using gradle 'application' plugin

后端 未结 3 1107
南方客
南方客 2021-01-03 23:42

I would like to use the Gradle \"application\" plugin to create startScripts for a second mainClass. Is this possible? Even if the application plugin doesn\'t have this func

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-04 00:24

    I combined parts of both of these answers to arrive at the relatively simple solution:

    task otherStartScripts(type: CreateStartScripts) {
        description "Creates OS specific scripts to call the 'other' entry point"
        classpath = startScripts.classpath
        outputDir = startScripts.outputDir
        mainClassName = 'some.package.app.Other'
        applicationName = 'other'
    }
    
    distZip {
        baseName = archivesBaseName
        classifier = 'app'
        //include our extra start script 
        //this is a bit weird, I'm open to suggestions on how to do this better
        into("${baseName}-${version}-${classifier}/bin") {
            from otherStartScripts
            fileMode = 0755
        }
    }
    

    startScripts is created when the application plugin is applied.

提交回复
热议问题