Skip to content

Commit dc5f78f

Browse files
author
Bryan Clark
committed
generated and pretty files
1 parent b0e5cf2 commit dc5f78f

4 files changed

Lines changed: 16 additions & 9 deletions

File tree

lib/auth.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ const core = __importStar(require("@actions/core"));
2222
const io = __importStar(require("@actions/io"));
2323
exports.M2_DIR = '.m2';
2424
exports.SETTINGS_FILE = 'settings.xml';
25-
function configAuthentication(username, password) {
25+
function configAuthentication(id, username, password) {
2626
return __awaiter(this, void 0, void 0, function* () {
27-
if (username && password) {
27+
if (id && username && password) {
2828
core.debug(`configAuthentication with ${username} and a password`);
2929
const directory = path.join(os.homedir(), exports.M2_DIR);
3030
yield io.mkdirP(directory);
3131
core.debug(`created directory ${directory}`);
32-
yield write(directory, generate(username, password));
32+
yield write(directory, generate(id, username, password));
3333
}
3434
else {
3535
core.debug(`no auth without username: ${username} and password: ${password}`);
@@ -38,11 +38,12 @@ function configAuthentication(username, password) {
3838
}
3939
exports.configAuthentication = configAuthentication;
4040
// only exported for testing purposes
41-
function generate(username, password) {
41+
function generate(id, username, password) {
4242
return `
4343
<settings>
4444
<servers>
4545
<server>
46+
<id>${id}</id>
4647
<username>${username}</username>
4748
<password>${password}</password>
4849
</server>

lib/setup-java.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ function run() {
2929
const arch = core.getInput('architecture', { required: true });
3030
const jdkFile = core.getInput('jdkFile', { required: false }) || '';
3131
yield installer.getJava(version, arch, jdkFile);
32-
const username = core.getInput('username', { required: false });
33-
const password = core.getInput('password', { required: false });
34-
yield auth.configAuthentication(username, password);
3532
const matchersPath = path.join(__dirname, '..', '.github');
3633
console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
34+
const id = core.getInput('id', { required: false });
35+
const username = core.getInput('username', { required: false });
36+
const password = core.getInput('password', { required: false });
37+
if (id && username && password) {
38+
yield auth.configAuthentication(id, username, password);
39+
}
3740
}
3841
catch (error) {
3942
core.setFailed(error.message);

src/auth.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import * as io from '@actions/io';
77
export const M2_DIR = '.m2';
88
export const SETTINGS_FILE = 'settings.xml';
99

10-
export async function configAuthentication(id: string, username: string, password: string) {
10+
export async function configAuthentication(
11+
id: string,
12+
username: string,
13+
password: string
14+
) {
1115
if (id && username && password) {
1216
core.debug(`configAuthentication with ${username} and a password`);
1317
const directory: string = path.join(os.homedir(), M2_DIR);

src/setup-java.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ async function run() {
2525
if (id && username && password) {
2626
await auth.configAuthentication(id, username, password);
2727
}
28-
2928
} catch (error) {
3029
core.setFailed(error.message);
3130
}

0 commit comments

Comments
 (0)