All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.autonomousapps.tasks.LocateDependenciesTask.kt Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package com.autonomousapps.tasks

import com.autonomousapps.TASK_GROUP_DEP
import com.autonomousapps.internal.ConfigurationsToDependenciesTransformer
import com.autonomousapps.internal.utils.getAndDelete
import com.autonomousapps.internal.utils.toJson
import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction

abstract class LocateDependenciesTask : DefaultTask() {

  init {
    group = TASK_GROUP_DEP
    description = "Produces a report of all dependencies and the configurations on which they are declared"

    // This task can never be up to date because we do not yet know a way to model having the
    // configurations themselves (not the files they resolve to!) as an input
    outputs.upToDateWhen { false }
  }

  @get:Optional
  @get:Input
  abstract val flavorName: Property

  @get:Input
  abstract val variantName: Property

  @get:OutputFile
  abstract val output: RegularFileProperty

  @TaskAction fun action() {
    val outputFile = output.getAndDelete()

    val locations = ConfigurationsToDependenciesTransformer(
      flavorName = flavorName.orNull,
      variantName = variantName.get(),
      project = project
    ).dependencyConfigurations()

    outputFile.writeText(locations.toJson())
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy