Skip to content

Commit

Permalink
Add dry-run mode to dependency rake and don't run on android test pro…
Browse files Browse the repository at this point in the history
…jects (#458)

<!--
  ⬆ Put your description above this! ⬆

  Please be descriptive and detailed.
  
Please read our [Contributing
Guidelines](https://github.com/tinyspeck/slack-gradle-plugin/blob/main/.github/CONTRIBUTING.md)
and [Code of Conduct](https://slackhq.github.io/code-of-conduct).

Don't worry about deleting this, it's not visible in the PR!
-->
  • Loading branch information
ZacSweers authored Jul 12, 2023
1 parent cdfa42c commit 64b2a3c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.UntrackedTask
import slack.gradle.convertProjectPathToAccessor
import slack.gradle.property
import slack.gradle.util.mapToBoolean

private const val IGNORE_COMMENT = "// dependency-rake=ignore"

Expand Down Expand Up @@ -98,6 +100,14 @@ constructor(objects: ObjectFactory, providers: ProviderFactory) : AbstractPostPr
)
)

@get:Input
val dryRun: Property<Boolean> =
objects
.property<Boolean>()
.convention(
providers.gradleProperty("slack.dependencyrake.dryRun").mapToBoolean().orElse(false)
)

@get:Input abstract val noApi: Property<Boolean>

@get:OutputFile abstract val missingIdentifiersFile: RegularFileProperty
Expand Down Expand Up @@ -322,7 +332,20 @@ constructor(objects: ObjectFactory, providers: ProviderFactory) : AbstractPostPr
}
}
}
buildFile.writeText(newLines.cleanLineFormatting().joinToString("\n"))

val fileToWrite =
if (!dryRun.get()) {
buildFile
} else {
buildFile.parentFile.resolve("new-build.gradle.kts").apply {
if (exists()) {
delete()
}
createNewFile()
}
}

fileToWrite.writeText(newLines.cleanLineFormatting().joinToString("\n"))
}

/** Remaps a given [Coordinates] to a known toml lib reference or error if [error] is true. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ internal class StandardProjectConfigurations(
if (buildFile.exists()) {
// Configure rake
plugins.withId("com.autonomousapps.dependency-analysis") {
if (project.pluginManager.hasPlugin("com.android.test")) {
// Not supported yet in DAGP
// https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin/issues/797
return@withId
}
val isNoApi = slackProperties.rakeNoApi
val catalogNames =
extensions.findByType<VersionCatalogsExtension>()?.catalogNames ?: return@withId
Expand Down

0 comments on commit 64b2a3c

Please sign in to comment.