@@ -30,7 +30,7 @@ fun Project.configureTestResources() {
3030
3131 " KOTLIN_VERSION" to libs.versions.kotlin,
3232 " JUNIT_JUPITER_VERSION" to libs.versions.junitJupiter,
33- " JUNIT5_ANDROID_LIBS_VERSION" to Artifacts .Instrumentation .latestStableVersion,
33+ " JUNIT5_ANDROID_LIBS_VERSION" to Artifacts .Instrumentation .Core . latestStableVersion,
3434
3535 // Collect all supported AGP versions into a single string.
3636 // This string is delimited with semicolons, and each of the separated values itself is a 3-tuple.
@@ -134,6 +134,43 @@ fun Project.configureTestResources() {
134134 }
135135}
136136
137+ fun findInstrumentationVersion (
138+ pluginVersion : String = Artifacts .Plugin .currentVersion,
139+ currentInstrumentationVersion : String = Artifacts .Instrumentation .Core .currentVersion,
140+ stableInstrumentationVersion : String = Artifacts .Instrumentation .Core .latestStableVersion
141+ ): String {
142+ return when {
143+ pluginVersion.endsWith(" -SNAPSHOT" ) -> currentInstrumentationVersion
144+ currentInstrumentationVersion.endsWith(" -SNAPSHOT" ) -> stableInstrumentationVersion
145+ else -> currentInstrumentationVersion
146+ }
147+ }
148+
149+ fun Copy.configureCreateVersionClassTask (
150+ instrumentationVersion : String = findInstrumentationVersion(),
151+ fromPath : String = "src/main/templates/Libraries .kt",
152+ intoPath : String = "build/generated/sources/plugin/de/mannodermaus",
153+ ) {
154+ from(fromPath)
155+ into(intoPath)
156+ filter(
157+ mapOf (
158+ " tokens" to mapOf (
159+ " INSTRUMENTATION_GROUP" to Artifacts .Instrumentation .groupId,
160+ " INSTRUMENTATION_COMPOSE" to Artifacts .Instrumentation .Compose .artifactId,
161+ " INSTRUMENTATION_CORE" to Artifacts .Instrumentation .Core .artifactId,
162+ " INSTRUMENTATION_EXTENSIONS" to Artifacts .Instrumentation .Extensions .artifactId,
163+ " INSTRUMENTATION_RUNNER" to Artifacts .Instrumentation .Runner .artifactId,
164+
165+ // Find an appropriate version of the instrumentation library,
166+ // depending on the version of how the plugin is configured
167+ " INSTRUMENTATION_VERSION" to instrumentationVersion,
168+ )
169+ ), ReplaceTokens ::class .java
170+ )
171+ outputs.upToDateWhen { false }
172+ }
173+
137174/* *
138175 * Helper Task class for generating an up-to-date version of the project's README.md.
139176 * Using a template file, the plugin's version constants & other dependency versions
0 commit comments