Skip to content

Commit 0fed623

Browse files
committed
Deprecate junitJupiter() and junitParams() for more declarative handlers
1 parent 8863ca3 commit 0fed623

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

android-junit5/src/main/groovy/de/mannodermaus/gradle/plugins/android_junit5/AndroidJUnitPlatformPlugin.groovy

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ class AndroidJUnitPlatformPlugin implements Plugin<Project> {
2222

2323
static final String EXTENSION_NAME = "junitPlatform"
2424

25+
private static String dependencyDeprecationWarning(oldName, newName) {
26+
return "AGPBI: {" +
27+
'"kind":"warning",' +
28+
'"text":' + "\"$LOG_TAG The $oldName() dependency handler is deprecated " +
29+
"and will be removed in a future release. Use $newName() instead!\"," +
30+
'"sources":[{},{}]' +
31+
'}'
32+
}
33+
34+
private static final String JUNITJUPITER_DEPENDENCY_WARNING = dependencyDeprecationWarning("junitJupiter", "junitPlatform")
35+
private static final String JUNITPARAMS_DEPENDENCY_WARNING = dependencyDeprecationWarning("junitParams", "junitJupiterParams")
36+
2537
/**
2638
* This method doesn't call through to super.apply().
2739
* This is intentional, and prevents clashing between our Android-specific extension
@@ -66,8 +78,8 @@ class AndroidJUnitPlatformPlugin implements Plugin<Project> {
6678
deps.add(project.dependencies.create("org.junit.vintage:junit-vintage-engine:${vintageVersion}"))
6779
}
6880

69-
// Add a junitJupiter() dependency handler
70-
project.dependencies.ext.junitJupiter = {
81+
// Configure dependency handlers
82+
project.dependencies.ext.junitPlatform = {
7183
def jupiterVersion = junitExtension.jupiterVersion
7284
def platformVersion = junitExtension.platformVersion
7385
def vintageVersion = junitExtension.vintageVersion
@@ -86,13 +98,23 @@ class AndroidJUnitPlatformPlugin implements Plugin<Project> {
8698
]
8799
}
88100

89-
// Add a junitParams() dependency handler
90-
project.dependencies.ext.junitParams = {
101+
project.dependencies.ext.junitJupiterParams = {
91102
def jupiterVersion = junitExtension.jupiterVersion
92103

93104
return project.dependencies.create("org.junit.jupiter:junit-jupiter-params:${jupiterVersion}")
94105
}
95106

107+
// Add deprecated dependency handlers
108+
project.dependencies.ext.junitJupiter = {
109+
project.logger.warn(JUNITJUPITER_DEPENDENCY_WARNING)
110+
return project.dependencies.ext.junitPlatform
111+
}
112+
113+
project.dependencies.ext.junitParams = {
114+
project.logger.warn(JUNITPARAMS_DEPENDENCY_WARNING)
115+
return project.dependencies.ext.junitJupiterParams
116+
}
117+
96118
project.afterEvaluate {
97119
configure(project)
98120
}

0 commit comments

Comments
 (0)