Slackbot
12/11/2023, 10:35 PMtwisterrob
12/11/2023, 10:40 PMorg.gradle.wrapper.GradleUserHomeLookup#gradleUserHome might be the answer.
This must be documented somewhere too, but couldn't find it with a quick search.
Tip: right click the gradle-wrapper.jar and add as library, then you can expand and browse the classes. Alternatively: https://github.com/gradle/gradle/blob/master/platforms/core-runtime/wrapper-shared/src/main/java/org/gradle/wrapper/GradleUserHomeLookup.javatwisterrob
12/11/2023, 10:41 PMRyan Schmitt
12/11/2023, 10:43 PMRyan Schmitt
12/11/2023, 10:43 PMtwisterrob
12/11/2023, 10:44 PMdists folder?Ryan Schmitt
12/11/2023, 10:45 PMGRADLE_HOME in $GRADLE_HOME/bin/gradleRyan Schmitt
12/11/2023, 10:45 PMRyan Schmitt
12/11/2023, 10:46 PMinit.d/ directory contents, and I need much better visibility than I currently have into how Gradle distinguishes different Gradle installationstwisterrob
12/11/2023, 10:49 PMRyan Schmitt
12/11/2023, 10:49 PMtwisterrob
12/11/2023, 10:49 PMRyan Schmitt
12/11/2023, 10:50 PMdistributionSha256Sum that seems to appear in the wrapper dists' paths, there's the APP_HOME environment variable that the bin/gradle script seems very concerned with figuring outRyan Schmitt
12/11/2023, 10:51 PMhow do you tell it to use a specific installation?You run the
bin/gradle script from that installation. That's the only place where I've been able to find code that is clearly concerned with locating the Gradle installation directory (for the current distribution)twisterrob
12/11/2023, 10:52 PMbin/.. but in a really roundabout way 🙂Ryan Schmitt
12/11/2023, 10:52 PMbin/gradle resolves symlinksRyan Schmitt
12/11/2023, 10:52 PMtwisterrob
12/11/2023, 10:53 PMCLASSPATH=$APP_HOME/lib/gradle-launcher-8.5.jar and wrapper is doing something similarRyan Schmitt
12/11/2023, 10:53 PMRyan Schmitt
12/11/2023, 10:54 PMjava -jar .../gradle-launcher-8.5.jar it locates the Gradle installation where that jar file lives, no matter which working directory you run java in. Which suggests that this information is effectively baked into the classpathRyan Schmitt
12/11/2023, 10:56 PMdistributionSha256Sum -- you can't distinguish a Gradle installation by the SHA256 of its classpath, because the same jar files could live in different locationstwisterrob
12/11/2023, 10:57 PMGradleWrapperMain.class.getProtectionDomain().getCodeSource().getLocation()
to locate itself.Ryan Schmitt
12/11/2023, 10:57 PMtwisterrob
12/11/2023, 10:58 PMRyan Schmitt
12/11/2023, 10:59 PMRyan Schmitt
12/11/2023, 10:59 PMbin/gradle to be a "gradle wrapper" technically speakingtwisterrob
12/11/2023, 10:59 PMtwisterrob
12/11/2023, 11:00 PMdists and then launches it, so I think yes.twisterrob
12/11/2023, 11:00 PMgetProtectionDomain (you can probably find the same in the gradle repo too)twisterrob
12/11/2023, 11:01 PMRyan Schmitt
12/11/2023, 11:01 PMtwisterrob
12/11/2023, 11:04 PMGRADLE_OPTS=<... the usual debugger attach params for Java> some/bin/gradle and then attach a debugger with a breakpoint at org.gradle.launcher.GradleMain.twisterrob
12/11/2023, 11:06 PMSystem.getProperties() and getenv() and follow through. I have a feeling it would quickly reach a point where it knows where it is.Ryan Schmitt
12/11/2023, 11:08 PMRyan Schmitt
12/11/2023, 11:09 PMGradleRunner option that lets you provide a Gradle distribution to run. I suppose that if you don't set it, the default behavior is to use the "current" distributionRyan Schmitt
12/11/2023, 11:09 PMtwisterrob
12/11/2023, 11:11 PMRyan Schmitt
12/11/2023, 11:14 PMFile testKitDir = createTestKitDir(testKitDirProvider);
GradleProvider effectiveDistribution = gradleProvider == null ? findGradleInstallFromGradleRunner() : gradleProvider;
🤔Ryan Schmitt
12/11/2023, 11:15 PMprivate static GradleProvider findGradleInstallFromGradleRunner() {
GradleInstallation gradleInstallation = CurrentGradleInstallation.get();Ryan Schmitt
12/11/2023, 11:16 PMRyan Schmitt
12/11/2023, 11:17 PM/**
* This marker is used to locate the "source" Gradle distribution at runtime.
* See {@code CurrentGradleInstallationLocator}.
*/
@SuppressWarnings("unused")
public interface InstallationBeacon {
}
abstract class CurrentGradleInstallationLocator {
private static final String BEACON_CLASS_NAME = "org.gradle.internal.installation.beacon.InstallationBeacon";
😮twisterrob
12/11/2023, 11:19 PMclasspathutil was the third in my list aboveRyan Schmitt
12/11/2023, 11:20 PMRyan Schmitt
12/11/2023, 11:22 PMtwisterrob
12/11/2023, 11:24 PMtwisterrob
12/11/2023, 11:25 PM