gradle - Gradle 没有考虑依赖锁文件
问题描述
我不确定我在使用 gradle 依赖锁时做错了什么,但是在构建它时
gradlew clean build
或执行gradlew test gradle 没有考虑存储在 {projectroot}/gradle/dependency-locks下的 compileClasspath.lockfile 。
我正在使用gradlew dependencies --write-locks来写锁。使用 gradle 版本 6.7.1 并使用 6.8 进行测试。
我的 build.gradle 文件:
buildscript {
repositories {
// ...
}
dependencies {
classpath 'com.commercehub.gradle.plugin:gradle-avro-plugin:0.21.+'
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.+'
}
}
plugins {
id 'java'
id 'pl.allegro.tech.build.axion-release' version '1.12.1'
}
group 'xxx'
sourceCompatibility = '11'
targetCompatibility = '11'
configurations {
compileClasspath {
resolutionStrategy.activateDependencyLocking()
}
intTestImplementation.extendsFrom implementation
}
repositories {
// ...
}
apply from: "${rootDir}/gradle/versioning.gradle"
project.version = scmVersion.version
apply plugin: 'com.commercehub.gradle.plugin.avro'
apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
implementation 'org.apache.avro:avro:1.10.+'
implementation 'org.slf4j:slf4j-log4j12:1.7.+'
implementation 'org.apache.kafka:kafka-streams:2.6.+'
implementation 'io.confluent:kafka-streams-avro-serde:6.0.+'
implementation 'com.fasterxml.jackson.core:jackson-core:2.11.+'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.11.+'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.11.+'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.+'
testImplementation 'org.apache.kafka:kafka-streams-test-utils:2.6.+'
testImplementation 'com.fasterxml.jackson.core:jackson-core:2.11.+'
testImplementation 'com.fasterxml.jackson.core:jackson-annotations:2.11.+'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.11.+'
testImplementation 'junit:junit:4.13.+'
}
test {
testLogging {
outputs.upToDateWhen { false }
showStandardStreams = true
exceptionFormat = 'full'
}
}
task run(type: JavaExec) {
main = 'Class'
classpath = sourceSets.main.runtimeClasspath
args = ['configuration/dev.properties']
}
jar {
manifest {
attributes(
'Class-Path': configurations.compileClasspath.collect { it.getName() }.join(' '),
'Main-Class': 'Class'
)
}
}
project.tasks.assemble.dependsOn project.tasks.shadowJar
shadowJar {
archiveBaseName = "app-standalone"
archiveClassifier = ''
}
我只意识到由于依赖项中的错误,锁定现在正在工作。锁定版本是 2.6.0,但 gradle 正在使用包含错误的 2.6.1。由于这个原因,测试失败了
不幸的是,我在 gradle 文档中找不到任何指向该问题的内容。非常感谢您的帮助!
解决方案
我的错。我没有锁定测试类路径。
它适用于以下更改:
configurations {
intTestImplementation.extendsFrom implementation
}
dependencyLocking {
lockAllConfigurations()
}
如果有更好的方法我仍然感兴趣;)
推荐阅读
- java - Spring Boot 找不到 Thymeleaf(消息)属性文件
- html - 具有列环绕和不同高度的引导垂直对齐
- powershell - 使用嵌套模块加载 PowerShell 模块会出现错误
- javascript - jQuery - 检测元素是否在视口中
- php - 我的验证器功能有什么问题?
- .net - 如何处理 EndSave 事件(AutoCAD .net vb)?
- javascript - 修改 Web Speech API 的问题?
- android - Google Pixel 中的指纹扫描错误
- ibm-midrange - 如何知道哪些成员嵌入了 SQL
- c - 如何在c中用'%30'替换字符串中的空格