有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java构建文件不是gradle中设置文件定义的构建的一部分

今天,我为我的项目做了一件新事情,我添加了一个名为build-robot.gradle的gradle构建文件的新分支(旧分支名为build.gradle)。当我在jenkins的build阶段使用此命令构建项目时(使用不同的gradle配置构建):

./gradlew :_robot-multibranch_feature_robot:soa-robot-api:build publishMavenPublicationToMavenRepository -x test --build-file=build-robot.gradle

显示此错误:

Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.

* What went wrong:
Build file '/Users/dabaidabai/.jenkins/workspace/_robot-multibranch_feature_robot/build-robot.gradle' is not part of the build defined by settings file '/Users/dabaidabai/.jenkins/workspace/settings.gradle'. If this is an unrelated build, it must have its own settings file.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

settings.gradle配置如下:

rootProject.name = 'microservice'


include ":_robot-multibranch_feature_robot"
include ":_robot-multibranch_feature_robot:soa-robot-api"
include ":_robot-multibranch_feature_robot:soa-robot-service"

这是build-robot.gradle配置:

project(":_robot-multibranch_feature_robot") {
    dependencies {
    }
}

project(":_robot-multibranch_feature_robot:soa-robot-api") {
    jar {
        enabled = true
    }
    bootJar {
        enabled = false
    }
    archivesBaseName = "soa-robot-api"
    version = "1.0.0-SNAPSHOT"
    jar {
        enabled = true
    }
    dependencies {
        api("com.sportswin.soa:soa-misc-biz:1.0.0-RELEASE")
        api project(":packet:packet-api")
    }

    publishing {
        publications {
            maven(MavenPublication) {
                groupId 'com.sportswin.soa'
                artifactId 'soa-robot-api'
                version '1.0.0-SNAPSHOT'
                from components.java

                artifact sourceJar {
                    classifier "sources"
                }
            }
        }
        repositories {
            maven {
                url = version.endsWith('SNAPSHOT') ? "${dabaiSnapshotRepo}" : "${dabaiReleaseRepo}"
                url = "$url"
                credentials {
                    username "$mavenLoginName"
                    password "$mavenPassword"
                }
            }
        }
    }
}

project(":_robot-multibranch_feature_robot:soa-robot-service") {

    archivesBaseName = "soa-robot-service"
    version = "1.0.0-SNAPSHOT"

    bootJar {
        manifest {
            attributes 'Start-Class': 'com.sportswin.soa.robot.AppStarter'
        }
    }

    dependencies {
        implementation("com.squareup.okhttp3:okhttp:4.0.0")
        implementation("org.codehaus.groovy:groovy-all:3.0.3")
        implementation("com.sportswin.soa:soa-robot-api:1.0.0-SNAPSHOT")
        implementation project(":soa-user:soa-user-api")
        api project(":soa-red-envelope:soa-red-envelope-api")
        api project(":soa-happy-rain:soa-happy-rain-api")
        api project(":soa-happy-go:soa-happy-go-api")
        api project(":soa-happy-bomb:soa-happy-bomb-api")
        api project(":ws-red-envelope:ws-red-envelope-api")
        api project(":soa-wallet:soa-wallet-api")
        api project(":packet:packet-api")
        implementation("org.springframework.cloud:spring-cloud-starter-netflix-eureka-client")
    }

    test {
        useTestNG() {

        }
    }
}

我读过一些类似的问题,但仍然解决了我的问题。我想在不同的分支中使用不同的构建文件。我错过什么了吗?问题是什么?我应该如何解决


共 (0) 个答案