Skip to content

Commit

Permalink
Fix external process started 'uname -a' warnings (part of #167).
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg committed Dec 8, 2023
1 parent 6e42048 commit 552977b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ changelog_per_project=true
VER_JUNIT=5.10.1
VER_ASSERTJ=3.24.2
VER_SNAPSHOT_TESTING=4.0.1
VER_DURIAN_SWT=4.2.2
VER_DURIAN_SWT=4.3.0
VER_EQUO_CHROMIUM=106.0.8
37 changes: 34 additions & 3 deletions plugin-gradle/src/main/java/dev/equo/ide/gradle/GradleCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*******************************************************************************/
package dev.equo.ide.gradle;

import com.diffplug.common.swt.os.OS;
import dev.equo.solstice.p2.CacheLocations;
import java.io.File;
import java.lang.reflect.Field;
Expand All @@ -21,6 +22,7 @@
import java.util.regex.Pattern;
import org.gradle.api.GradleException;
import org.gradle.api.Project;
import org.gradle.api.provider.Provider;

class GradleCommon {
static final String MINIMUM_GRADLE = "6.0";
Expand All @@ -29,6 +31,7 @@ static void initialize(Project project, String name) {
if (gradleIsTooOld(project)) {
throw new GradleException(name + " requires Gradle " + MINIMUM_GRADLE + " or later");
}
platformSpecificBuild(project);
setCacheLocations(project);
}

Expand Down Expand Up @@ -70,12 +73,40 @@ private static int badSemver(int major, int minor) {
static boolean anyArgMatching(Project project, Predicate<String> predicate) {
return project.getGradle().getStartParameter().getTaskRequests().stream()
.flatMap(taskReq -> taskReq.getArgs().stream())
.filter(predicate)
.findAny()
.isPresent();
.anyMatch(predicate);
}

static boolean anyArgEquals(Project project, String arg) {
return anyArgMatching(project, a -> a.equals(arg));
}

// copied from
// https://github.com/diffplug/goomph/blob/main/src/main/java/com/diffplug/gradle/swt/PlatformSpecificBuildPlugin.java
private static void platformSpecificBuild(Project settings) {
OS.detectPlatform(
systemProp -> get(settings, settings.getProviders().systemProperty(systemProp)),
envVar -> get(settings, settings.getProviders().environmentVariable(envVar)),
cmds ->
get(
settings,
settings
.getProviders()
.exec(
e -> {
e.commandLine(cmds.toArray());
})
.getStandardOutput()
.getAsText()));
}

private static <T> T get(Project settings, Provider<T> provider) {
if (badSemver(settings.getGradle().getGradleVersion())
>= badSemver(STOP_FORUSE_AT_CONFIGURATION_TIME)) {
return provider.get();
} else {
return provider.forUseAtConfigurationTime().get();
}
}

private static final String STOP_FORUSE_AT_CONFIGURATION_TIME = "7.4";
}

0 comments on commit 552977b

Please sign in to comment.