Skip to content

Commit ba9297c

Browse files
authored
Fix configuration cache issues (#214 fixes #211)
2 parents 4220dbf + f89c5c9 commit ba9297c

File tree

3 files changed

+46
-11
lines changed

3 files changed

+46
-11
lines changed

CHANGES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
## [Unreleased]
44
### Added
5-
- Eclipse `4.30.0` aka `2023-12` ([new and noteworthy](https://eclipse.dev/eclipse/news/4.30/))
5+
- Eclipse `4.30.0` aka `2023-12` ([new and noteworthy](https://eclipse.dev/eclipse/news/4.30/)) ([#213](https://github.com/diffplug/goomph/pull/213))
6+
### Fixed
7+
- `com.diffplug.configuration-cache-for-platform-specific-build` no longer throws Gradle warnings about `uname -a` or about `forUseAtConfigurationTime` being deprecated. ([#214](https://github.com/diffplug/goomph/pull/214))
68

79
## [3.43.0] - 2023-09-28
810
### Added

build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ spotless {
2929
}
3030

3131
String VER_DURIAN = '1.2.0'
32-
String VER_DURIAN_SWT = '3.6.1'
32+
String VER_DURIAN_SWT = '4.3.0'
3333
String VER_BNDLIB = '6.3.1'
3434
String OLDEST_SUPPORTED_GRADLE = '5.1'
3535
String VER_P2_BOOTSTRAP = '4.13.0'
@@ -40,15 +40,15 @@ dependencies {
4040
implementation "com.diffplug.durian:durian-collect:${VER_DURIAN}"
4141
implementation "com.diffplug.durian:durian-io:${VER_DURIAN}"
4242
implementation "com.diffplug.durian:durian-swt.os:${VER_DURIAN_SWT}"
43-
implementation "commons-io:commons-io:2.11.0"
44-
implementation "com.diffplug.spotless:spotless-lib:2.28.0"
45-
implementation "com.squareup.okhttp3:okhttp:4.10.0"
46-
implementation "com.squareup.okio:okio:3.2.0"
43+
implementation "commons-io:commons-io:2.15.1"
44+
implementation "com.diffplug.spotless:spotless-lib:2.34.0"
45+
implementation "com.squareup.okhttp3:okhttp:4.12.0"
46+
implementation "com.squareup.okio:okio:3.6.0"
4747
// OSGi
4848
implementation "biz.aQute.bnd:biz.aQute.bndlib:${VER_BNDLIB}"
4949
// testing
5050
testImplementation "junit:junit:4.13.2"
51-
testImplementation "org.assertj:assertj-core:3.23.1"
51+
testImplementation "org.assertj:assertj-core:3.24.2"
5252
}
5353

5454
configurations.compileClasspath {

src/main/java/com/diffplug/gradle/swt/PlatformSpecificBuildPlugin.java

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021 DiffPlug
2+
* Copyright (C) 2021-2023 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,10 +15,12 @@
1515
*/
1616
package com.diffplug.gradle.swt;
1717

18-
1918
import com.diffplug.common.swt.os.OS;
19+
import java.util.regex.Matcher;
20+
import java.util.regex.Pattern;
2021
import org.gradle.api.Plugin;
2122
import org.gradle.api.initialization.Settings;
23+
import org.gradle.api.provider.Provider;
2224

2325
/**
2426
* In order to detect the underlying operating system and architecture, it is necessary to
@@ -29,10 +31,41 @@
2931
* the appropriate APIs</a> which don't break the configuration cache.
3032
*/
3133
public class PlatformSpecificBuildPlugin implements Plugin<Settings> {
34+
3235
@Override
3336
public void apply(Settings settings) {
3437
OS.detectPlatform(
35-
systemProp -> settings.getProviders().systemProperty(systemProp).forUseAtConfigurationTime().get(),
36-
envVar -> settings.getProviders().environmentVariable(envVar).forUseAtConfigurationTime().get());
38+
systemProp -> get(settings, settings.getProviders().systemProperty(systemProp)),
39+
envVar -> get(settings, settings.getProviders().environmentVariable(envVar)),
40+
cmds -> get(settings, settings.getProviders().exec(e -> {
41+
e.commandLine(cmds.toArray());
42+
}).getStandardOutput().getAsText()));
43+
}
44+
45+
private <T> T get(Settings settings, Provider<T> provider) {
46+
if (badSemver(settings.getGradle().getGradleVersion()) >= badSemver(STOP_FORUSE_AT_CONFIGURATION_TIME)) {
47+
return provider.get();
48+
} else {
49+
return provider.forUseAtConfigurationTime().get();
50+
}
51+
}
52+
53+
static final String STOP_FORUSE_AT_CONFIGURATION_TIME = "7.4";
54+
55+
private static final Pattern BAD_SEMVER = Pattern.compile("(\\d+)\\.(\\d+)");
56+
57+
private static int badSemver(String input) {
58+
Matcher matcher = BAD_SEMVER.matcher(input);
59+
if (!matcher.find() || matcher.start() != 0) {
60+
throw new IllegalArgumentException("Version must start with " + BAD_SEMVER.pattern());
61+
}
62+
String major = matcher.group(1);
63+
String minor = matcher.group(2);
64+
return badSemver(Integer.parseInt(major), Integer.parseInt(minor));
65+
}
66+
67+
/** Ambiguous after 2147.483647.blah-blah */
68+
private static int badSemver(int major, int minor) {
69+
return major * 1_000_000 + minor;
3770
}
3871
}

0 commit comments

Comments
 (0)