/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.5";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
easyExcel实现大数据导出 (140个子文件)
ExcelExportUtil.class 3KB
DemoApplication.class 723B
DemoApplicationTests.class 521B
mvnw.cmd 6KB
.gitignore 333B
demo.iml 8KB
maven-wrapper.jar 50KB
MavenWrapperDownloader.java 5KB
ExcelExportUtil.java 2KB
DemoApplication.java 312B
DemoApplicationTests.java 210B
inputFiles.lst 164B
createdFiles.lst 0B
HELP.md 310B
mvnw 10KB
maven-wrapper.properties 218B
application.properties 1B
application.properties 1B
withHead35.xls 19KB
withHead47.xls 19KB
withHead8.xls 19KB
withHead39.xls 19KB
withHead13.xls 19KB
withHead25.xls 19KB
withHead23.xls 19KB
withHead45.xls 19KB
withHead10.xls 19KB
withHead43.xls 19KB
withHead50.xls 19KB
withHead24.xls 19KB
withHead49.xls 19KB
withHead34.xls 19KB
withHead20.xls 19KB
withHead27.xls 19KB
withHead6.xls 19KB
withHead3.xls 19KB
withHead11.xls 19KB
withHead17.xls 19KB
withHead32.xls 19KB
withHead16.xls 19KB
withHead9.xls 19KB
withHead42.xls 19KB
withHead21.xls 19KB
withHead26.xls 19KB
withHead18.xls 19KB
withHead37.xls 19KB
withHead48.xls 19KB
withHead40.xls 19KB
withHead14.xls 19KB
withHead2.xls 19KB
withHead36.xls 19KB
withHead46.xls 19KB
withHead12.xls 19KB
withHead38.xls 19KB
withHead33.xls 19KB
withHead28.xls 19KB
withHead5.xls 19KB
withHead30.xls 19KB
withHead1.xls 19KB
withHead31.xls 19KB
withHead41.xls 19KB
withHead19.xls 19KB
withHead7.xls 19KB
withHead29.xls 19KB
withHead4.xls 19KB
withHead44.xls 19KB
withHead22.xls 19KB
withHead15.xls 19KB
workspace.xml 14KB
pom.xml 2KB
Project_Default.xml 1KB
compiler.xml 803B
Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_2_1_RELEASE.xml 793B
Maven__org_springframework_boot_spring_boot_starter_logging_2_2_1_RELEASE.xml 772B
Maven__org_springframework_boot_spring_boot_autoconfigure_2_2_1_RELEASE.xml 758B
Maven__org_springframework_boot_spring_boot_starter_test_2_2_1_RELEASE.xml 751B
Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml 724B
Maven__org_springframework_boot_spring_boot_starter_2_2_1_RELEASE.xml 716B
Maven__org_springframework_boot_spring_boot_test_2_2_1_RELEASE.xml 695B
Maven__org_springframework_spring_expression_5_2_1_RELEASE.xml 682B
Maven__org_springframework_spring_context_5_2_1_RELEASE.xml 661B
Maven__org_springframework_boot_spring_boot_2_2_1_RELEASE.xml 660B
Maven__org_junit_platform_junit_platform_commons_1_5_2.xml 657B
Maven__jakarta_annotation_jakarta_annotation_api_1_3_5.xml 657B
Maven__jakarta_activation_jakarta_activation_api_1_2_1.xml 657B
Maven__org_junit_platform_junit_platform_engine_1_5_2.xml 650B
Maven__org_springframework_spring_beans_5_2_1_RELEASE.xml 647B
Maven__com_sun_istack_istack_commons_runtime_3_0_8.xml 641B
Maven__org_springframework_spring_test_5_2_1_RELEASE.xml 640B
Maven__org_springframework_spring_core_5_2_1_RELEASE.xml 640B
Maven__org_junit_jupiter_junit_jupiter_params_5_5_2.xml 639B
Maven__org_junit_jupiter_junit_jupiter_engine_5_5_2.xml 639B
Maven__jakarta_xml_bind_jakarta_xml_bind_api_2_3_2.xml 635B
Maven__org_springframework_spring_aop_5_2_1_RELEASE.xml 633B
Maven__org_springframework_spring_jcl_5_2_1_RELEASE.xml 633B
Maven__org_apache_logging_log4j_log4j_to_slf4j_2_12_1.xml 632B
Maven__org_apache_commons_commons_collections4_4_1.xml 629B
checkstyle-idea.xml 624B
Maven__org_mockito_mockito_junit_jupiter_3_1_0.xml 622B
Maven__org_junit_jupiter_junit_jupiter_api_5_5_2.xml 618B
共 140 条
- 1
- 2
资源评论
- 程序猿大叔文海2021-01-19垃圾,一个demo
- 疯狂的太阳2020-09-13垃圾的东西!!!
最清晰的脚印
- 粉丝: 59
- 资源: 103
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 高等数学第一章第二节数列的极限
- Python 版冒泡排序算法源代码
- tensorflow-gpu-2.7.2-cp38-cp38-manylinux2010-x86-64.whl
- tensorflow-2.7.3-cp39-cp39-manylinux2010-x86-64.whl
- tensorflow-2.7.2-cp39-cp39-manylinux2010-x86-64.whl
- Python版本快速排序源代码
- Python 语言版的快速排序算法实现
- 450815388207377安卓_base.apk
- 超微主板 X9DRE-TF+ bios 支持 nvme启动
- 基于Python通过下载气象数据和插值拟合离散数据曲线实现对寒潮过程的能量分析
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功