gradle:在projectB中获取projectA战争文件

时间:2019-05-25 19:46:43

标签: java spring spring-boot gradle

这是您感兴趣的项目设置。 Range API

include ':sb-2.1-multi-package', ':sb-2.1-multi-package:hello-rest-lib', 
        ':sb-2.1-multi-package:hello-rest-standalone-jar',
        ':sb-2.1-multi-package:hello-rest-war'
include 'sb-2.1-3pp-resources'
include 'sb-2.1-build'

向sb-2.1-build.tar.gz添加hello-rest-war失败。
而不是war文件,而是打包的依赖项。

dependencies {
    archivesDeps    project(path: ':sb-2.1-3pp-resources', configuration: 'archives')
    javaDeps project(":sb-2.1-multi-package:hello-rest-war")
}

...    
task copyJavaDeps(type: Copy) {
    inputs.files(configurations.javaDeps)
    from configurations.javaDeps
    into "${ARCHIVE_DIRECTORY}/lib"
}

...
// create distribution bundle
distributions {
    main {
        contents {
            from ARCHIVE_DIRECTORY
            into "/springapp/multimodule"
        }
    }
}

包装内容

springapp/multimodule/lib/classmate-1.4.0.jar
springapp/multimodule/lib/hello-rest-lib-0.0.1-SNAPSHOT.jar
springapp/multimodule/lib/hibernate-validator-6.0.16.Final.jar
...
springapp/multimodule/lib/tomcat-embed-websocket-9.0.17.jar
springapp/multimodule/lib/validation-api-2.0.1.Final.jar    
springapp/multimodule/sb-2.1-3pp-resources/config/3pp.json

如何打包war文件(hello-rest-war模块)并且没有所有传递依赖项?

0 个答案:

没有答案