簡體   English   中英

Heroku Spring Boot沒有建立Jar

[英]Heroku Spring Boot doesn't build Jar

我正在部署到Heroku,我還沒有真正更改任何東西,現在Heroku尚未創建Jar。

盡管Gradle buildpack從未讓我失望過,但它仍處於“測試版”中。

Heroku

remote: -----> Using set buildpack heroku/gradle
remote: -----> Gradle app detected
remote: -----> Installing OpenJDK 1.8... done
remote: -----> Installing Gradle Wrapper...
remote:        WARNING: Your application does not have it's own gradlew file.
remote:        We'll install one for you, but this is a deprecated feature and
remote:        in the future may not be supported.
remote: -----> Building Gradle app...
remote:        WARNING: The Gradle buildpack is currently in Beta.
remote: -----> executing ./gradlew stage
remote:        :api:compileJavaNote: Some input files use unchecked or unsafe operations.
remote:        Note: Recompile with -Xlint:unchecked for details.
remote:        
remote:        :api:processResources
remote:        :api:classes
remote:        :api:war
remote:        :api:bootRepackage
remote:        :api:assemble
remote:        :api:cleanNode
remote:        :api:stage
remote:        BUILD SUCCESSFUL

注意缺少:api:jar ,但是在本地仍然存在。

:api:compileJava UP-TO-DATE
:api:processResources UP-TO-DATE
:api:classes UP-TO-DATE
:api:jar
:api:findMainClass
:api:startScripts
:api:distTar
:api:distZip
:api:war
:api:bootRepackage
:api:assemble
:api:cleanNode
:api:stage

BUILD SUCCESSFUL

而且Gradle直截了當。

apply plugin: "java"
apply plugin: "war"
apply plugin: "spring-boot"

task cleanNode {
    doLast {
        // clean up files we no longer need in the slug
        delete '../node_modules'
        delete '../html/bower_components'
    }
}

// used by Heroku
task stage {
    dependsOn cleanNode, assemble
}

我必須使用Gradle包裝器才能使用相同的Gradle版本。

Heroku使用Gradle 2.10,而我使用2.13。 我不確定有什么區別,但這是一件好事。

正如@codefinger所說,使用相同版本是明智的。

作為獎勵,我添加了一些清理Heroku Slug的方法以減小大小。

// used by Heroku
task stage {
    dependsOn assemble

    doLast {
        // https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku#using-grails-3
        // this still leaves around empty folders, but what are you going to do?
        delete fileTree(dir: "build", exclude: "libs")
        delete fileTree(dir: "build/libs", exclude: "*.jar")
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM