/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.Properties;
public class MavenWrapperDownloader {
/**
* 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/0.4.2/maven-wrapper-0.4.2.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 direcrory '" + 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 {
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();
}
}
![avatar](https://profile-avatar.csdnimg.cn/bc3c40a1700d40bc91a04af0dc7133fa_weixin_41883161.jpg!1)
九转成圣
- 粉丝: 6177
- 资源: 2958
最新资源
- GXX-MLSGA40 高新兴国迈视音频一体化管理平台V4.2.0_部署手册.docx
- 智能家居专用-STM32 以太网开发板电路设计(含功能试验源码、原理图、开源带例程)
- 基于MATLAB2020b和Carsim2020的模型预测控制(MPC)与路径跟踪(PTC)结合侧偏角软约束及主动前轮转向仿真研究,基于MATLAB2020b与Carsim2020的模型预测控制(MP
- 基于SHO-CNN-SVM图像识别模型:多层次卷积池化与海马优化算法的深度应用,为口腔溃疡图像数据集带来高精度迁移性优势,支持灵活替换算法体系,基于SHO-CNN-SVM算法的图像识别模型:多元特征提
- 毕设springboot在线拍卖系统
- 基于图卷积神经网络(GCN)的数据分类预测:Matlab 2022A版本及以上的GCN模型实现代码指南,基于图卷积神经网络(GCN)的Matlab代码实现与数据分类预测应用指南(适用于Matlab 2
- 基于魔术公式的非线性七自由度车辆Simulink模型与二、三自由度车辆模型对照研究及动力学模型参考分析,基于魔术公式的非线性七自由度车辆Simulink模型与二、三自由度对照研究,包含驱动力矩、制动力
- 基于Simulink的无线充电仿真:LCC谐振器与磁耦合谐振的恒压恒流输出研究及四套模型解析,基于Simulink的无线充电仿真:探讨LCC谐振器与磁耦合谐振的恒压恒流输出及拓扑补偿技术,无线充电仿真
- 经典Banba低压带隙基准电路,SMIC 130nm工艺,输出890mv,可调整电压值,含完整版图的Bandgap电路与二级密勒补偿运放仿真结果展示,经典Banba低压带隙基准,电流模结构,工艺SMI
- 智能家居系统设计(附智能照明、自动浇花、宠物喂食器功能)【含代码、文档】
- Simulink整车控制器VCU模型:简洁易懂,经过实车验证,展现卓越处理能力与可读性-自动驾驶部分待调试屏蔽状态,Simulink整车控制器VCU模型:简单易懂,经实车验证!适当处理,注重可读性
- 50%占空比振荡器:开关电源核心元件,带修调功能,学习实践之理想选择,50%占空比振荡器:开关电源的理想选择,带修调功能,助力学习与实践,50%占空比振荡器,适用于开关电源,带修调,适合学习 ,50%
- 编队控制中的分布式线性二次离散时间博弈方法:碰撞避免策略的探索与应用,编队控制与博弈的分布式线性二次离散时间方法:碰撞避免策略研究,26.避免碰撞的编队控制分布式线性二次离散时间博弈方法 ,避免碰撞
- 智能家居管理系统设计(原理图+APP+源代码等)
- 基于Dugoff轮胎模型的车辆七自由度模型研究及魔术轮胎公式在路面附着系数估计中的应用-附参考文献与说明文档,基于Dugoff轮胎模型的车辆七自由度模型研究及魔术轮胎公式在路面附着系数估计中的应用说
- 基于博途1200 PLC与HMI的智能花式喷泉控制系统仿真工程:四模式喷水花样实现与优化,基于博途1200 PLC与HMI联合的花式喷泉控制系统仿真研究与实践教程,基于博途1200PLC+HMI花式喷
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)