-
Notifications
You must be signed in to change notification settings - Fork 5k
Share build cache configuration instead of build cache service #4231
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ import org.gradle.integtests.fixtures.AbstractIntegrationSpec | |
import org.gradle.integtests.fixtures.BuildOperationsFixture | ||
import org.gradle.integtests.fixtures.TestBuildCache | ||
import org.gradle.internal.operations.trace.BuildOperationTrace | ||
import spock.lang.Issue | ||
/** | ||
* Tests build cache configuration within composite builds and buildSrc. | ||
*/ | ||
|
@@ -29,7 +30,9 @@ class BuildCacheCompositeConfigurationIntegrationTest extends AbstractIntegratio | |
def operations = new BuildOperationsFixture(executer, testDirectoryProvider) | ||
|
||
def setup() { | ||
executer.withBuildCacheEnabled() | ||
executer.beforeExecute { | ||
withBuildCacheEnabled() | ||
} | ||
} | ||
|
||
def "can configure with settings.gradle"() { | ||
|
@@ -96,7 +99,7 @@ class BuildCacheCompositeConfigurationIntegrationTest extends AbstractIntegratio | |
|
||
and: | ||
def finalizeOps = operations.all(FinalizeBuildCacheConfigurationBuildOperationType) | ||
finalizeOps.size() == 2 | ||
finalizeOps.size() == 5 | ||
def pathToCacheDirMap = finalizeOps.collectEntries { | ||
[ | ||
it.details.buildPath, | ||
|
@@ -106,10 +109,55 @@ class BuildCacheCompositeConfigurationIntegrationTest extends AbstractIntegratio | |
|
||
pathToCacheDirMap == [ | ||
":": mainCache.cacheDir, | ||
":i1": mainCache.cacheDir, | ||
":i1:buildSrc": mainCache.cacheDir, | ||
":i2": mainCache.cacheDir, | ||
":buildSrc": buildSrcCache.cacheDir | ||
] | ||
} | ||
|
||
@Issue("https://github.com/gradle/gradle/issues/4216") | ||
def "build cache service is closed only after all included builds are finished"() { | ||
def localCache = new TestBuildCache(file("local-cache")) | ||
|
||
buildTestFixture.withBuildInSubDir() | ||
['i1', 'i2'].each { | ||
multiProjectBuild(it, ['first', 'second']) { | ||
buildFile << """ | ||
gradle.startParameter.setTaskNames(['build']) | ||
println gradle | ||
allprojects { | ||
apply plugin: 'java-library' | ||
} | ||
""" | ||
} | ||
} | ||
|
||
settingsFile << localCache.localCacheConfiguration() << """ | ||
includeBuild "i1" | ||
includeBuild "i2" | ||
""" | ||
buildFile << """ | ||
apply plugin: 'java' | ||
println gradle | ||
gradle.startParameter.setTaskNames(['build']) | ||
processResources { | ||
dependsOn gradle.includedBuild('i1').task(':processResources') | ||
dependsOn gradle.includedBuild('i2').task(':processResources') | ||
} | ||
""" | ||
|
||
expect: | ||
succeeds '--parallel' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you don't need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, @adammurdoch. Removed. |
||
|
||
when: | ||
['i1', 'i2'].each { | ||
file("$it/src/test/java/DummyTest.java") << "public class DummyTest {}" | ||
} | ||
then: | ||
succeeds '--parallel' | ||
} | ||
|
||
private static String customTaskCode(String val = "foo") { | ||
""" | ||
@CacheableTask | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2017 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.gradle.caching.internal.controller; | ||
|
||
import org.gradle.caching.configuration.internal.BuildCacheConfigurationInternal; | ||
|
||
public class RootBuildCacheConfigurationRef { | ||
|
||
private BuildCacheConfigurationInternal buildCacheConfiguration; | ||
|
||
public void set(BuildCacheConfigurationInternal buildCacheConfiguration) { | ||
// This instance ends up in build/gradle scoped services for nesteds | ||
// We don't want to invoke close at that time. | ||
// Instead, close it at the root. | ||
this.buildCacheConfiguration = buildCacheConfiguration; | ||
} | ||
|
||
public BuildCacheConfigurationInternal getForNonRootBuild() { | ||
if (!isSet()) { | ||
throw new IllegalStateException("Root build cache configuration not yet assigned"); | ||
} | ||
|
||
return buildCacheConfiguration; | ||
} | ||
|
||
public boolean isSet() { | ||
return buildCacheConfiguration != null; | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a break for build scans.
We either need to roll this back (e.g. don't fire this event for non root builds), or we have to update build scans to ignore these events.