java - 构建文件不是 gradle 中的设置文件定义的构建的一部分
问题描述
今天我对我的项目做了一件新的事情,我添加了一个新的 gradle 构建文件分支,名为build-robot.gradle
(旧的名为build.gradle
)。当我使用此命令在 jenkins 的构建阶段构建项目时(使用不同的 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() {
}
}
}
我已经阅读了一些类似的问题,但仍然解决了我的问题。我想在不同的分支中使用不同的构建文件。我错过了什么吗?有什么问题,我应该怎么做才能解决它?
解决方案
推荐阅读
- javascript - 如何将两个 html 表单与一个谷歌表格链接?
- amazon-web-services - 未找到字段的值 - AppSync AWS
- python - 查找数据框中的最低时间值
- java - JAVA Hibernate 合并正在更新而不是合并
- python - 使用 python 在现有 SQL Server 表中附加来自 excel 的数据
- flutter - 哪些 Flutter 默认插件很重要?
- php - 如何向 Laravel Artisan 生成的代码添加更多内容?
- excel - 使用多个条件压缩嵌套的 if 语句
- macos - IOCreatePlugInInterfaceForService 失败 w/kIOReturnNoResources/0xe00002be
- mysql - 基于其他列从 1 列返回 2 个值的查询