From dc5f78f54d4e2452492208bb2dd5164231dc2623 Mon Sep 17 00:00:00 2001
From: Bryan Clark <clarkbw@github.com>
Date: Thu, 28 Nov 2019 12:40:45 -0800
Subject: [PATCH] generated and pretty files

---
 lib/auth.js       | 9 +++++----
 lib/setup-java.js | 9 ++++++---
 src/auth.ts       | 6 +++++-
 src/setup-java.ts | 1 -
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/lib/auth.js b/lib/auth.js
index 4bfc3c7..9b03d1c 100644
--- a/lib/auth.js
+++ b/lib/auth.js
@@ -22,14 +22,14 @@ const core = __importStar(require("@actions/core"));
 const io = __importStar(require("@actions/io"));
 exports.M2_DIR = '.m2';
 exports.SETTINGS_FILE = 'settings.xml';
-function configAuthentication(username, password) {
+function configAuthentication(id, username, password) {
     return __awaiter(this, void 0, void 0, function* () {
-        if (username && password) {
+        if (id && username && password) {
             core.debug(`configAuthentication with ${username} and a password`);
             const directory = path.join(os.homedir(), exports.M2_DIR);
             yield io.mkdirP(directory);
             core.debug(`created directory ${directory}`);
-            yield write(directory, generate(username, password));
+            yield write(directory, generate(id, username, password));
         }
         else {
             core.debug(`no auth without username: ${username} and password: ${password}`);
@@ -38,11 +38,12 @@ function configAuthentication(username, password) {
 }
 exports.configAuthentication = configAuthentication;
 // only exported for testing purposes
-function generate(username, password) {
+function generate(id, username, password) {
     return `
   <settings>
       <servers>
         <server>
+          <id>${id}</id>
           <username>${username}</username>
           <password>${password}</password>
         </server>
diff --git a/lib/setup-java.js b/lib/setup-java.js
index a000d4e..ce1e376 100644
--- a/lib/setup-java.js
+++ b/lib/setup-java.js
@@ -29,11 +29,14 @@ function run() {
             const arch = core.getInput('architecture', { required: true });
             const jdkFile = core.getInput('jdkFile', { required: false }) || '';
             yield installer.getJava(version, arch, jdkFile);
-            const username = core.getInput('username', { required: false });
-            const password = core.getInput('password', { required: false });
-            yield auth.configAuthentication(username, password);
             const matchersPath = path.join(__dirname, '..', '.github');
             console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
+            const id = core.getInput('id', { required: false });
+            const username = core.getInput('username', { required: false });
+            const password = core.getInput('password', { required: false });
+            if (id && username && password) {
+                yield auth.configAuthentication(id, username, password);
+            }
         }
         catch (error) {
             core.setFailed(error.message);
diff --git a/src/auth.ts b/src/auth.ts
index d3c13bc..4979045 100644
--- a/src/auth.ts
+++ b/src/auth.ts
@@ -7,7 +7,11 @@ import * as io from '@actions/io';
 export const M2_DIR = '.m2';
 export const SETTINGS_FILE = 'settings.xml';
 
-export async function configAuthentication(id: string, username: string, password: string) {
+export async function configAuthentication(
+  id: string,
+  username: string,
+  password: string
+) {
   if (id && username && password) {
     core.debug(`configAuthentication with ${username} and a password`);
     const directory: string = path.join(os.homedir(), M2_DIR);
diff --git a/src/setup-java.ts b/src/setup-java.ts
index 2a73116..39f5466 100644
--- a/src/setup-java.ts
+++ b/src/setup-java.ts
@@ -25,7 +25,6 @@ async function run() {
     if (id && username && password) {
       await auth.configAuthentication(id, username, password);
     }
-
   } catch (error) {
     core.setFailed(error.message);
   }