22
22
import java .io .InputStream ;
23
23
import java .io .OutputStream ;
24
24
import java .net .HttpURLConnection ;
25
- import java .net .URL ;
25
+ import java .net .URI ;
26
26
import java .nio .charset .StandardCharsets ;
27
27
import java .nio .file .Files ;
28
28
import java .nio .file .Path ;
@@ -54,7 +54,7 @@ public static void main(String[] args) {
54
54
}
55
55
56
56
public static void checkVersion () {
57
- int major = Runtime .getRuntime (). version ().feature ();
57
+ int major = Runtime .version ().feature ();
58
58
if (major < 21 || major > 23 ) {
59
59
throw new IllegalStateException (
60
60
"java version must be between 21 and 23, your version: " + major );
@@ -89,12 +89,12 @@ public void run(Path destination) throws IOException, NoSuchAlgorithmException {
89
89
}
90
90
}
91
91
92
- URL url =
93
- new URL (
92
+ URI uri =
93
+ URI . create (
94
94
"https://raw.githubusercontent.com/gradle/gradle/v"
95
95
+ wrapperVersion
96
96
+ "/gradle/wrapper/gradle-wrapper.jar" );
97
- System .err .println ("Downloading gradle-wrapper.jar from " + url );
97
+ System .err .println ("Downloading gradle-wrapper.jar from " + uri );
98
98
99
99
// Zero-copy save the jar to a temp file
100
100
Path temp = Files .createTempFile (destination .getParent (), ".gradle-wrapper" , ".tmp" );
@@ -103,7 +103,7 @@ public void run(Path destination) throws IOException, NoSuchAlgorithmException {
103
103
int retryDelay = 30 ;
104
104
HttpURLConnection connection ;
105
105
while (true ) {
106
- connection = (HttpURLConnection ) url .openConnection ();
106
+ connection = (HttpURLConnection ) uri . toURL () .openConnection ();
107
107
try {
108
108
connection .connect ();
109
109
} catch (IOException e ) {
0 commit comments