Skip to content

Commit 759a2d2

Browse files
committed
[mvn] Update maven wrapper
1 parent 094786b commit 759a2d2

File tree

5 files changed

+501
-351
lines changed

5 files changed

+501
-351
lines changed

.mvn/settings.xml

+12
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
-->
1919
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2020
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
21+
2122
<servers>
23+
<!-- Used for sonatype snapshots and releases -->
2224
<server>
2325
<id>ossrh</id>
2426
<username>${env.CI_DEPLOY_USERNAME}</username>
2527
<password>${env.CI_DEPLOY_PASSWORD}</password>
2628
</server>
29+
2730
<!-- Used for gh-pages-scm publish via maven-scm-publish-plugin -->
2831
<server>
2932
<id>gh-pages-scm</id>
@@ -32,10 +35,19 @@
3235
<scmVersion>gh-pages</scmVersion>
3336
</configuration>
3437
</server>
38+
39+
<!-- Github deployments (site) -->
3540
<server>
3641
<id>github</id>
3742
<username>${env.CI_DEPLOY_USERNAME}</username>
3843
<password>${env.GITHUB_TOKEN}</password>
3944
</server>
45+
46+
<!-- NVD API Access (dependency-check-plugin) -->
47+
<server>
48+
<id>nvd</id>
49+
<password>${env.NVD_API_KEY}</password>
50+
</server>
4051
</servers>
52+
4153
</settings>

.mvn/wrapper/MavenWrapperDownloader.java

+44-49
Original file line numberDiff line numberDiff line change
@@ -21,77 +21,72 @@
2121
import java.io.InputStream;
2222
import java.net.Authenticator;
2323
import java.net.PasswordAuthentication;
24+
import java.net.URI;
2425
import java.net.URL;
2526
import java.nio.file.Files;
2627
import java.nio.file.Path;
2728
import java.nio.file.Paths;
2829
import java.nio.file.StandardCopyOption;
30+
import java.util.concurrent.ThreadLocalRandom;
2931

30-
public final class MavenWrapperDownloader
31-
{
32-
private static final String WRAPPER_VERSION = "3.2.0";
32+
public final class MavenWrapperDownloader {
33+
private static final String WRAPPER_VERSION = "3.3.0";
3334

34-
private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) );
35+
private static final boolean VERBOSE = Boolean.parseBoolean(System.getenv("MVNW_VERBOSE"));
3536

36-
public static void main( String[] args )
37-
{
38-
log( "Apache Maven Wrapper Downloader " + WRAPPER_VERSION );
37+
public static void main(String[] args) {
38+
log("Apache Maven Wrapper Downloader " + WRAPPER_VERSION);
3939

40-
if ( args.length != 2 )
41-
{
42-
System.err.println( " - ERROR wrapperUrl or wrapperJarPath parameter missing" );
43-
System.exit( 1 );
40+
if (args.length != 2) {
41+
System.err.println(" - ERROR wrapperUrl or wrapperJarPath parameter missing");
42+
System.exit(1);
4443
}
4544

46-
try
47-
{
48-
log( " - Downloader started" );
49-
final URL wrapperUrl = new URL( args[0] );
50-
final String jarPath = args[1].replace( "..", "" ); // Sanitize path
51-
final Path wrapperJarPath = Paths.get( jarPath ).toAbsolutePath().normalize();
52-
downloadFileFromURL( wrapperUrl, wrapperJarPath );
53-
log( "Done" );
54-
}
55-
catch ( IOException e )
56-
{
57-
System.err.println( "- Error downloading: " + e.getMessage() );
58-
if ( VERBOSE )
59-
{
45+
try {
46+
log(" - Downloader started");
47+
final URL wrapperUrl = URI.create(args[0]).toURL();
48+
final String jarPath = args[1].replace("..", ""); // Sanitize path
49+
final Path wrapperJarPath = Paths.get(jarPath).toAbsolutePath().normalize();
50+
downloadFileFromURL(wrapperUrl, wrapperJarPath);
51+
log("Done");
52+
} catch (IOException e) {
53+
System.err.println("- Error downloading: " + e.getMessage());
54+
if (VERBOSE) {
6055
e.printStackTrace();
6156
}
62-
System.exit( 1 );
57+
System.exit(1);
6358
}
6459
}
6560

66-
private static void downloadFileFromURL( URL wrapperUrl, Path wrapperJarPath )
67-
throws IOException
68-
{
69-
log( " - Downloading to: " + wrapperJarPath );
70-
if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null )
71-
{
72-
final String username = System.getenv( "MVNW_USERNAME" );
73-
final char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray();
74-
Authenticator.setDefault( new Authenticator()
75-
{
61+
private static void downloadFileFromURL(URL wrapperUrl, Path wrapperJarPath)
62+
throws IOException {
63+
log(" - Downloading to: " + wrapperJarPath);
64+
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
65+
final String username = System.getenv("MVNW_USERNAME");
66+
final char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
67+
Authenticator.setDefault(new Authenticator() {
7668
@Override
77-
protected PasswordAuthentication getPasswordAuthentication()
78-
{
79-
return new PasswordAuthentication( username, password );
69+
protected PasswordAuthentication getPasswordAuthentication() {
70+
return new PasswordAuthentication(username, password);
8071
}
81-
} );
72+
});
8273
}
83-
try ( InputStream inStream = wrapperUrl.openStream() )
84-
{
85-
Files.copy( inStream, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING );
74+
Path temp = wrapperJarPath
75+
.getParent()
76+
.resolve(wrapperJarPath.getFileName() + "."
77+
+ Long.toUnsignedString(ThreadLocalRandom.current().nextLong()) + ".tmp");
78+
try (InputStream inStream = wrapperUrl.openStream()) {
79+
Files.copy(inStream, temp, StandardCopyOption.REPLACE_EXISTING);
80+
Files.move(temp, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING);
81+
} finally {
82+
Files.deleteIfExists(temp);
8683
}
87-
log( " - Downloader complete" );
84+
log(" - Downloader complete");
8885
}
8986

90-
private static void log( String msg )
91-
{
92-
if ( VERBOSE )
93-
{
94-
System.out.println( msg );
87+
private static void log(String msg) {
88+
if (VERBOSE) {
89+
System.out.println(msg);
9590
}
9691
}
9792

.mvn/wrapper/maven-wrapper.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# "License"); you may not use this file except in compliance
77
# with the License. You may obtain a copy of the License at
88
#
9-
# http://www.apache.org/licenses/LICENSE-2.0
9+
# https://www.apache.org/licenses/LICENSE-2.0
1010
#
1111
# Unless required by applicable law or agreed to in writing,
1212
# software distributed under the License is distributed on an
@@ -15,3 +15,4 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.0/maven-wrapper-3.3.0.jar

0 commit comments

Comments
 (0)