diff --git a/action.yml b/action.yml index faade0b..18d07bb 100644 --- a/action.yml +++ b/action.yml @@ -30,6 +30,15 @@ inputs: description: 'A boolean value ("true" or "false") on whether the personalRepo should be used.' required: false default: false + openj9Repo: + description: 'openj9 Repo, example: eclipse-openj9/openj9:master' + required: false + openj9-omrRepo: + description: 'openj9-omr Repo, example: eclipse-openj9/openj9-omr:openj9' + required: false + openj9-openjdkRepo: + description: 'ibmruntimes extension Repo, example: ibmruntimes/openj9-openjdk-jdk11:openj9 ' + required: false outputs: BuildJDKDir: description: 'build jdk images directory' diff --git a/dist/index.js b/dist/index.js index e8e9361..7f982ac 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3335,14 +3335,14 @@ if (!tempDirectory) { } tempDirectory = path.join(baseLocation, 'actions', 'temp'); } -function buildJDK(version, usePersonalRepo) { +function buildJDK(version, usePersonalRepo, specifiedReposMap) { return __awaiter(this, void 0, void 0, function* () { const openj9Version = `openj9-openjdk-jdk${version}`; yield installDependencies(version); process.chdir(`${workDir}`); yield getBootJdk(version); process.chdir(`${workDir}`); - yield getSource(openj9Version, usePersonalRepo); + yield getSource(openj9Version, usePersonalRepo, specifiedReposMap); yield setConfigure(version, openj9Version); yield exec.exec(`make all`); yield printJavaVersion(version, openj9Version); @@ -3526,7 +3526,7 @@ function getBootJdk(version) { } }); } -function getSource(openj9Version, usePersonalRepo) { +function getSource(openj9Version, usePersonalRepo, specifiedReposMap) { return __awaiter(this, void 0, void 0, function* () { let openjdkOpenj9Repo = `ibmruntimes/${openj9Version}`; let openjdkOpenj9Branch = 'openj9'; @@ -3557,7 +3557,31 @@ function getSource(openj9Version, usePersonalRepo) { openj9Branch = branch; } else { - core.error(`${repo} is not one of openj9-openjdk-jdk8|11|12..., openj9, omr`); + //parsing personal openj9Repo, openj9 Repo, openj9-omrRepo openj9-openjdkRepo' + for (let [key, value] of specifiedReposMap) { + const personalRepo = parseRepoBranch(value)[0]; + const personalBranch = parseRepoBranch(value)[1]; + switch (key) { + case "openj9Repo": { + openj9Repo = personalRepo; + openj9Branch = personalBranch; + break; + } + case "openj9-omrRepo": { + omrRepo = personalRepo; + omrBranch = personalBranch; + break; + } + case "openj9-openjdkRepo": { + openjdkOpenj9Repo = personalRepo; + openjdkOpenj9Branch = personalBranch; + } + default: { + //statements; + break; + } + } + } } } yield exec.exec(`git clone -b ${openjdkOpenj9Branch} https://github.com/${openjdkOpenj9Repo}.git`); @@ -3669,6 +3693,10 @@ function getOsVersion() { return osVersion; }); } +function parseRepoBranch(repoBranch) { + const tempRepo = repoBranch.replace(/\s/g, ''); + return tempRepo.split(':'); +} /***/ }), @@ -4768,13 +4796,18 @@ function run() { return __awaiter(this, void 0, void 0, function* () { try { const version = core.getInput('version', { required: false }); - const repository = core.getInput('repository', { required: false }); - const ref = core.getInput('ref', { required: false }); const usePersonalRepo = core.getInput('usePersonalRepo') === 'true'; - if (repository.length === 0 && ref.length !== 0) { - core.error(`Please give repository name`); + let specifiedReposMap = new Map(); + if (usePersonalRepo) { + const repos = ['openj9Repo', 'openj9-omrRepo', 'openj9-openjdkRepo']; + for (let repo of repos) { + const tempRepo = core.getInput(repo, { required: false }); + if (tempRepo.length !== 0) { + specifiedReposMap.set(repo, tempRepo); + } + } } - yield builder.buildJDK(version, usePersonalRepo); + yield builder.buildJDK(version, usePersonalRepo, specifiedReposMap); } catch (error) { core.setFailed(error.message); diff --git a/src/build-openj9.ts b/src/build-openj9.ts index a71395a..899b1ac 100644 --- a/src/build-openj9.ts +++ b/src/build-openj9.ts @@ -25,13 +25,18 @@ import * as builder from './builder' async function run(): Promise { try { const version = core.getInput('version', {required: false}) - const repository = core.getInput('repository', {required: false}) - const ref = core.getInput('ref', {required: false}) const usePersonalRepo = core.getInput('usePersonalRepo') === 'true' - if (repository.length === 0 && ref.length !== 0) { - core.error(`Please give repository name`) + let specifiedReposMap = new Map() + if (usePersonalRepo) { + const repos: string[] = ['openj9Repo', 'openj9-omrRepo', 'openj9-openjdkRepo'] + for (let repo of repos) { + const tempRepo = core.getInput(repo, { required: false }) + if (tempRepo.length !== 0) { + specifiedReposMap.set(repo, tempRepo) + } + } } - await builder.buildJDK(version, usePersonalRepo) + await builder.buildJDK(version, usePersonalRepo, specifiedReposMap) } catch (error) { core.setFailed(error.message) } diff --git a/src/builder.ts b/src/builder.ts index 86e7120..d50e3c4 100644 --- a/src/builder.ts +++ b/src/builder.ts @@ -48,14 +48,15 @@ if (!tempDirectory) { export async function buildJDK( version: string, - usePersonalRepo: boolean + usePersonalRepo: boolean, + specifiedReposMap: Map ): Promise { const openj9Version = `openj9-openjdk-jdk${version}` await installDependencies(version) process.chdir(`${workDir}`) await getBootJdk(version) process.chdir(`${workDir}`) - await getSource(openj9Version, usePersonalRepo) + await getSource(openj9Version, usePersonalRepo, specifiedReposMap) await setConfigure(version, openj9Version) await exec.exec(`make all`) await printJavaVersion(version, openj9Version) @@ -249,7 +250,8 @@ async function getBootJdk(version: string): Promise { async function getSource( openj9Version: string, - usePersonalRepo: boolean + usePersonalRepo: boolean, + specifiedReposMap: Map ): Promise { let openjdkOpenj9Repo = `ibmruntimes/${openj9Version}` let openjdkOpenj9Branch = 'openj9' @@ -277,7 +279,31 @@ async function getSource( openj9Repo = repo openj9Branch = branch } else { - core.error(`${repo} is not one of openj9-openjdk-jdk8|11|12..., openj9, omr`) + //parsing personal openj9Repo, openj9 Repo, openj9-omrRepo openj9-openjdkRepo' + for (let [key, value] of specifiedReposMap) { + const personalRepo = parseRepoBranch(value)[0] + const personalBranch = parseRepoBranch(value)[1] + switch(key) { + case "openj9Repo": { + openj9Repo = personalRepo + openj9Branch = personalBranch + break; + } + case "openj9-omrRepo": { + omrRepo = personalRepo + omrBranch = personalBranch + break; + } + case "openj9-openjdkRepo": { + openjdkOpenj9Repo = personalRepo + openjdkOpenj9Branch = personalBranch + } + default: { + //statements; + break; + } + } + } } } @@ -384,3 +410,8 @@ async function getOsVersion(): Promise { } return osVersion } + +function parseRepoBranch(repoBranch: string): string[] { + const tempRepo = repoBranch.replace(/\s/g, '') + return tempRepo.split(':') +} \ No newline at end of file