mirror of
https://github.com/tadfisher/gradle2nix.git
synced 2026-01-11 23:40:37 -05:00
Move Gradle build logic to a setup hook
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -17,11 +17,10 @@ class DependencySetModelBuilder(
|
||||
override fun buildAll(
|
||||
modelName: String,
|
||||
project: Project,
|
||||
): DependencySet {
|
||||
return dependencyExtractor.buildDependencySet(
|
||||
): DependencySet =
|
||||
dependencyExtractor.buildDependencySet(
|
||||
cacheAccess,
|
||||
checksumService,
|
||||
fileStoreAndIndexProvider,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user