Slackbot
05/18/2022, 2:24 AMChris Lee
05/18/2022, 2:35 AMChris Lee
05/18/2022, 2:36 AMPaul Merlin
05/18/2022, 6:31 AMValueSource
and use it via ProviderFactory.of(...)
.
See https://docs.gradle.org/current/javadoc/org/gradle/api/provider/ValueSource.htmlGianfranco Monzon
05/18/2022, 6:00 PMinterface VpnParameters extends ValueSourceParameters {
Property<String> getServerUrl();
}
abstract class VpnConnectionSource implements ValueSource<Boolean, VpnParameters> {
@Override
Boolean obtain() {
String serverUrl = getParameters().serverUrl.get()
return hasServerConnection(serverUrl)
}
boolean hasServerConnection(String serverUrl) {
try (Socket socket = new Socket()) {
// Logic to check if we have a connection to our VPN
println "Found VPN connection for $serverUrl"
return true
} catch (Exception exception) {
println "VPN connection not found for $serverUrl (Reason: '${exception.message}')."
return false
}
}
}
String url = "<https://my.vpn.com>"
def vpnProvider = settings.providers.of(VpnConnectionSource.class) {
parameters {
serverUrl = url
}
}
println(vpnProvider.get().class)
boolean remoteCacheEnabled = vpnProvider.get()
println "Remote cache enabled: $remoteCacheEnabled"
buildCache {
remote(HttpBuildCache) {
enabled = remoteCacheEnabled
push = isCi
url = "$url/cache/"
}
}
However, when I run ./gradlew :app:assembleDebug
, I'm encountering this error:
Found VPN connection for <https://my.vpn.com>
class java.lang.Boolean
Remote cache enabled: true
FAILURE: Build failed with an exception.
* What went wrong:
Gradle could not start your build.
> Could not create service of type BuildCacheController using .createBuildCacheController().
> HTTP build cache has no URL configured
This error is the same as this one from https://github.com/gradle/gradle/issues/14874. Is this fixed in Gradle 7.5?Paul Merlin
05/18/2022, 6:06 PMChris Lee
05/18/2022, 6:06 PMHTTP build cache has no URL configured
would seem to indicate that the URL is not being correctly setPaul Merlin
05/18/2022, 6:07 PMHTTP build cache has no URL configured
looks weird to me given you have
url = "$url/cache/"
Are you sure this is a valid URL to a build cache node?Gianfranco Monzon
05/18/2022, 6:08 PMbuildCache {
remote(HttpBuildCache) {
enabled = true // Dont use the provider
push = isCi
url = "$url/cache/"
}
}
Found VPN connection for <https://my.vpn.com>
class java.lang.Boolean
Remote cache enabled: true
BUILD SUCCESSFUL in 54s
9280 actionable tasks: 129 executed, 336 from cache, 8815 up-to-date
Paul Merlin
05/18/2022, 6:11 PMGianfranco Monzon
05/18/2022, 6:11 PMprovider.get()
in buildCache
Paul Merlin
05/18/2022, 6:12 PMremote(HttpBuildCache) {}
lambda? It's just to rule out somethingPaul Merlin
05/18/2022, 6:13 PMbuildCache {
def providers = settings.providers
remote(HttpBuildCache) {
String url = "<https://my.vpn.com>"
def vpnProvider = providers.of(VpnConnectionSource.class) {
parameters {
serverUrl = url
}
}
println(vpnProvider.get().class)
boolean remoteCacheEnabled = vpnProvider.get()
println "Remote cache enabled: $remoteCacheEnabled"
enabled = remoteCacheEnabled
push = isCi
url = "$url/cache/"
}
}
Gianfranco Monzon
05/18/2022, 6:14 PMFound VPN connection for <https://my-vpn.com>
class java.lang.Boolean
Remote cache enabled: true
FAILURE: Build failed with an exception.
* What went wrong:
Gradle could not start your build.
> Could not create service of type BuildCacheController using .createBuildCacheController().
> HTTP build cache has no URL configured
Paul Merlin
05/18/2022, 6:15 PMPaul Merlin
05/18/2022, 6:15 PMPaul Merlin
05/18/2022, 6:16 PMGianfranco Monzon
05/18/2022, 6:17 PMPaul Merlin
05/18/2022, 6:17 PMPaul Merlin
05/18/2022, 6:17 PMGianfranco Monzon
05/18/2022, 6:20 PMGianfranco Monzon
05/18/2022, 7:33 PMbuildCache {
def providers = settings.providers
remote(HttpBuildCache) {
String url = "<https://my.vpn.com>"
def vpnProvider = providers.of(VpnConnectionSource.class) {
parameters {
serverUrl = url
}
}
println(vpnProvider.get().class)
boolean remoteCacheEnabled = vpnProvider.get()
println "Remote cache enabled: $remoteCacheEnabled"
enabled = remoteCacheEnabled
push = isCi
url = "$url/cache/"
}
I guess there must be a reasonable explanation for that behavior 😅Gianfranco Monzon
05/18/2022, 7:41 PM./gradlew :app:assembleDebug
and no VPN connection
Configuration cache is an incubating feature.
Configuration on demand is an incubating feature.
Calculating task graph as configuration cache cannot be reused because file 'tools/gradle-cache-node-config.gradle' has changed.
VPN connection not found for <https://my.vpn.com> (Reason: 'Connect timed out').
Remote cache enabled: false
BUILD SUCCESSFUL in 1m 4s
9280 actionable tasks: 9280 up-to-date
Configuration cache entry stored.
Second build with ./gradlew :app:assembleDebug
and no VPN connection:
Configuration cache is an incubating feature.
Configuration on demand is an incubating feature.
VPN connection not found for <https://my.vpn.com> (Reason: 'Connect timed out').
Reusing configuration cache.
BUILD SUCCESSFUL in 5s
9275 actionable tasks: 9275 up-to-date
Configuration cache entry reused.
Third build with ./gradlew :app:assembleDebug
and connected to the VPN; however, it fails with the same error than before
Configuration cache is an incubating feature.
Configuration on demand is an incubating feature.
Found VPN connection for <https://my.vpn.com>
Calculating task graph as configuration cache cannot be reused because a build logic input of type 'VpnConnectionSource' has changed.
Found VPN connection for <https://my.vpn.com>
Remote cache enabled: true
0 problems were found storing the configuration cache.
See the complete report at file:///Users/gianfranco.monzon/Documents/rappi/build/reports/configuration-cache/a4ykle2laqrcw1011gdh200a0/bkc4qjoucgl778cxj19sj43su/configuration-cache-report.html
FAILURE: Build failed with an exception.
* What went wrong:
Gradle could not start your build.
> Could not create service of type BuildCacheController using .createBuildCacheController().
> HTTP build cache has no URL configured
Chris Lee
05/18/2022, 7:41 PMGianfranco Monzon
05/18/2022, 7:45 PMgradle.properties
# Project-wide Gradle settings
org.gradle.daemon=true
org.gradle.parallel=true
# org.gradle.configureondemand=true
org.gradle.caching=true
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx8g -Xms4g -XX:+UseParallelGC
org.gradle.unsafe.configuration-cache=true
kotlin.incremental.usePreciseJavaTracking=true
kapt.include.compile.classpath=false
kapt.incremental.apt=true
android.useAndroidX=true
android.enableJetifier=true
android.databinding.incremental=true
android.experimental.cacheCompileLibResources=true
android.experimental.enableSourceSetPathsMap=true
rappi.localBuild=true
rappi.payMocksEnabled=true
Chris Lee
05/18/2022, 7:47 PMConfiguration on demand is an incubating feature.
Gianfranco Monzon
05/18/2022, 7:50 PMConfiguration cache is an incubating feature.
Calculating task graph as configuration cache cannot be reused because file 'gradle.properties' has changed.
VPN connection not found for <https://my.vpn.com> (Reason: 'Connect timed out').
Remote cache enabled: false
BUILD SUCCESSFUL in 34s
9280 actionable tasks: 3 from cache, 9277 up-to-date
Configuration cache entry stored.
Configuration cache is an incubating feature.
VPN connection not found for <https://my.vpn.com> (Reason: 'Connect timed out').
Reusing configuration cache.
BUILD SUCCESSFUL in 4s
9275 actionable tasks: 3 from cache, 9272 up-to-date
Configuration cache entry reused.
Configuration cache is an incubating feature.
Found VPN connection for <https://my.vpn.com>
Calculating task graph as configuration cache cannot be reused because a build logic input of type 'VpnConnectionSource' has changed.
Found VPN connection for <https://my.vpn.com>
Remote cache enabled: true
0 problems were found storing the configuration cache.
See the complete report at file:///Users/gianfranco.monzon/Documents/rappi/build/reports/configuration-cache/a4ykle2laqrcw1011gdh200a0/bkc4qjoucgl778cxj19sj43su/configuration-cache-report.html
FAILURE: Build failed with an exception.
* What went wrong:
Gradle could not start your build.
> Could not create service of type BuildCacheController using .createBuildCacheController().
> HTTP build cache has no URL configured
Gianfranco Monzon
05/18/2022, 8:09 PMGianfranco Monzon
05/18/2022, 8:11 PMfinal String nodeUrl = "<https://gradle-cache.dev.rappi.com>"
final def vpnProvider = settings.providers.of(VpnConnectionSource.class) {
parameters {
serverUrl = nodeUrl
}
}
final boolean remoteCacheEnabled = vpnProvider.get()
println "Remote cache enabled: $remoteCacheEnabled"
buildCache {
remote(HttpBuildCache) {
enabled = remoteCacheEnabled
push = isCi
url = "$nodeUrl/cache/"
}
}
Gianfranco Monzon
05/18/2022, 8:24 PM./gradlew :app:assembleDebug
Configuration cache is an incubating feature.
Configuration on demand is an incubating feature.
Calculating task graph as configuration cache cannot be reused because file 'tools/ge/gradle-cache-node-config.gradle' has changed.
VPN connection not found for <https://gradle-cache.dev.rappi.com> (Reason: 'Connect timed out').
Remote cache enabled: false
0 problems were found storing the configuration cache.
See the complete report at file:///Users/gianfranco.monzon/Documents/rappi/build/reports/configuration-cache/a4ykle2laqrcw1011gdh200a0/cxkjktsjf93db8q40gs6s3tn9/configuration-cache-report.html
BUILD SUCCESSFUL in 1m 1s
9280 actionable tasks: 9280 up-to-date
Configuration cache entry stored.
Second build without VPN
./gradlew :app:assembleDebug
Configuration cache is an incubating feature.
Configuration on demand is an incubating feature.
VPN connection not found for <https://gradle-cache.dev.rappi.com> (Reason: 'Connect timed out').
Reusing configuration cache.
BUILD SUCCESSFUL in 7s
9275 actionable tasks: 3 from cache, 9272 up-to-date
Configuration cache entry reused.
Third build with VPN
./gradlew :app:assembleDebug
Configuration cache is an incubating feature.
Configuration on demand is an incubating feature.
Found VPN connection for <https://gradle-cache.dev.rappi.com>
Calculating task graph as configuration cache cannot be reused because a build logic input of type 'VpnConnectionSource' has changed.
Found VPN connection for <https://gradle-cache.dev.rappi.com>
Remote cache enabled: true
0 problems were found storing the configuration cache.
See the complete report at file:///Users/gianfranco.monzon/Documents/rappi/build/reports/configuration-cache/a4ykle2laqrcw1011gdh200a0/6vueooe9ptz278qk8ui6l7my6/configuration-cache-report.html
BUILD SUCCESSFUL in 27s
9280 actionable tasks: 3 from cache, 9277 up-to-date
Configuration cache entry stored.
Fourth build with VPN (this one went really slow compared to the second build)
./gradlew :app:assembleDebug
Configuration cache is an incubating feature.
Configuration on demand is an incubating feature.
Found VPN connection for <https://gradle-cache.dev.rappi.com>
Reusing configuration cache.
BUILD SUCCESSFUL in 49s
9275 actionable tasks: 3 from cache, 9272 up-to-date
Configuration cache entry reused.
Fifth build without VPN to test if everything keeps working and I got this error
Starting a Gradle Daemon, 1 busy and 4 stopped Daemons could not be reused, use --status for details
Configuration cache is an incubating feature.
Configuration on demand is an incubating feature.
FAILURE: Build failed with an exception.
* What went wrong:
Gradle could not start your build.
> Cannot create service of type BuildTreeActionExecutor using method LauncherServices$ToolingBuildTreeScopeServices.createActionExecutor() as there is a problem with parameter #1 of type List<BuildActionRunner>.
> Cannot create service of type BuildModelActionRunner using BuildModelActionRunner constructor as there is a problem with parameter #1 of type PayloadSerializer.
> Cannot create service of type PayloadSerializer using method LauncherServices$ToolingGradleUserHomeScopeServices.createPayloadSerializer() as there is a problem with parameter #2 of type PayloadClassLoaderFactory.
> Cannot create service of type PayloadClassLoaderFactory using method LauncherServices$ToolingGradleUserHomeScopeServices.createClassLoaderFactory() as there is a problem with parameter #1 of type CachedClasspathTransformer.
> Cannot create service of type DefaultCachedClasspathTransformer using DefaultCachedClasspathTransformer constructor as there is a problem with parameter #6 of type FileSystemAccess.
> Cannot create service of type FileSystemAccess using method VirtualFileSystemServices$GradleUserHomeServices.createFileSystemAccess() as there is a problem with parameter #2 of type VirtualFileSystem.
> Cannot create service of type BuildLifecycleAwareVirtualFileSystem using method VirtualFileSystemServices$GradleUserHomeServices.createVirtualFileSystem() as there is a problem with parameter #6 of type GlobalCacheLocations.
> Cannot create service of type GlobalCacheLocations using method GradleUserHomeScopeServices.createGlobalCacheLocations() as there is a problem with parameter #1 of type List<GlobalCache>.
> Could not create service of type FileAccessTimeJournal using GradleUserHomeScopeServices.createFileAccessTimeJournal().
> Timeout waiting to lock journal cache (/Users/gianfranco.monzon/.gradle/caches/journal-1). It is currently in use by another Gradle instance.
Owner PID: 36627
Our PID: 37151
Owner Operation:
Our operation:
Lock file: /Users/gianfranco.monzon/.gradle/caches/journal-1/journal-1.lock
Sixth build without VPN to test if everything keeps working.
./gradlew :app:assembleDebug
Starting a Gradle Daemon, 5 stopped Daemons could not be reused, use --status for details
Configuration cache is an incubating feature.
Configuration on demand is an incubating feature.
VPN connection not found for <https://gradle-cache.dev.rappi.com> (Reason: 'Connect timed out').
Calculating task graph as configuration cache cannot be reused because a build logic input of type 'VpnConnectionSource' has changed.
VPN connection not found for <https://gradle-cache.dev.rappi.com> (Reason: 'Connect timed out').
Remote cache enabled: false
0 problems were found storing the configuration cache.
See the complete report at file:///Users/gianfranco.monzon/Documents/rappi/build/reports/configuration-cache/a4ykle2laqrcw1011gdh200a0/xj79okyqfag8uftok0ng1ih3/configuration-cache-report.html
BUILD SUCCESSFUL in 50s
9280 actionable tasks: 3 from cache, 9277 up-to-date
Configuration cache entry stored.
Build is successful, but it did not reuse the configuration cache from the first build when it should have been reused. Is this expected behavior?Paul Merlin
05/19/2022, 6:24 AMPaul Merlin
05/19/2022, 6:26 AMBuild is successful, but it did not reuse the configuration cache from the first build when it should have been reused. Is this expected behavior?Unfortunately yes, the cache key would be the same but the cache fingerprint invalidates it. That's an interesting case for which the current scheme is counter productive.