我正在研究Java中的遗留API,Collection Framework
并且我学到了诸如Vector
并且HashTable
已经被ArrayList
和取代的类HashMap
.
但是,它们仍然不被弃用,并且在本质上被视为遗留,弃用适用于被取代且应该避免的软件功能,因此,我不确定什么时候API被认为是遗留的以及何时被弃用.
在成功运行JUnit 4测试后,我正在尝试将JUnit 5与Gradle一起使用.
预期的结果: JUnit 4测试在输出中给出了一个很好的'传递',并且输入了一个html报告build/reports/tests
.
实际结果: JUnit 5测试如下所示不输出任何内容(...) build succesful
,虽然我知道测试实际上没有运行,因为没有传递/跳过/失败的测试日志输出,并且fail
在测试中放置一个使构建成功.
在很多我认为主要是不相关的输出之间运行gradle test --info
收益率Skipping task ':testClasses' as it has no actions.
.令人惊讶的是,它也说Executing task ':test'
和Generating HTML test report... Finished generating test html results
xml中的类似build/test-results/test
,而xml没有生成,html显示没有测试运行且没有错误,测试确实没有运行.
我认为非常有趣的是gradle test --debug
收益率
[TestEventLogger] Gradle Test Run :test STARTED
[org.gradle.api.internal.tasks.testing.junit.JUnitDetector] test-class-
scan : failed to scan parent class java/lang/Object, could not find the class file
[TestEventLogger]
[TestEventLogger] Gradle Test Run :test …
Run Code Online (Sandbox Code Playgroud) 我试图了解在 Gradle、Kotlin DSL 中应用插件的所有方法。 这个问题回答了我的部分问题,但不是全部(我猜方法是在六年后添加的)。
我在我的一份build.gradle.kts
文件中看到过这种确切的情况。
plugins{
`kotlin-dsl`
kotlin("jvm") version "1.6.10"
id("com.foo.bar.someplugin") version 1.2.3
}
apply("foo2.bar2.anotherplugin")
Run Code Online (Sandbox Code Playgroud)
哇,这是应用插件的四种不同方式,我根本不明白它们之间的关系。从另一个答案中,我知道这apply(...)
是遗留方式,最终将被弃用,但是其他三个呢?
此外,我很困惑为什么`kotlin-dsl`
甚至不需要版本。这是什么巫术?
最后,为了保持一致性,我想标准化插件块(让我们忽略它,apply(...)
因为它是遗留功能),以便一切都使用id(...)
. 如何转换另外两个?
我目前正在更新我的项目,作为步骤之一,我正在更改 gradle 文件以使用该plugins { id 'xxx' }
方式而不是旧apply plugin 'xxx'
方法。我能够将大部分导入迁移到新格式,但是我无法添加一些插件,因为我无法找到它们的 gradle 插件 ID。
例如,这是我的旧 gradle 文件:
设置.gradle 文件
include ':app'
Run Code Online (Sandbox Code Playgroud)
项目的build.gradle文件
buildscript {
repositories {
google()
mavenCentral()
(...)
}
dependencies {
(...)
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.0'
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5'
}
}
(...)
Run Code Online (Sandbox Code Playgroud)
模块的 build.gradle 文件
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
(...)
Run Code Online (Sandbox Code Playgroud)
以下是部分修改的新 gradle 文件:
设置.gradle 文件
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = …
Run Code Online (Sandbox Code Playgroud) build.gradle ×2
gradle ×2
android ×1
collections ×1
java ×1
junit ×1
junit5 ×1
kotlin ×1
terminology ×1