introduce options to choose a bundle strategy

Pick from 'none', 'keycloakify' or 'mvn', default to 'mvn'. 'none' will
not create a jar, 'keycloakify' will create a jar file using only tools
available to native nodejs, no additional  system library required.
Choosing 'mvn' will behave as before, starting maven in a subprocess.

The bundler can be chosen in `package.json` or via `KEYCLOAKIFY_BUNDLER`
env var.

This commit also adds `KEYCLOAKIFY_GROUP_ID` and
`KEYCLOAKIFY_ARTIFACT_ID` env vars, which will be used to
define group id and artifact id in pom.xml and pom.properties, if given.
This commit is contained in:
Waldemar Reusch
2023-02-03 14:28:06 +01:00
parent 2b87c35058
commit f4a547df11
3 changed files with 44 additions and 17 deletions

View File

@ -7,6 +7,7 @@ import * as fs from "fs";
import { readBuildOptions } from "./BuildOptions";
import { getLogger } from "../tools/logger";
import { getCliOptions } from "../tools/cliOptions";
import jar from "../tools/jar";
const reactProjectDirPath = process.cwd();
@ -45,17 +46,30 @@ export async function main() {
});
const { jarFilePath } = generateJavaStackFiles({
"version": buildOptions.version,
keycloakThemeBuildingDirPath,
doBundlesEmailTemplate,
buildOptions
});
child_process.execSync("mvn package", {
"cwd": keycloakThemeBuildingDirPath
});
if (buildOptions.bundler === "none") {
logger.log("😱 Skipping bundling step, there will be no jar");
} else if (buildOptions.bundler === "keycloakify") {
logger.log("🫶 Let keycloakify do its thang");
await jar({
"rootPath": keycloakThemeBuildingDirPath,
"version": buildOptions.version,
"groupId": buildOptions.groupId,
"artifactId": buildOptions.artifactId || `${buildOptions.themeName}-keycloak-theme`,
"targetPath": jarFilePath
});
} else {
logger.log("🫙 Run maven to deliver a jar");
child_process.execSync("mvn package", {
"cwd": keycloakThemeBuildingDirPath
});
}
//We want, however, to test in a container running the latest Keycloak version
// We want, however, to test in a container running the latest Keycloak version
const containerKeycloakVersion = "20.0.1";
generateStartKeycloakTestingContainer({