Skip to content

Commit

Permalink
Merge pull request #980 from mikepenz/fix/collectortask_module_cache
Browse files Browse the repository at this point in the history
Fix CollectorTask output to be dependent on project name [Plugin]
  • Loading branch information
mikepenz committed May 1, 2024
2 parents 1fc1813 + e473836 commit 32daecd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ package com.mikepenz.aboutlibraries.plugin
import com.mikepenz.aboutlibraries.plugin.model.CollectedContainer
import com.mikepenz.aboutlibraries.plugin.util.DependencyCollector
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.*
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import org.slf4j.LoggerFactory
import java.io.File

@CacheableTask
Expand All @@ -12,6 +17,9 @@ abstract class AboutLibrariesCollectorTask : DefaultTask() {
@Internal
protected val extension = project.extensions.getByName("aboutLibraries") as AboutLibrariesExtension

@Input
val projectName = project.name

@Input
val includePlatform = extension.includePlatform

Expand All @@ -37,9 +45,14 @@ abstract class AboutLibrariesCollectorTask : DefaultTask() {

@TaskAction
fun action() {
LOGGER.info("Collecting for: $projectName")
if (!::collectedDependencies.isInitialized) {
configure()
}
dependencyCache.writeText(groovy.json.JsonOutput.toJson(collectedDependencies))
}

private companion object {
private val LOGGER = LoggerFactory.getLogger(AboutLibrariesCollectorTask::class.java)!!
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ class AboutLibrariesPlugin : Plugin<Project> {

private val Project.experimentalCache: Boolean
get() = hasProperty("org.gradle.unsafe.configuration-cache") &&
property("org.gradle.unsafe.configuration-cache") == "true" ||
hasProperty("org.gradle.configuration-cache") &&
property("org.gradle.configuration-cache") == "true"
property("org.gradle.unsafe.configuration-cache") == "true" ||
hasProperty("org.gradle.configuration-cache") &&
property("org.gradle.configuration-cache") == "true"


companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import java.io.OutputStreamWriter
import java.net.URL

internal class GitHubApi(
private val gitHubToken: String? = null
private val gitHubToken: String? = null,
) : IApi {
private var rateLimit: Int = 0

Expand All @@ -36,7 +36,7 @@ internal class GitHubApi(
}
limit
} catch (t: Throwable) {
LOGGER.error("Could not retrieve `rate_limit`. Please check if the token is provided.")
LOGGER.error("Could not retrieve `rate_limit`. Please check if the token is provided. (${t.message})")
0
}
}
Expand Down

0 comments on commit 32daecd

Please sign in to comment.