简体   繁体   English

Gradle Spring Boot插件在Linux上损坏

[英]Gradle Spring Boot plugin broken on Linux

I have a multimodule gradle build with a single module containing a spring boot application that consumes the artifacts of the other modules. 我有一个包含单个模块的多模块gradle构建,该模块包含一个使用其他模块工件的spring boot应用程序。 I have the spring boot plugin applied to the single spring boot module. 我已将spring boot插件应用于单个spring boot模块。

Everything works correctly in Windows, but once I try the build on a Linux machine if fails. 一切都可以在Windows中正常运行,但是一旦失败,我尝试在Linux机器上进行构建。 I have tried multiple linux machines (Jenkins server, Ubuntu VM, even bitbucket pipeline) and it fails with this error: 我已经尝试了多台Linux机器(Jenkins服务器,Ubuntu VM,甚至bitbucket管道),但由于以下错误而失败:

Problems reading data from Binary store in /tmp/gradle2075404181876889604.bin (exist: false)

I am not entirely sure what gradle uses this binary store for, but after debugging I found that this file name is different than binary store that every other module is using while building. 我不完全确定gradle将二进制存储库用于什么,但是在调试之后,我发现此文件名与构建时每个其他模块正在使用的二进制存储库不同。

I have tried multiple gradle versions(2, 3, and 4) and several spring boot versions and they all fail with the same error. 我尝试了多个gradle版本(2、3和4)和几个spring boot版本,它们都因相同的错误而失败。 The only thing that fixes this is removing the spring boot plugin. 解决此问题的唯一方法是删除spring boot插件。

Here is the parent build.gradle 这是父build.gradle

    repositories {
        mavenCentral()
    }

    def javaLangVersion = '1.8'
    def gradleDir = "${rootProject.rootDir}/gradle"
    def realProjects = allprojects - [project(':external'), project(':delivery')]
    def javaProjects = realProjects - rootProject
    def integrationTestProjects = javaProjects

    configure(realProjects) {
        group 'com.packagename'
        version '1.0-SNAPSHOT'

        apply plugin: 'eclipse'
        apply plugin: 'idea'
    }

    configure(javaProjects) {
        apply plugin: 'java'

        targetCompatibility = javaLangVersion
        sourceCompatibility = javaLangVersion

        repositories {
            mavenCentral()
        }

        dependencies {
            compile group: 'org.slf4j', name: 'slf4j-api', version: "${slf4jVersion}"
            compile group: 'org.slf4j', name: 'log4j-over-slf4j', version: "${slf4jVersion}"

            testCompile group: 'junit', name: 'junit', version: "${junitVersion}"
            testCompile group: 'org.mockito', name: 'mockito-core', version: "${mockitoVersion}"
            testCompile group: 'nl.jqno.equalsverifier', name: 'equalsverifier', version: "${equalsverifierVersion}"
        }
    }

    configure(integrationTestProjects) {
        apply from: "${gradleDir}/integrationTest.gradle"
    }

    task wrapper(type: Wrapper) {
        gradleVersion = '3.5'
    }

Here is the spring boot module build.gradle file: 这是Spring Boot模块的build.gradle文件:

buildscript {
    ext {
        springBootVersion = '1.5.3.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootStarterVersion}")
    }
}

apply plugin: 'org.springframework.boot'
apply plugin: 'war'

war {
    baseName = "${project.name}"
    version = "${project.version}"
}

dependencies {
    compile project(':module1')
    compile project(':module2')

    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-rest'

    compile group: 'org.apache.httpcomponents', name: 'httpcore', version: "${httpCoreVersion}"
    compile group: 'org.apache.httpcomponents', name: 'httpclient', version: "${httpClientVersion}"

    compile group: 'com.h2database', name: 'h2', version: "${h2Version}"

    testCompile project(':test-utils')
    testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
}

All other modules are plain java modules and only declare a dependencies block in the build file. 所有其他模块都是纯Java模块,并且仅在构建文件中声明依赖项块。

I have been working on this for 2 days now so any help or suggestions would be greatly appreciated. 我已经为此工作了2天,因此任何帮助或建议将不胜感激。 Thanks! 谢谢!

您是否在Linux机器上确认gradle.properties正常?

Well this is super embarrasing... I had a unit test using FileUtils.getTempDirectory() and then I was cleaning that directory using FileUtils.deleteQuietly after the test and it was deleting the gradle binary store that was in the /tmp folder. 好吧,这真令人尴尬...我使用FileUtils.getTempDirectory()进行了单元测试,然后在测试后使用FileUtils.deleteQuietly清理该目录,并删除了/ tmp文件夹中的gradle二进制存储。 The reason it wasnt showing on windows is because windows locks files. 它没有在Windows上显示的原因是Windows锁定文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM