diffplug / goomph

IDE as build artifact
Apache License 2.0
130 stars 30 forks source link

Configuration cache issue with use of `uname -a` on macOS #211

Closed msridhar closed 9 months ago

msridhar commented 1 year ago

I see a configuration cache problem in particular circumstances when using this plugin on macOS. Here is my version info:

------------------------------------------------------------
Gradle 8.3
------------------------------------------------------------

Build time:   2023-08-17 07:06:47 UTC
Revision:     8afbf24b469158b714b36e84c6f4d4976c86fcd5

Kotlin:       1.9.0
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          17.0.8 (Azul Systems, Inc. 17.0.8+7-LTS)
OS:           Mac OS X 13.5 aarch64

I'm using version 3.42.2 of the plugin. To reproduce, clone https://github.com/wala/WALA, and then run ./gradlew clean compileJava compileTestJava --no-build-cache --no-daemon. I get the following error:

* What went wrong:
Configuration cache problems found in this build.

1 problem was found storing the configuration cache.
- Plugin 'com.diffplug.configuration-cache-for-platform-specific-build': external process started 'uname -a'
  See https://docs.gradle.org/8.3/userguide/configuration_cache.html#config_cache:requirements:external_processes

See the complete report at file:///Users/msridhar/git-repos/WALA/build/reports/configuration-cache/4qxf7tzsgios90i91fxmtohav/a10rhbrh9u5tku1v9bqi75yce/configuration-cache-report.html
> Starting an external process 'uname -a' during configuration time is unsupported.

I see the same error on JDK 11 and JDK 17. I'm attaching the configuration cache report from JDK 17.

Gradle Configuration Cache.pdf

Please let me know I can provide any other information.

msridhar commented 1 year ago

Possibly related to #203, but now I believe we already have the com.diffplug.configuration-cache-for-platform-specific-build plugin set up correctly in our settings.gradle.

msridhar commented 1 year ago

It looks like this code is relevant, similar to #203 (in fact this issue may just be a duplicate and possibly #203 was closed erroneously):

https://github.com/diffplug/durian-swt/blob/6adaf31d894be65fadcafaa1d8610c05c6561942/durian-swt.os/src/main/java/com/diffplug/common/swt/os/OS.java#L135-L136

Looks like this issue is specific to MacOS and detecting whether the chip is ARM or x86.

msridhar commented 1 year ago

I attempted a fix for this in https://github.com/diffplug/durian-swt/pull/24.

nedtwigg commented 1 year ago

Thanks for the PR! I posted my concerns there. If my concerns are incorrect, then this is easy to fix. If my concern is correct, I think we can fix it by using uname within this: https://github.com/diffplug/goomph/blob/main/src/main/java/com/diffplug/gradle/swt/PlatformSpecificBuildPlugin.java

msridhar commented 1 year ago

Hi @nedtwigg as I noted on the PR I think your concern is correct. As to changing PlatformSpecificBuildPlugin instead, I'm not exactly sure how that would work; I think we'd need to make a change also in durian-swt? In any case, if you'd like me to make a PR, it will be a few days before I can look again. Again thanks for the feedback!

nedtwigg commented 1 year ago

According to the docs [here](), this will work if it was run inside the plugin's apply block.

def gitVersion = providers.exec {
    commandLine("git", "--version")
}.standardOutput.asText.get()

Seems like something along the lines of

OS.detectPlatform(
  systemProp -> settings.getProviders().systemProperty(systemProp).forUseAtConfigurationTime().get(),
  envVar -> settings.getProviders().environmentVariable(envVar).forUseAtConfigurationTime().get(),
  (Function<List<String>, String> command executor) -> { args ->
    settings.getProviders().exec {
       commandLine(args)
    }.standardOutput.asText.get()
  }
);
msridhar commented 9 months ago

Thanks for this fix!! I confirmed on the WALA project that this fixes the configuration cache problem we were seeing on an M1 Mac.

nedtwigg commented 9 months ago

Fixed in 3.44.0.