Merge c8a3e928ae
into d6af6abeda
This commit is contained in:
commit
fb41a687e6
|
@ -5,6 +5,9 @@ inputs:
|
||||||
maven-version:
|
maven-version:
|
||||||
description: 'Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0'
|
description: 'Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0'
|
||||||
default: '3.8.2'
|
default: '3.8.2'
|
||||||
|
maven-mirror:
|
||||||
|
description: 'download mirror,url or aliyun or empty'
|
||||||
|
default: ''
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node20'
|
||||||
main: 'lib/setup-maven.js'
|
main: 'lib/setup-maven.js'
|
||||||
|
|
|
@ -53,22 +53,34 @@ if (!tempDirectory) {
|
||||||
}
|
}
|
||||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||||||
}
|
}
|
||||||
function getMaven(version) {
|
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);
|
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 downloadMaven(version) {
|
function get_server_url(mirror) {
|
||||||
|
if (mirror && (mirror.indexOf("http") === 0)) {
|
||||||
|
return mirror;
|
||||||
|
}
|
||||||
|
switch (mirror) {
|
||||||
|
case "aliyun":
|
||||||
|
return "https://maven.aliyun.com/repository/public";
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return "https://repo.maven.apache.org/maven2";
|
||||||
|
}
|
||||||
|
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 = `https://repo.maven.apache.org/maven2/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);
|
||||||
|
|
|
@ -38,8 +38,9 @@ function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
let version = core.getInput('maven-version');
|
let version = core.getInput('maven-version');
|
||||||
|
let mirror = core.getInput('maven-mirror');
|
||||||
if (version) {
|
if (version) {
|
||||||
yield installer.getMaven(version);
|
yield installer.getMaven(version, mirror || "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
|
@ -19,21 +19,34 @@ if (!tempDirectory) {
|
||||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getMaven(version: 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);
|
toolPath = await downloadMaven(version, mirror);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolPath = path.join(toolPath, 'bin');
|
toolPath = path.join(toolPath, 'bin');
|
||||||
core.addPath(toolPath);
|
core.addPath(toolPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadMaven(version: string): Promise<string> {
|
function get_server_url(mirror: string) {
|
||||||
|
if (mirror && (mirror.indexOf("http") === 0)) {
|
||||||
|
return mirror;
|
||||||
|
}
|
||||||
|
switch (mirror) {
|
||||||
|
case "aliyun":
|
||||||
|
return "https://maven.aliyun.com/repository/public";
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return "https://repo.maven.apache.org/maven2";
|
||||||
|
}
|
||||||
|
|
||||||
|
async function downloadMaven(version: string, mirror: string): Promise<string> {
|
||||||
const toolDirectoryName = `apache-maven-${version}`;
|
const toolDirectoryName = `apache-maven-${version}`;
|
||||||
const downloadUrl = `https://repo.maven.apache.org/maven2/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 {
|
||||||
|
|
|
@ -4,8 +4,9 @@ import * as installer from './installer';
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
let version = core.getInput('maven-version');
|
let version = core.getInput('maven-version');
|
||||||
|
let mirror = core.getInput('maven-mirror');
|
||||||
if (version) {
|
if (version) {
|
||||||
await installer.getMaven(version);
|
await installer.getMaven(version, mirror || "");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed((error as Error).message);
|
core.setFailed((error as Error).message);
|
||||||
|
|
Loading…
Reference in New Issue