Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate config cache support #1048

Merged
merged 3 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package com.mikepenz.aboutlibraries.plugin

import com.mikepenz.aboutlibraries.plugin.mapping.SpdxLicense
import org.gradle.api.file.Directory
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.*
import org.gradle.util.GradleVersion
import org.slf4j.LoggerFactory
import java.io.File
Expand All @@ -15,19 +13,24 @@ import java.nio.file.StandardCopyOption

abstract class AboutLibrariesExportComplianceTask : BaseAboutLibrariesTask() {

@get:InputDirectory
abstract val projectDirectory: DirectoryProperty

@Input
@Optional
val exportPath: Provider<Directory> = project.providers.gradleProperty("aboutLibraries.exportPath")
.map { path -> project.layout.projectDirectory.dir(path) }
.map { path -> projectDirectory.get().dir(path) }
.orElse(project.providers.gradleProperty("exportPath").map { path ->
projectDirectory.get().dir(path)
})
.orElse(
project.providers.gradleProperty("exportPath").map { path -> project.layout.projectDirectory.dir(path) }
).orElse(
if (GradleVersion.current() < GradleVersion.version("8.8")) {
project.isolated.rootProject.projectDirectory.dir(".")
} else {
LOGGER.info("Fallback to non project isolated safe API for root directory.")
// noinspection GradleProjectIsolation
project.rootProject.layout.projectDirectory.dir(".")
} else {
@Suppress("UnstableApiUsage")
project.isolated.rootProject.projectDirectory.dir(".")
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ class AboutLibrariesPlugin : Plugin<Project> {
it.variant = project.providers.gradleProperty("aboutLibraries.exportVariant")
.orElse(project.providers.gradleProperty("exportVariant"))

val projectDirectory = project.layout.projectDirectory
val buildDirectory = project.layout.buildDirectory

val exportPath: Provider<Directory> = project.providers.gradleProperty("aboutLibraries.exportPath")
.map { path -> project.layout.projectDirectory.dir(path) }
.map { path -> projectDirectory.dir(path) }
.orElse(
project.providers.gradleProperty("exportPath")
.map { path -> project.layout.projectDirectory.dir(path) }
project.providers.gradleProperty("exportPath").map { path -> projectDirectory.dir(path) }
).orElse(
project.layout.buildDirectory.dir("generated/aboutLibraries/")
buildDirectory.dir("generated/aboutLibraries/")
)
it.resultDirectory.set(exportPath)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.mikepenz.aboutlibraries.plugin
import org.gradle.api.Project
import org.gradle.api.tasks.TaskProvider
import org.slf4j.LoggerFactory
import java.util.Locale
import java.util.*

/**
* Android specific extension for the [AboutLibrariesPlugin]
Expand Down Expand Up @@ -91,10 +91,11 @@ object AboutLibrariesPluginAndroidExtension {
"exportComplianceLibraries${variant.name.capitalize(Locale.ENGLISH)}",
AboutLibrariesExportComplianceTask::class.java
) {
it.description =
"Writes all libraries with their source and their license in CSV format to the configured directory"
it.description = "Writes all libraries with their source and their license in CSV format to the configured directory"
it.group = "Help"
it.variant = project.provider { variant.name }
it.projectDirectory.set(project.layout.projectDirectory)

it.dependsOn(collectTask)
}
}
Expand Down
Loading