Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23309aacac |
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2022 stCarolas
|
Copyright (c) 2022 suisrc
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@ -4,7 +4,7 @@ Add this step into workflow
|
|||||||
|
|
||||||
```
|
```
|
||||||
- name: Set up Maven
|
- name: Set up Maven
|
||||||
uses: stCarolas/setup-maven@v5
|
uses: suisrc/setup-maven-cn@v5.1
|
||||||
with:
|
with:
|
||||||
maven-version: 3.8.2
|
maven-version: 3.8.2
|
||||||
```
|
```
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
name: 'Setup Maven'
|
name: 'Setup Maven'
|
||||||
description: 'Install a specific version of Apache Maven and add it to the PATH'
|
description: 'Install a specific version of Apache Maven and add it to the PATH'
|
||||||
author: 'stCarolas'
|
author: 'suisrc'
|
||||||
inputs:
|
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'
|
||||||
|
|||||||
@ -53,22 +53,26 @@ if (!tempDirectory) {
|
|||||||
}
|
}
|
||||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||||||
}
|
}
|
||||||
function getMaven(version) {
|
function getMaven(version, mirrors) {
|
||||||
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, mirrors);
|
||||||
}
|
}
|
||||||
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 downloadMaven(version, mirrors) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (!mirrors) {
|
||||||
|
mirrors = 'https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3';
|
||||||
|
// https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven
|
||||||
|
}
|
||||||
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 = `${mirrors}/${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 mirrors = core.getInput('maven-mirrors');
|
||||||
if (version) {
|
if (version) {
|
||||||
yield installer.getMaven(version);
|
yield installer.getMaven(version, mirrors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
"maven",
|
"maven",
|
||||||
"setup"
|
"setup"
|
||||||
],
|
],
|
||||||
"author": "stCarolas",
|
"author": "suisrc",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
|
|||||||
@ -19,21 +19,25 @@ 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, mirrors: string): Promise<void> {
|
||||||
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, mirrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolPath = path.join(toolPath, 'bin');
|
toolPath = path.join(toolPath, 'bin');
|
||||||
core.addPath(toolPath);
|
core.addPath(toolPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadMaven(version: string): Promise<string> {
|
async function downloadMaven(version: string, mirrors: string): Promise<string> {
|
||||||
|
if (!mirrors) {
|
||||||
|
mirrors = 'https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3';
|
||||||
|
// https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven
|
||||||
|
}
|
||||||
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 = `${mirrors}/${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 mirrors = core.getInput('maven-mirrors');
|
||||||
if (version) {
|
if (version) {
|
||||||
await installer.getMaven(version);
|
await installer.getMaven(version, mirrors);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed((error as Error).message);
|
core.setFailed((error as Error).message);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user