Skip to content

Commit

Permalink
feat(common): allow using legacy wrappers (i.e .bat, for maven mostly)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinesoft committed Jul 3, 2022
1 parent f426575 commit 7a13720
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/common/src/lib/core/jvm/builder-core.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface BuilderCommandAliasMapper {
export interface BuilderCore {
getBuildSystemType();

getExecutable(ignoreWrapper: boolean);
getExecutable(ignoreWrapper: boolean, useLegacyWrapper: boolean);

getCommand(alias: BuilderCommandAliasType): string;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/lib/core/jvm/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export const GRADLE_EXECUTABLE = 'gradle';

export const MAVEN_WRAPPER_EXECUTABLE = IS_WINDOWS ? 'mvnw.cmd' : './mvnw';

// previous versions of the wrapper were using '.bat' extension for Windows executable
export const MAVEN_WRAPPER_EXECUTABLE_LEGACY = IS_WINDOWS ? 'mvnw.bat' : './mvnw';

export const GRADLE_WRAPPER_EXECUTABLE = IS_WINDOWS
? 'gradlew.bat'
: './gradlew';
2 changes: 1 addition & 1 deletion packages/common/src/lib/core/jvm/gradle-builder.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class GradleBuilder implements BuilderCore {
return BuildSystem.GRADLE;
}

getExecutable(ignoreWrapper: boolean) {
getExecutable(ignoreWrapper: boolean, useLegacyWrapper = false) {
return ignoreWrapper ? GRADLE_EXECUTABLE : GRADLE_WRAPPER_EXECUTABLE;
}

Expand Down
9 changes: 6 additions & 3 deletions packages/common/src/lib/core/jvm/maven-builder.class.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MAVEN_EXECUTABLE, MAVEN_WRAPPER_EXECUTABLE } from './constants';
import { MAVEN_EXECUTABLE, MAVEN_WRAPPER_EXECUTABLE, MAVEN_WRAPPER_EXECUTABLE_LEGACY } from './constants';
import {
BuilderCommandAliasMapper,
BuilderCommandAliasType,
Expand All @@ -13,8 +13,11 @@ export class MavenBuilder implements BuilderCore {
return BuildSystem.MAVEN;
}

getExecutable(ignoreWrapper: boolean) {
return ignoreWrapper ? MAVEN_EXECUTABLE : MAVEN_WRAPPER_EXECUTABLE;
getExecutable(ignoreWrapper: boolean, useLegacyWrapper = false) {
if(ignoreWrapper)
return MAVEN_EXECUTABLE;
else
return useLegacyWrapper ? MAVEN_WRAPPER_EXECUTABLE_LEGACY : MAVEN_WRAPPER_EXECUTABLE;
}

getCommand(alias: BuilderCommandAliasType) {
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/lib/core/jvm/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export function runBuilderCommand(
commandAlias: BuilderCommandAliasType,
getBuilder : (cwd: string) => BuilderCore,
params: string[],
options: { cwd?: string; ignoreWrapper?: boolean } = { ignoreWrapper: false }
options: { cwd?: string; ignoreWrapper?: boolean, useLegacyWrapper?: boolean } = { ignoreWrapper: false, useLegacyWrapper: false }
): { success: boolean } {
// Take the parameters or set defaults
const cwd = options.cwd || process.cwd();
const buildSystem = getBuilder(cwd);
const executable = buildSystem.getExecutable(options.ignoreWrapper);
const executable = buildSystem.getExecutable(options.ignoreWrapper, options.useLegacyWrapper);
const command = buildSystem.getCommand(commandAlias);
// Create the command to execute
const execute = `${executable} ${command} ${(params || []).join(' ')}`;
Expand Down

0 comments on commit 7a13720

Please sign in to comment.