diff --git a/lib/auth.js b/lib/auth.js
index 33e643be..4bfc3c7c 100644
--- a/lib/auth.js
+++ b/lib/auth.js
@@ -18,30 +18,44 @@ Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const os = __importStar(require("os"));
const path = __importStar(require("path"));
+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) {
return __awaiter(this, void 0, void 0, function* () {
- const directory = path.join(os.homedir(), '.m2');
- yield io.mkdirP(directory);
- yield write(directory, generate(username, password));
+ if (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));
+ }
+ else {
+ core.debug(`no auth without username: ${username} and password: ${password}`);
+ }
});
}
exports.configAuthentication = configAuthentication;
// only exported for testing purposes
-function generate(username = '${actions.username}', password = '${actions.password}') {
- return `
-
-
- ${username}
- ${password}
-
-
-
- `;
+function generate(username, password) {
+ return `
+
+
+
+ ${username}
+ ${password}
+
+
+
+ `;
}
exports.generate = generate;
function write(directory, settings) {
return __awaiter(this, void 0, void 0, function* () {
- return fs.writeFileSync(path.join(directory, 'settings.xml'), settings);
+ const options = { encoding: 'utf-8' };
+ const location = path.join(directory, exports.SETTINGS_FILE);
+ core.debug(`writing ${location}`);
+ return fs.writeFileSync(location, settings, options);
});
}
diff --git a/lib/setup-java.js b/lib/setup-java.js
index 1028cf84..a000d4e6 100644
--- a/lib/setup-java.js
+++ b/lib/setup-java.js
@@ -31,9 +31,7 @@ function run() {
yield installer.getJava(version, arch, jdkFile);
const username = core.getInput('username', { required: false });
const password = core.getInput('password', { required: false });
- if (username && password) {
- yield auth.configAuthentication(username, password);
- }
+ yield auth.configAuthentication(username, password);
const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
}