Skip to content

Add support specifying gradle distribution in the gradle-version agrument #598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/gradle/profiler/CommandLineParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public InvocationSettings parseSettings(String[] args) throws IOException, Setti
parser.nonOptions("The scenarios or task names to run");
ArgumentAcceptingOptionSpec<File> projectOption = parser.accepts("project-dir", "The directory containing the build to run")
.withRequiredArg().ofType(File.class).defaultsTo(new File(".").getCanonicalFile());
ArgumentAcceptingOptionSpec<String> gradleVersionOption = parser.accepts("gradle-version", "Gradle version or installation to use to run build")
ArgumentAcceptingOptionSpec<String> gradleVersionOption = parser.accepts("gradle-version", "Gradle version, distribution or installation to use to run build")
.withRequiredArg();
ArgumentAcceptingOptionSpec<File> gradleUserHomeOption = parser.accepts("gradle-user-home", "The Gradle user home to use")
.withRequiredArg()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.URI;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -89,6 +90,12 @@ private GradleBuildConfiguration doResolveVersion(String versionString) {
if (versionString.matches("\\d+(\\.\\d+)+(-.+)?")) {
return probe(connector().useGradleVersion(versionString));
}
try {
URI distributionUri = URI.create(versionString);
return probe(connector().useDistribution(distributionUri));
} catch (IllegalArgumentException e) {
// do nothing because versionString is not gradle distribution uri
}
} catch (IOException e) {
throw new RuntimeException("Could not locate Gradle distribution for requested version '" + versionString + "'.", e);
}
Expand Down