in maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java [258:313]
private void replaceProperties(String wrapperVersion, Path targetFolder) throws MojoExecutionException {
String repoUrl = getRepoUrl();
String distributionUrl = repoUrl + "/org/apache/maven/apache-maven/" + mavenVersion + "/apache-maven-"
+ mavenVersion + "-bin.zip";
String wrapperUrl = repoUrl + "/org/apache/maven/wrapper/maven-wrapper/" + wrapperVersion + "/maven-wrapper-"
+ wrapperVersion + ".jar";
if (mvndVersion != null && mvndVersion.length() > 0) {
// now maven-mvnd is not published to the central repo.
distributionUrl = "https://archive.apache.org/dist/maven/mvnd/" + mvndVersion + "/maven-mvnd-" + mvndVersion
+ "-bin.zip";
}
Path wrapperPropertiesFile = targetFolder.resolve("maven-wrapper.properties");
getLog().info("Configuring .mvn/wrapper/maven-wrapper.properties to use "
+ buffer().strong("Maven " + mavenVersion) + " and download from " + repoUrl);
final String license = "# Licensed to the Apache Software Foundation (ASF) under one%n"
+ "# or more contributor license agreements. See the NOTICE file%n"
+ "# distributed with this work for additional information%n"
+ "# regarding copyright ownership. The ASF licenses this file%n"
+ "# to you under the Apache License, Version 2.0 (the%n"
+ "# \"License\"); you may not use this file except in compliance%n"
+ "# with the License. You may obtain a copy of the License at%n"
+ "#%n"
+ "# http://www.apache.org/licenses/LICENSE-2.0%n"
+ "#%n"
+ "# Unless required by applicable law or agreed to in writing,%n"
+ "# software distributed under the License is distributed on an%n"
+ "# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%n"
+ "# KIND, either express or implied. See the License for the%n"
+ "# specific language governing permissions and limitations%n"
+ "# under the License.%n";
try (BufferedWriter out = Files.newBufferedWriter(wrapperPropertiesFile, StandardCharsets.UTF_8)) {
out.append(String.format(Locale.ROOT, license));
out.append("distributionUrl=" + distributionUrl + System.lineSeparator());
if (distributionSha256Sum != null) {
out.append("distributionSha256Sum=" + distributionSha256Sum + System.lineSeparator());
}
out.append("wrapperUrl=" + wrapperUrl + System.lineSeparator());
if (wrapperSha256Sum != null) {
out.append("wrapperSha256Sum=" + wrapperSha256Sum + System.lineSeparator());
}
if (alwaysDownload) {
out.append("alwaysDownload=" + Boolean.TRUE + System.lineSeparator());
}
if (alwaysUnpack) {
out.append("alwaysUnpack=" + Boolean.TRUE + System.lineSeparator());
}
} catch (IOException ioe) {
throw new MojoExecutionException("Can't create maven-wrapper.properties", ioe);
}
}