gpt4 book ai didi

gradle - 如何在 build.gradle 中嵌入 gradle 的共同值(value)

转载 作者:行者123 更新时间:2023-12-03 05:25:39 25 4
gpt4 key购买 nike

我在 common.build 中定义了一个公共(public)依赖项,如下所示(Gradle 6.0.1):

ext {
java = [
compileSdkVersion: 1.8,
minSdkVersion : 1.8,
targetSdkVersion : 1.8,
versionCode : 1.8,
]

version = [
mybatisGeneratorCoreVersion : '1.3.7',
itfswMybatisGeneratorPluginVersion: '1.3.8'
]

dependencies = [
mybatisGeneratorCore : "org.mybatis.generator:mybatis-generator-core:${version["mybatisGeneratorCoreVersion"]}",
]
}

并在根项目 build.gradle 中使用,如下所示:
subprojects {
apply from: "${rootProject.projectDir}/common.gradle"
dependencies {
implementation rootProject.ext.dependencies.mybatisGeneratorCore
}
}

并像这样构建项目:
./gradlew clean :soa-illidan-mini:soa-illidan-mini-service:build -x test

并给我这个错误:
~/Library/Mobile Documents/com~apple~CloudDocs/Document/source/dabai/microservice/soa-illidan-mini on  master! ⌚ 10:59:03
$ ./gradlew clean :soa-illidan-mini:soa-illidan-mini-service:build -x test

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/dolphin/Library/Mobile Documents/com~apple~CloudDocs/Document/source/dabai/microservice/build.gradle' line: 99

* What went wrong:
A problem occurred evaluating root project 'microservice'.
> Cannot get property 'dependencies' on extra properties extension as it does not exist

* 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 12s

我跟着网络教程,我应该怎么做才能解决这个问题?

最佳答案

将您的应用命令移动到 build.gradle 的根目录,如下所示:

apply from: "${rootProject.projectDir}/common.gradle"

只需将其放在项目配置的顶层即可。有用!

关于gradle - 如何在 build.gradle 中嵌入 gradle 的共同值(value),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61378711/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com