Skip to content

Commit cacc90d

Browse files
committed
Refactor Maven command construction in Java SDK utilities
1 parent 7566b37 commit cacc90d

File tree

1 file changed

+18
-12
lines changed
  • src/tools/appautomate-utils/appium-sdk/languages

1 file changed

+18
-12
lines changed

src/tools/appautomate-utils/appium-sdk/languages/java.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function getMavenCommandForWindows(
7878
accessKey: string,
7979
appPath?: string,
8080
): string {
81-
let command = (
81+
let command =
8282
`mvn archetype:generate -B ` +
8383
`-DarchetypeGroupId="${MAVEN_ARCHETYPE_GROUP_ID}" ` +
8484
`-DarchetypeArtifactId="${mavenFramework}" ` +
@@ -87,8 +87,7 @@ function getMavenCommandForWindows(
8787
`-DartifactId="${mavenFramework}" ` +
8888
`-Dversion="${version}" ` +
8989
`-DBROWSERSTACK_USERNAME="${username}" ` +
90-
`-DBROWSERSTACK_ACCESS_KEY="${accessKey}"`
91-
);
90+
`-DBROWSERSTACK_ACCESS_KEY="${accessKey}"`;
9291

9392
// Add framework parameter for browserstack-sdk-archetype-integrate
9493
if (mavenFramework === "browserstack-sdk-archetype-integrate") {
@@ -111,7 +110,7 @@ function getMavenCommandForUnix(
111110
accessKey: string,
112111
appPath?: string,
113112
): string {
114-
let command = (
113+
let command =
115114
`mvn archetype:generate -B ` +
116115
`-DarchetypeGroupId="${MAVEN_ARCHETYPE_GROUP_ID}" ` +
117116
`-DarchetypeArtifactId="${mavenFramework}" ` +
@@ -120,8 +119,7 @@ function getMavenCommandForUnix(
120119
`-DartifactId="${mavenFramework}" ` +
121120
`-Dversion="${version}" ` +
122121
`-DBROWSERSTACK_USERNAME="${username}" ` +
123-
`-DBROWSERSTACK_ACCESS_KEY="${accessKey}"`
124-
);
122+
`-DBROWSERSTACK_ACCESS_KEY="${accessKey}"`;
125123

126124
// Add framework parameter for browserstack-sdk-archetype-integrate
127125
if (mavenFramework === "browserstack-sdk-archetype-integrate") {
@@ -179,13 +177,21 @@ export function getJavaSDKCommand(
179177
const mavenStep = createStep(
180178
"Install BrowserStack SDK using Maven Archetype for App Automate",
181179
`Maven command for ${framework} (${getPlatformLabel()}):
182-
\`\`\`bash
183-
${mavenCommand}
184-
\`\`\`
180+
\`\`\`bash
181+
${mavenCommand}
182+
\`\`\`
183+
184+
Alternative setup for Gradle users:
185+
${GRADLE_APP_SETUP_INSTRUCTIONS}`,
186+
);
185187

186-
Alternative setup for Gradle users:
187-
${GRADLE_APP_SETUP_INSTRUCTIONS}`,
188+
const argsLineStep = createStep(
189+
"Verifying dependency and argsLine",
190+
`Verify browserstack-java-sdk with LATEST is added as dependency and add this line in pom.xml if not added:
191+
\`\`\`xml
192+
<argLine>-javaagent:"\${com.browserstack:browserstack-java-sdk:jar}"</argLine>
193+
\`\`\``,
188194
);
189195

190-
return combineInstructions(envStep, mavenStep);
196+
return combineInstructions(envStep, mavenStep, argsLineStep);
191197
}

0 commit comments

Comments
 (0)