Skip to content

Commit

Permalink
fix(common-jvm): improve the check for presence of Maven Wrapper nece…
Browse files Browse the repository at this point in the history
…ssary files

The check was too strict and would not consider Maven Wrapper to be present if some optional files were missing
  • Loading branch information
tinesoft committed Jul 19, 2024
1 parent 9a73a73 commit 4020539
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
1 change: 0 additions & 1 deletion packages/common-jvm/src/lib/utils/maven-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,6 @@ function hasMavenWrapperWithPredicate(predicate: (file: string) => boolean) {
) &&
['mvnw.bat', 'mvnw.cmd'].some((file) => predicate(file)) &&
[
'.mvn/wrapper/MavenWrapperDownloader.class',
'.mvn/wrapper/MavenWrapperDownloader.java',
'.mvn/wrapper/maven-wrapper.jar',
].some((file) => predicate(file))
Expand Down
19 changes: 10 additions & 9 deletions packages/common-jvm/src/lib/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
getGradleModules,
hasGradleModule,
} from './gradle-utils';
import { dirname, relative } from 'path';
import { dirname, relative, resolve } from 'path';

export const LARGE_BUFFER = 1024 * 1000000;

Expand Down Expand Up @@ -85,7 +85,7 @@ export function isMavenProjectInTree(tree: Tree, rootFolder: string) {
}

export function hasMavenProject(cwd: string) {
return fileExists(`${cwd}/pom.xml`);
return fileExists(resolve(cwd, 'pom.xml'));
}

export function isGradleProject(project: { root: string }) {
Expand Down Expand Up @@ -115,23 +115,24 @@ export function isGradleProjectSettingsInTree(tree: Tree, rootFolder: string) {

export function hasGradleProject(cwd: string) {
return (
fileExists(`${cwd}/build.gradle`) ||
fileExists(`${cwd}/settings.gradle`) ||
fileExists(`${cwd}/build.gradle.kts`) ||
fileExists(`${cwd}/settings.gradle.kts`)
fileExists(resolve(cwd, 'build.gradle')) ||
fileExists(resolve(cwd, 'settings.gradle')) ||
fileExists(resolve(cwd, 'build.gradle.kts')) ||
fileExists(resolve(cwd, 'settings.gradle.kts'))
);
}

export function hasGradleSettingsFile(cwd: string) {
return (
fileExists(`${cwd}/settings.gradle`) ||
fileExists(`${cwd}/settings.gradle.kts`)
fileExists(resolve(cwd, 'settings.gradle')) ||
fileExists(resolve(cwd, 'settings.gradle.kts'))
);
}

export function hasGradleBuildFile(cwd: string) {
return (
fileExists(`${cwd}/build.gradle`) || fileExists(`${cwd}/build.gradle.kts`)
fileExists(resolve(cwd, 'build.gradle')) ||
fileExists(resolve(cwd, 'build.gradle.kts'))
);
}

Expand Down

0 comments on commit 4020539

Please sign in to comment.