Add classpath in manifest using Gradle

前端 未结 9 1634
醉话见心
醉话见心 2020-12-01 02:51

I would like my Gradle build script to add the complete Classpath to the manifest file contained in JAR file created after the build.

Example:

Manife         


        
9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 03:29

    I managed to create a custom Jar file with its own manifest file like so:

    task createJar(type : Jar) {
        manifest {
            attributes(
                'Manifest-Version': "1.0",
                'Main-Class': "org.springframework.boot.loader.JarLauncher",
                'Start-Class': "com.my.app.AppApplication",
                'Spring-Boot-Version': "2.2.4.RELEASE",
                'Spring-Boot-Classes': "BOOT-INF/classes/",
                'Spring-Boot-Lib': "BOOT-INF/lib/"
            )
        }
        def originDir = file("${buildDir}/unpacked")
        def destinationFile = "${buildDir}/repackaged/${project.name}-${version}"
        entryCompression ZipEntryCompression.STORED // no compression in case there are files in BOOT-INF/lib
        archiveName destinationFile
        from originDir
        archiveFile
    }
    

提交回复
热议问题