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

qlzsbp2j  于 2021-07-08  发布在  Java
关注(0)|答案(0)|浏览(874)

今天我对我的项目做了一件新的事情,我添加了gradle构建文件的一个新分支,名为 build-robot.gradle (老一个叫 build.gradle ). 当我在jenkins的build stage(使用不同的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() {

        }
    }
}

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

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题