Move Gradle build logic to a setup hook

This commit is contained in:
Tad Fisher
2024-06-13 15:21:58 -07:00
parent a4ef499401
commit b32bf21a6c
26 changed files with 768 additions and 470 deletions

View File

@@ -116,22 +116,27 @@ private fun cachedComponentId(file: File): DependencyCoordinates? {
val parts = file.invariantSeparatorsPath.split('/')
if (parts.size < 6) return null
if (parts[parts.size - 6] != "files-2.1") return null
return parts.dropLast(2).takeLast(3).joinToString(":").let(DefaultDependencyCoordinates::parse)
return parts
.dropLast(2)
.takeLast(3)
.joinToString(":")
.let(DefaultDependencyCoordinates::parse)
}
@OptIn(ExperimentalSerializationApi::class)
private fun parseFileMappings(file: File): Map<String, String>? =
try {
Json.decodeFromStream<JsonObject>(file.inputStream())
.jsonObject["variants"]?.jsonArray
Json
.decodeFromStream<JsonObject>(file.inputStream())
.jsonObject["variants"]
?.jsonArray
?.flatMap { it.jsonObject["files"]?.jsonArray ?: emptyList() }
?.map { it.jsonObject }
?.mapNotNull {
val name = it["name"]?.jsonPrimitive?.content ?: return@mapNotNull null
val url = it["url"]?.jsonPrimitive?.content ?: return@mapNotNull null
if (name != url) name to url else null
}
?.toMap()
}?.toMap()
?.takeUnless { it.isEmpty() }
} catch (e: Throwable) {
null

View File

@@ -17,11 +17,10 @@ class DependencySetModelBuilder(
override fun buildAll(
modelName: String,
project: Project,
): DependencySet {
return dependencyExtractor.buildDependencySet(
): DependencySet =
dependencyExtractor.buildDependencySet(
cacheAccess,
checksumService,
fileStoreAndIndexProvider,
)
}
}

View File

@@ -38,14 +38,15 @@ abstract class AbstractResolveAllArtifactsApplier : ResolveAllArtifactsApplier {
abstract class ResolveProjectDependenciesTask : DefaultTask() {
@Internal
protected fun getReportableConfigurations(): List<Configuration> {
return project.configurations.filter { (it as? DeprecatableConfiguration)?.canSafelyBeResolved() ?: true }
}
protected fun getReportableConfigurations(): List<Configuration> =
project.configurations.filter {
(it as? DeprecatableConfiguration)?.canSafelyBeResolved() ?: true
}
protected fun Configuration.artifactFiles(): FileCollection {
return incoming.artifactView { viewConfiguration ->
viewConfiguration.isLenient = true
viewConfiguration.componentFilter { it is ModuleComponentIdentifier }
}.files
}
protected fun Configuration.artifactFiles(): FileCollection =
incoming
.artifactView { viewConfiguration ->
viewConfiguration.isLenient = true
viewConfiguration.componentFilter { it is ModuleComponentIdentifier }
}.files
}