Skip to content

Instantly share code, notes, and snippets.

View autonomousapps's full-sized avatar

Tony Robalik autonomousapps

View GitHub Profile
@autonomousapps
autonomousapps / ResolveDependenciesPlugin.kt
Created March 16, 2022 20:13
Plugin for resolving dependencies in a task action, to help with pre-populating a docker image
class ResolveDependenciesPlugin : Plugin<Project> {
override fun apply(target: Project): Unit = target.run {
pluginManager.withPlugin("java") {
registerTask(theJars = artifactFilesProvider("compileClasspath", "jar"))
}
pluginManager.withPlugin("com.android.base") {
// This lets us call `./gradlew resolveDependencies` and have it Just Work.
val lifecycleTask = tasks.register(RESOLVE_DEPENDENCIES_TASK_NAME)
@autonomousapps
autonomousapps / PluginTest.kt
Created November 16, 2023 18:43
Example usage of gradle-testkit-support
/**
* An example usage of https://github.com/autonomousapps/dependency-analysis-gradle-plugin/tree/main/testkit.
* This uses JUnit5 as the test framework. The test is paramaterized as well. The custom task `printVersions`,
* in the test fixture, unzips the jar and prints the contents of a resource file in that jar. The resource file
* is generated by "my-plugin", which is an internal plugin that bundles the runtime classpath artifact names
* (group:artifact:version) into the final jar built by the application.
*/
internal class PluginTest {
private companion object {