[Gradle] Refactor ResolvedDependencyGraph to instantiate via secondary constructor
This commit is contained in:
+2
-2
@@ -561,7 +561,7 @@ constructor(
|
||||
val exportLibraries: FileCollection get() = exportLibrariesResolvedGraph?.files ?: objectFactory.fileCollection()
|
||||
|
||||
private val exportLibrariesResolvedGraph = if (binary is AbstractNativeLibrary) {
|
||||
ResolvedDependencyGraph.fromConfiguration(project.configurations.getByName(binary.exportConfigurationName))
|
||||
ResolvedDependencyGraph(project.configurations.getByName(binary.exportConfigurationName))
|
||||
} else {
|
||||
null
|
||||
}
|
||||
@@ -640,7 +640,7 @@ constructor(
|
||||
@get:Internal
|
||||
internal abstract val konanPropertiesService: Property<KonanPropertiesBuildService>
|
||||
|
||||
private val resolvedDependencyGraph = ResolvedDependencyGraph.fromConfiguration(
|
||||
private val resolvedDependencyGraph = ResolvedDependencyGraph(
|
||||
project.configurations.getByName(compilation.compileDependencyConfigurationName)
|
||||
)
|
||||
|
||||
|
||||
+8
-7
@@ -31,6 +31,14 @@ private constructor(
|
||||
private val resolvedComponentsRootProvider: Lazy<ResolvedComponentResult>,
|
||||
private val artifactCollection: ArtifactCollection
|
||||
) {
|
||||
constructor(configuration: Configuration) : this(
|
||||
// Calling resolutionResult doesn't actually trigger resolution. But accessing its root ResolvedComponentResult
|
||||
// via ResolutionResult::root does. ResolutionResult can't be serialised for Configuration Cache
|
||||
// but ResolvedComponentResult can. Wrapping it in `lazy` makes it resolve upon serialisation.
|
||||
resolvedComponentsRootProvider = configuration.incoming.resolutionResult.let { rr -> lazy { rr.root } },
|
||||
artifactCollection = configuration.incoming.artifacts // lazy ArtifactCollection
|
||||
)
|
||||
|
||||
val root get() = resolvedComponentsRootProvider.value
|
||||
val files: FileCollection get() = artifactCollection.artifactFiles
|
||||
val artifacts get() = artifactCollection.artifacts
|
||||
@@ -52,11 +60,4 @@ private constructor(
|
||||
val componentId = dependency.selected.id
|
||||
return artifactsByComponentId[componentId] ?: emptyList()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun fromConfiguration(configuration: Configuration) = ResolvedDependencyGraph(
|
||||
resolvedComponentsRootProvider = configuration.incoming.resolutionResult.let { rr -> lazy { rr.root } },
|
||||
artifactCollection = configuration.incoming.artifacts
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user