change url to mirror
This commit is contained in:
parent
95dcbce822
commit
0f834fcbd3
|
@ -53,23 +53,23 @@ if (!tempDirectory) {
|
|||
}
|
||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||||
}
|
||||
function getMaven(version, url) {
|
||||
function getMaven(version, mirror) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let toolPath;
|
||||
toolPath = tc.find('maven', version);
|
||||
if (!toolPath) {
|
||||
toolPath = yield downloadMaven(version, url);
|
||||
toolPath = yield downloadMaven(version, mirror);
|
||||
}
|
||||
toolPath = path.join(toolPath, 'bin');
|
||||
core.addPath(toolPath);
|
||||
});
|
||||
}
|
||||
exports.getMaven = getMaven;
|
||||
function get_server_url(url) {
|
||||
if (url && url.indexOf("http") == 0) {
|
||||
return url;
|
||||
function get_server_url(mirror) {
|
||||
if (mirror && mirror.indexOf("http") == 0) {
|
||||
return mirror;
|
||||
}
|
||||
switch (url) {
|
||||
switch (mirror) {
|
||||
case "aliyun":
|
||||
return "https://maven.aliyun.com/repository/public";
|
||||
default:
|
||||
|
@ -77,10 +77,10 @@ function get_server_url(url) {
|
|||
}
|
||||
return "https://repo.maven.apache.org/maven2";
|
||||
}
|
||||
function downloadMaven(version, url) {
|
||||
function downloadMaven(version, mirror) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const toolDirectoryName = `apache-maven-${version}`;
|
||||
const downloadUrl = `${get_server_url(url)}/org/apache/maven/apache-maven/${version}/apache-maven-${version}-bin.tar.gz`;
|
||||
const downloadUrl = `${get_server_url(mirror)}/org/apache/maven/apache-maven/${version}/apache-maven-${version}-bin.tar.gz`;
|
||||
console.log(`downloading ${downloadUrl}`);
|
||||
try {
|
||||
const downloadPath = yield tc.downloadTool(downloadUrl);
|
||||
|
|
|
@ -19,23 +19,23 @@ if (!tempDirectory) {
|
|||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||||
}
|
||||
|
||||
export async function getMaven(version: string, url: string) {
|
||||
export async function getMaven(version: string, mirror: string) {
|
||||
let toolPath: string;
|
||||
toolPath = tc.find('maven', version);
|
||||
|
||||
if (!toolPath) {
|
||||
toolPath = await downloadMaven(version, url);
|
||||
toolPath = await downloadMaven(version, mirror);
|
||||
}
|
||||
|
||||
toolPath = path.join(toolPath, 'bin');
|
||||
core.addPath(toolPath);
|
||||
}
|
||||
|
||||
function get_server_url(url: string) {
|
||||
if (url && url.indexOf("http") == 0) {
|
||||
return url;
|
||||
function get_server_url(mirror: string) {
|
||||
if (mirror && mirror.indexOf("http") == 0) {
|
||||
return mirror;
|
||||
}
|
||||
switch (url) {
|
||||
switch (mirror) {
|
||||
case "aliyun":
|
||||
return "https://maven.aliyun.com/repository/public";
|
||||
default:
|
||||
|
@ -44,9 +44,9 @@ function get_server_url(url: string) {
|
|||
return "https://repo.maven.apache.org/maven2";
|
||||
}
|
||||
|
||||
async function downloadMaven(version: string, url: string): Promise<string> {
|
||||
async function downloadMaven(version: string, mirror: string): Promise<string> {
|
||||
const toolDirectoryName = `apache-maven-${version}`;
|
||||
const downloadUrl = `${get_server_url(url)}/org/apache/maven/apache-maven/${version}/apache-maven-${version}-bin.tar.gz`;
|
||||
const downloadUrl = `${get_server_url(mirror)}/org/apache/maven/apache-maven/${version}/apache-maven-${version}-bin.tar.gz`;
|
||||
console.log(`downloading ${downloadUrl}`);
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue