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

[pull] master from gradle:master #26

Merged
merged 25 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3fbdec3
Support AndroidStudio sync tests
6hundreds Dec 20, 2024
3b89e4d
Run `IsolatedProjectsAndroidProjectSyncTest` on MacOs only
6hundreds Dec 23, 2024
8752cc8
Minor fix for Javadoc
6hundreds Dec 24, 2024
7524be3
Use existing infrastructure for AGP latest version provisioning
6hundreds Dec 24, 2024
c533297
Mention parallel configuration in Isolated Projects doc
DSteve595 Jan 7, 2025
1cd47db
Change "as of" version to 8.11
DSteve595 Jan 7, 2025
57a5fa9
Merge branch 'master' into patch-1
lkasso Jan 9, 2025
9203b9e
Merge branch 'master' into patch-1
lkasso Jan 9, 2025
617d044
Annotate BuildTree-scoped services with scopes
alllex Jan 10, 2025
82af2d3
Update injected services
alllex Jan 10, 2025
3518c47
Avoid annotating services of a published build-cache-base library
alllex Jan 10, 2025
bc8201b
Make BuildTree service scope strict
alllex Jan 10, 2025
34bd938
Add scope to GradleEnterprisePluginServiceRefInternal service
alllex Jan 10, 2025
a4b9acd
Mention `gradle-ide-starter` in javadoc
6hundreds Jan 13, 2025
fb92944
Use data classes
alllex Jan 13, 2025
76619ec
Add javadocs
alllex Jan 13, 2025
0a1023c
Support AndroidStudio sync tests (#31852)
6hundreds Jan 13, 2025
7957b0f
Fix typo
alllex Jan 13, 2025
f1a7994
Adjust ConfigurationCacheAction classes naming to camelcase
alllex Jan 13, 2025
ee1825b
Add explanation for an exclusion from the verification
alllex Jan 13, 2025
bed5cb4
Annotate BuildTree-scope services (#31990)
alllex Jan 13, 2025
2c5423c
Polish CC action and fingerprint class hierarchy (#32003)
alllex Jan 13, 2025
01ec426
Merge branch 'master' into patch-1
lkasso Jan 14, 2025
1540af6
Fix COD doc link
DSteve595 Jan 14, 2025
dd8e432
Mention parallel configuration in Isolated Projects doc (#31949)
lkasso Jan 14, 2025
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 @@ -24,7 +24,7 @@ abstract class ExternalModulesExtension(isBundleGroovy4: Boolean) {
val groovyGroup = if (isBundleGroovy4) "org.apache.groovy" else "org.codehaus.groovy"

val configurationCacheReportVersion = "1.23"
val gradleIdeStarterVersion = "0.3"
val gradleIdeStarterVersion = "0.5"
val kotlinVersion = "2.0.21"

fun futureKotlin(module: String) = "org.jetbrains.kotlin:kotlin-$module:$kotlinVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ import org.gradle.util.Path

sealed class CheckedFingerprint {

// No fingerprint, which means no cache entry
object NotFound : CheckedFingerprint()
/**
* No fingerprint, which means no cache entry
*/
object NotFound : CheckedFingerprint() {
override fun toString(): String = "NotFound"
}

// The entry cannot be reused at all and should be recreated from scratch
class Invalid(
/**
* The entry cannot be reused at all and should be recreated from scratch
*/
data class Invalid(
val buildPath: Path,
val reason: StructuredMessage
) : CheckedFingerprint()
Expand All @@ -35,13 +41,15 @@ sealed class CheckedFingerprint {
* The entry can be reused. However, the state of some projects might be invalid and should be recreated.
*/
// TODO:isolated when keeping multiple entries per key, Gradle should look for the entry with the least number of invalid projects
class Valid(
data class Valid(
val entryId: String,
val invalidProjects: InvalidProjects? = null
) : CheckedFingerprint()

// The entry can be reused, however the values for certain projects cannot be reused and should be recreated
class InvalidProjects(
/**
* The entry can be reused, however the values for certain projects cannot be reused and should be recreated
*/
data class InvalidProjects(
/**
* Identity path of the first project for which an invalidation was detected.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,29 @@
package org.gradle.internal.cc.impl


/**
* A build execution strategy chosen by Configuration Cache
* that depends on the availability and state of existing cache entries
* that correspond to the build environment and build parameters of the current invocation.
*/
internal sealed class ConfigurationCacheAction {
class LOAD(val entryId: String) : ConfigurationCacheAction()
class UPDATE(val entryId: String, val invalidProjects: CheckedFingerprint.InvalidProjects) : ConfigurationCacheAction()
object STORE : ConfigurationCacheAction()

/**
* Configuration cache entry is fully loaded and reused.
*/
data class Load(val entryId: String) : ConfigurationCacheAction()

/**
* Configuration cache entry is loaded and partially reused.
* The entry will be stored again, incrementally updating parts of state.
*/
data class Update(val entryId: String, val invalidProjects: CheckedFingerprint.InvalidProjects) : ConfigurationCacheAction()

/**
* Configuration cache entry is invalid for the current invocation.
* The new entry will be stored by the end of the build.
*/
object Store : ConfigurationCacheAction() {
override fun toString(): String = "Store"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import org.gradle.api.internal.tasks.TaskExecutionAccessChecker
import org.gradle.api.internal.tasks.execution.TaskExecutionAccessListener
import org.gradle.execution.ExecutionAccessChecker
import org.gradle.execution.ExecutionAccessListener
import org.gradle.internal.build.BuildModelControllerServices
import org.gradle.internal.build.BuildToolingModelControllerFactory
import org.gradle.internal.buildoption.InternalOptions
import org.gradle.internal.buildtree.BuildModelParameters
import org.gradle.internal.buildtree.BuildTreeModelControllerServices
Expand Down Expand Up @@ -63,8 +65,8 @@ class ConfigurationCacheServices : AbstractGradleModuleServices() {
registration.run {
add(BuildNameProvider::class.java)
add(ConfigurationCacheKey::class.java)
add(DefaultBuildModelControllerServices::class.java)
add(DefaultBuildToolingModelControllerFactory::class.java)
add(BuildModelControllerServices::class.java, DefaultBuildModelControllerServices::class.java)
add(BuildToolingModelControllerFactory::class.java, DefaultBuildToolingModelControllerFactory::class.java)
add(DeprecatedFeaturesListener::class.java)
add(InputTrackingState::class.java)
add(InstrumentedExecutionAccessListener::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ import org.gradle.api.internal.artifacts.ivyservice.projectmodule.LocalComponent
import org.gradle.api.internal.configuration.DefaultBuildFeatures
import org.gradle.api.logging.LogLevel
import org.gradle.execution.selection.BuildTaskSelector
import org.gradle.initialization.EnvironmentChangeTracker
import org.gradle.initialization.StartParameterBuildOptions
import org.gradle.internal.build.BuildStateRegistry
import org.gradle.internal.buildoption.DefaultInternalOptions
import org.gradle.internal.buildoption.InternalFlag
import org.gradle.internal.buildtree.BuildActionModelRequirements
import org.gradle.internal.buildtree.BuildModelParameters
import org.gradle.internal.buildtree.BuildTreeLifecycleControllerFactory
import org.gradle.internal.buildtree.BuildTreeModelControllerServices
import org.gradle.internal.buildtree.BuildTreeModelSideEffectExecutor
import org.gradle.internal.buildtree.BuildTreeWorkGraphPreparer
import org.gradle.internal.buildtree.DefaultBuildTreeModelSideEffectExecutor
import org.gradle.internal.buildtree.DefaultBuildTreeWorkGraphPreparer
Expand All @@ -39,6 +42,7 @@ import org.gradle.internal.cc.base.logger
import org.gradle.internal.cc.base.services.ConfigurationCacheEnvironmentChangeTracker
import org.gradle.internal.cc.impl.fingerprint.ConfigurationCacheFingerprintController
import org.gradle.internal.cc.impl.initialization.ConfigurationCacheInjectedClasspathInstrumentationStrategy
import org.gradle.internal.cc.impl.initialization.ConfigurationCacheProblemsListener
import org.gradle.internal.cc.impl.initialization.ConfigurationCacheStartParameter
import org.gradle.internal.cc.impl.initialization.DefaultConfigurationCacheProblemsListener
import org.gradle.internal.cc.impl.initialization.InstrumentedExecutionAccessListenerRegistry
Expand All @@ -50,12 +54,14 @@ import org.gradle.internal.cc.impl.services.DefaultBuildModelParameters
import org.gradle.internal.cc.impl.services.DefaultDeferredRootBuildGradle
import org.gradle.internal.cc.impl.services.VintageEnvironmentChangeTracker
import org.gradle.internal.configuration.problems.DefaultProblemFactory
import org.gradle.internal.configuration.problems.ProblemFactory
import org.gradle.internal.scripts.ProjectScopedScriptResolution
import org.gradle.internal.serialize.codecs.core.jos.JavaSerializationEncodingLookup
import org.gradle.internal.service.Provides
import org.gradle.internal.service.ServiceRegistration
import org.gradle.internal.service.ServiceRegistrationProvider
import org.gradle.internal.snapshot.ValueSnapshotter
import org.gradle.plugin.use.resolve.service.internal.InjectedClasspathInstrumentationStrategy
import org.gradle.tooling.provider.model.internal.ToolingModelParameterCarrier
import org.gradle.util.internal.IncubationLogger

Expand Down Expand Up @@ -230,29 +236,29 @@ class DefaultBuildTreeModelControllerServices : BuildTreeModelControllerServices
registration.add(JavaSerializationEncodingLookup::class.java)

// This was originally only for the configuration cache, but now used for configuration cache and problems reporting
registration.add(DefaultProblemFactory::class.java)
registration.add(ProblemFactory::class.java, DefaultProblemFactory::class.java)

if (modelParameters.isConfigurationCache) {
registration.add(ConfigurationCacheBuildTreeLifecycleControllerFactory::class.java)
registration.add(BuildTreeLifecycleControllerFactory::class.java, ConfigurationCacheBuildTreeLifecycleControllerFactory::class.java)
registration.add(ConfigurationCacheStartParameter::class.java)
registration.add(ConfigurationCacheClassLoaderScopeRegistryListener::class.java)
registration.add(ConfigurationCacheInjectedClasspathInstrumentationStrategy::class.java)
registration.add(InjectedClasspathInstrumentationStrategy::class.java, ConfigurationCacheInjectedClasspathInstrumentationStrategy::class.java)
registration.add(ConfigurationCacheEnvironmentChangeTracker::class.java)
registration.add(DefaultConfigurationCacheProblemsListener::class.java)
registration.add(ConfigurationCacheProblemsListener::class.java, DefaultConfigurationCacheProblemsListener::class.java)
registration.add(ConfigurationCacheProblems::class.java)
registration.add(DefaultConfigurationCache::class.java)
registration.add(BuildTreeConfigurationCache::class.java, DefaultConfigurationCache::class.java)
registration.add(InstrumentedExecutionAccessListenerRegistry::class.java)
registration.add(ConfigurationCacheFingerprintController::class.java)
registration.addProvider(ConfigurationCacheBuildTreeProvider())
registration.add(ConfigurationCacheBuildTreeModelSideEffectExecutor::class.java)
registration.add(DefaultDeferredRootBuildGradle::class.java)
} else {
registration.add(VintageInjectedClasspathInstrumentationStrategy::class.java)
registration.add(VintageBuildTreeLifecycleControllerFactory::class.java)
registration.add(VintageEnvironmentChangeTracker::class.java)
registration.add(InjectedClasspathInstrumentationStrategy::class.java, VintageInjectedClasspathInstrumentationStrategy::class.java)
registration.add(BuildTreeLifecycleControllerFactory::class.java, VintageBuildTreeLifecycleControllerFactory::class.java)
registration.add(EnvironmentChangeTracker::class.java, VintageEnvironmentChangeTracker::class.java)
registration.add(ProjectScopedScriptResolution::class.java, ProjectScopedScriptResolution.NO_OP)
registration.addProvider(VintageBuildTreeProvider())
registration.add(DefaultBuildTreeModelSideEffectExecutor::class.java)
registration.add(BuildTreeModelSideEffectExecutor::class.java, DefaultBuildTreeModelSideEffectExecutor::class.java)
}
if (modelParameters.isIntermediateModelCache) {
registration.addProvider(ConfigurationCacheModelProvider())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ class DefaultConfigurationCache internal constructor(
get() = host.service()

override val isLoaded: Boolean
get() = cacheAction is ConfigurationCacheAction.LOAD
get() = cacheAction is ConfigurationCacheAction.Load

override fun initializeCacheEntry() {
val (cacheAction, cacheActionDescription) = determineCacheAction()
this.cacheAction = cacheAction
this.entryId = when (cacheAction) {
is ConfigurationCacheAction.LOAD -> cacheAction.entryId
is ConfigurationCacheAction.UPDATE -> cacheAction.entryId
ConfigurationCacheAction.STORE -> UUID.randomUUID().toString()
is ConfigurationCacheAction.Load -> cacheAction.entryId
is ConfigurationCacheAction.Update -> cacheAction.entryId
ConfigurationCacheAction.Store -> UUID.randomUUID().toString()
}
initializeCacheEntrySideEffects(cacheAction)
problems.action(cacheAction, cacheActionDescription)
Expand All @@ -198,20 +198,20 @@ class DefaultConfigurationCache internal constructor(
private
fun initializeCacheEntrySideEffects(cacheAction: ConfigurationCacheAction) {
when (cacheAction) {
is ConfigurationCacheAction.LOAD -> {
is ConfigurationCacheAction.Load -> {
val entryDetails = readEntryDetails()
val sideEffects = buildTreeModelSideEffects.restoreFromCacheEntry(entryDetails.sideEffects)
loadedSideEffects += sideEffects
}

is ConfigurationCacheAction.UPDATE -> {
is ConfigurationCacheAction.Update -> {
val invalidProjects = cacheAction.invalidProjects
val entryDetails = readEntryDetails()
intermediateModels.restoreFromCacheEntry(entryDetails.intermediateModels, invalidProjects)
projectMetadata.restoreFromCacheEntry(entryDetails.projectMetadata, invalidProjects)
}

ConfigurationCacheAction.STORE -> {}
ConfigurationCacheAction.Store -> {}
}
// TODO:isolated find a way to avoid this late binding
modelSideEffectExecutor.sideEffectStore = buildTreeModelSideEffects
Expand Down Expand Up @@ -304,7 +304,7 @@ class DefaultConfigurationCache internal constructor(
problems.projectStateStats(projectUsage.reused.size, projectUsage.updated.size)
cacheEntryRequiresCommit = false
// Can reuse the cache entry for the rest of this build invocation
cacheAction = ConfigurationCacheAction.LOAD(entryId)
cacheAction = ConfigurationCacheAction.Load(entryId)
}
try {
cacheFingerprintController.stop()
Expand Down Expand Up @@ -349,7 +349,7 @@ class DefaultConfigurationCache internal constructor(
startParameter.recreateCache -> {
val description = StructuredMessage.forText("Recreating configuration cache")
logBootstrapSummary(description)
ConfigurationCacheAction.STORE to description
ConfigurationCacheAction.Store to description
}

startParameter.isRefreshDependencies -> {
Expand All @@ -359,7 +359,7 @@ class DefaultConfigurationCache internal constructor(
"--refresh-dependencies"
)
logBootstrapSummary(description)
ConfigurationCacheAction.STORE to description
ConfigurationCacheAction.Store to description
}

startParameter.isWriteDependencyLocks -> {
Expand All @@ -369,7 +369,7 @@ class DefaultConfigurationCache internal constructor(
"--write-locks"
)
logBootstrapSummary(description)
ConfigurationCacheAction.STORE to description
ConfigurationCacheAction.Store to description
}

startParameter.isUpdateDependencyLocks -> {
Expand All @@ -379,7 +379,7 @@ class DefaultConfigurationCache internal constructor(
"--update-locks"
)
logBootstrapSummary(description)
ConfigurationCacheAction.STORE to description
ConfigurationCacheAction.Store to description
}

else -> {
Expand All @@ -391,7 +391,7 @@ class DefaultConfigurationCache internal constructor(
buildActionModelRequirements.configurationCacheKeyDisplayName.displayName
)
logBootstrapSummary(description)
ConfigurationCacheAction.STORE to description
ConfigurationCacheAction.Store to description
}

is CheckedFingerprint.Invalid -> {
Expand All @@ -401,15 +401,15 @@ class DefaultConfigurationCache internal constructor(
checkedFingerprint.reason.render()
)
logBootstrapSummary(description)
ConfigurationCacheAction.STORE to description
ConfigurationCacheAction.Store to description
}

is CheckedFingerprint.Valid -> {
when (val invalid = checkedFingerprint.invalidProjects) {
null -> {
val description = StructuredMessage.forText("Reusing configuration cache.")
logBootstrapSummary(description)
ConfigurationCacheAction.LOAD(checkedFingerprint.entryId) to description
ConfigurationCacheAction.Load(checkedFingerprint.entryId) to description
}

else -> {
Expand All @@ -419,7 +419,7 @@ class DefaultConfigurationCache internal constructor(
invalid.first.reason.render()
)
logBootstrapSummary(description)
ConfigurationCacheAction.UPDATE(checkedFingerprint.entryId, invalid) to description
ConfigurationCacheAction.Update(checkedFingerprint.entryId, invalid) to description
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ import org.gradle.internal.service.scopes.ServiceScope


@ServiceScope(Scope.BuildTree::class)
@ListenerService
interface ConfigurationCacheProblemsListener : ExecutionAccessListener, TaskExecutionAccessListener, BuildScopeListenerRegistrationListener, ExternalProcessStartedListener


@ListenerService
class DefaultConfigurationCacheProblemsListener internal constructor(
private val problems: ProblemsListener,
private val problemFactory: ProblemFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ import org.gradle.internal.cc.impl.InstrumentedExecutionAccessListener
import org.gradle.internal.classpath.InstrumentedExecutionAccess
import org.gradle.internal.concurrent.Stoppable
import org.gradle.internal.service.scopes.ListenerService
import org.gradle.internal.service.scopes.Scope
import org.gradle.internal.service.scopes.ServiceScope


@ServiceScope(Scope.BuildTree::class)
@ListenerService
internal
class InstrumentedExecutionAccessListenerRegistry(
Expand Down
Loading
Loading