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