1
1
/*
2
- Licensed to the Apache Software Foundation (ASF) under one
3
- or more contributor license agreements. See the NOTICE file
4
- distributed with this work for additional information
5
- regarding copyright ownership. The ASF licenses this file
6
- to you under the Apache License, Version 2.0 (the
7
- "License"); you may not use this file except in compliance
8
- with the License. You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing,
13
- software distributed under the License is distributed on an
14
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
- KIND, either express or implied. See the License for the
16
- specific language governing permissions and limitations
17
- under the License.
18
- */
19
-
2
+ * Copyright 2007-present the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
20
16
import java .net .*;
21
17
import java .io .*;
22
18
import java .nio .channels .*;
23
19
import java .util .Properties ;
24
20
25
21
public class MavenWrapperDownloader {
26
22
23
+ private static final String WRAPPER_VERSION = "0.5.5" ;
27
24
/**
28
25
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
29
26
*/
30
- private static final String DEFAULT_DOWNLOAD_URL =
31
- "https://repo. maven.apache.org/maven2/io/takari/maven -wrapper/0.4.0/maven-wrapper-0.4.0 .jar" ;
27
+ private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28
+ + WRAPPER_VERSION + "/ maven-wrapper-" + WRAPPER_VERSION + " .jar" ;
32
29
33
30
/**
34
31
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
@@ -76,13 +73,13 @@ public static void main(String args[]) {
76
73
}
77
74
}
78
75
}
79
- System .out .println ("- Downloading from: : " + url );
76
+ System .out .println ("- Downloading from: " + url );
80
77
81
78
File outputFile = new File (baseDirectory .getAbsolutePath (), MAVEN_WRAPPER_JAR_PATH );
82
79
if (!outputFile .getParentFile ().exists ()) {
83
80
if (!outputFile .getParentFile ().mkdirs ()) {
84
81
System .out .println (
85
- "- ERROR creating output direcrory '" + outputFile .getParentFile ().getAbsolutePath () + "'" );
82
+ "- ERROR creating output directory '" + outputFile .getParentFile ().getAbsolutePath () + "'" );
86
83
}
87
84
}
88
85
System .out .println ("- Downloading to: " + outputFile .getAbsolutePath ());
@@ -98,6 +95,16 @@ public static void main(String args[]) {
98
95
}
99
96
100
97
private static void downloadFileFromURL (String urlString , File destination ) throws Exception {
98
+ if (System .getenv ("MVNW_USERNAME" ) != null && System .getenv ("MVNW_PASSWORD" ) != null ) {
99
+ String username = System .getenv ("MVNW_USERNAME" );
100
+ char [] password = System .getenv ("MVNW_PASSWORD" ).toCharArray ();
101
+ Authenticator .setDefault (new Authenticator () {
102
+ @ Override
103
+ protected PasswordAuthentication getPasswordAuthentication () {
104
+ return new PasswordAuthentication (username , password );
105
+ }
106
+ });
107
+ }
101
108
URL website = new URL (urlString );
102
109
ReadableByteChannel rbc ;
103
110
rbc = Channels .newChannel (website .openStream ());
0 commit comments