Skip to content

Commit 0e61ae1

Browse files
authored
Merge branch 'master' into copilot/support-custom-gradle-build-directory
2 parents 75d32e2 + d6b3f0a commit 0e61ae1

2 files changed

Lines changed: 32 additions & 5 deletions

File tree

src/main/fish/payara/project/Maven.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,14 @@ export class Maven implements Build {
235235
}
236236

237237
public getBuildDir(): string {
238-
let targetDir = path.join(this.workspaceFolder.uri.fsPath, 'target');
238+
let buildDirValue = 'target';
239+
if (this.pomReader instanceof MavenPomReader) {
240+
let customDir = this.pomReader.getBuildDirectory();
241+
if (customDir.length > 0) {
242+
buildDirValue = customDir;
243+
}
244+
}
245+
let targetDir = path.resolve(this.workspaceFolder.uri.fsPath, buildDirValue);
239246
if (!fs.existsSync(targetDir)) {
240247
throw Error("no target dir found: " + targetDir);
241248
}

src/main/fish/payara/project/MavenPomReader.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class MavenPomReader implements BuildReader {
2929
private artifactId: string = '';
3030
private version: string = '';
3131
private finalName: string = '';
32+
private buildDirectory: string = '';
3233

3334
public constructor(public workspaceFolder: WorkspaceFolder) {
3435
this.parsePom();
@@ -54,14 +55,20 @@ export class MavenPomReader implements BuildReader {
5455
reader.groupId = project.groupId[0];
5556
reader.artifactId = project.artifactId[0];
5657
reader.version = project.version[0];
57-
reader.finalName = reader.parseBuild(project.build);
58+
reader.finalName = reader.parseFinalName(project.build);
59+
reader.buildDirectory = reader.parseBuildDirectory(project.build);
5860
if (project.profiles
5961
&& project.profiles[0].profile) {
6062
for (let profile of project.profiles[0].profile) {
61-
if (reader.finalName.length > 0) {
63+
if (reader.finalName.length > 0 && reader.buildDirectory.length > 0) {
6264
break;
6365
}
64-
reader.finalName = reader.parseBuild(profile.build);
66+
if (reader.finalName.length < 1) {
67+
reader.finalName = reader.parseFinalName(profile.build);
68+
}
69+
if (reader.buildDirectory.length < 1) {
70+
reader.buildDirectory = reader.parseBuildDirectory(profile.build);
71+
}
6572
}
6673
}
6774
if (reader.finalName.length < 1) {
@@ -73,7 +80,7 @@ export class MavenPomReader implements BuildReader {
7380
}
7481
}
7582

76-
private parseBuild(build: any): string {
83+
private parseFinalName(build: any): string {
7784
if (build
7885
&& build[0]
7986
&& build[0].finalName) {
@@ -82,6 +89,15 @@ export class MavenPomReader implements BuildReader {
8289
return '';
8390
}
8491

92+
private parseBuildDirectory(build: any): string {
93+
if (build
94+
&& build[0]
95+
&& build[0].directory) {
96+
return build[0].directory.toString();
97+
}
98+
return '';
99+
}
100+
85101
public getGroupId(): string {
86102
return this.groupId;
87103
}
@@ -98,4 +114,8 @@ export class MavenPomReader implements BuildReader {
98114
return this.finalName;
99115
}
100116

117+
public getBuildDirectory(): string {
118+
return this.buildDirectory;
119+
}
120+
101121
}

0 commit comments

Comments
 (0)