Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: don't explicitly pass through sdk info, let user app.gradle…
… handle it
  • Loading branch information
rigor789 authored and NathanWalker committed May 31, 2024
commit 7e444f8bbafea15dfd7da3d7c90117124a95fdf6
16 changes: 0 additions & 16 deletions lib/services/android-plugin-build-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { Builder, parseString } from "xml2js";
import {
IRuntimeGradleVersions,
INodePackageManager,
IAndroidToolsInfo,
IWatchIgnoreListService,
} from "../declarations";
import { IPlatformsDataService } from "../definitions/platform";
Expand Down Expand Up @@ -47,7 +46,6 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
private $fs: IFileSystem,
private $childProcess: IChildProcess,
private $hostInfo: IHostInfo,
private $androidToolsInfo: IAndroidToolsInfo,
private $logger: ILogger,
private $packageManager: INodePackageManager,
private $projectData: IProjectData,
Expand Down Expand Up @@ -802,18 +800,6 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
private async buildPlugin(
pluginBuildSettings: IBuildAndroidPluginData
): Promise<void> {
if (!pluginBuildSettings.androidToolsInfo) {
this.$androidToolsInfo.validateInfo({
showWarningsAsErrors: true,
validateTargetSdk: true,
projectDir: pluginBuildSettings.projectDir,
});
pluginBuildSettings.androidToolsInfo =
this.$androidToolsInfo.getToolsInfo({
projectDir: pluginBuildSettings.projectDir,
});
}

const gradlew =
pluginBuildSettings.gradlePath ??
(this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew");
Expand All @@ -823,8 +809,6 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
pluginBuildSettings.pluginDir,
"assembleRelease",
`-PtempBuild=true`,
`-PcompileSdk=android-${pluginBuildSettings.androidToolsInfo.compileSdkVersion}`,
`-PbuildToolsVersion=${pluginBuildSettings.androidToolsInfo.buildToolsVersion}`,
`-PappPath=${this.$projectData.getAppDirectoryPath()}`,
`-PappResourcesPath=${this.$projectData.getAppResourcesDirectoryPath()}`,
];
Expand Down
10 changes: 0 additions & 10 deletions lib/services/android/gradle-build-args-service.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import * as path from "path";
import { Configurations } from "../../common/constants";
import { IGradleBuildArgsService } from "../../definitions/gradle";
import { IAndroidToolsInfo } from "../../declarations";
import { IAndroidBuildData } from "../../definitions/build";
import { IHooksService, IAnalyticsService } from "../../common/declarations";
import { injector } from "../../common/yok";
import { IProjectData } from "../../definitions/project";

export class GradleBuildArgsService implements IGradleBuildArgsService {
constructor(
private $androidToolsInfo: IAndroidToolsInfo,
private $hooksService: IHooksService,
private $analyticsService: IAnalyticsService,
private $staticConfig: Config.IStaticConfig,
Expand Down Expand Up @@ -49,18 +47,10 @@ export class GradleBuildArgsService implements IGradleBuildArgsService {
private getBaseTaskArgs(buildData: IAndroidBuildData): string[] {
const args = this.getBuildLoggingArgs();

const toolsInfo = this.$androidToolsInfo.getToolsInfo({
projectDir: buildData.projectDir,
});

// ensure we initialize project data
this.$projectData.initializeProjectData(buildData.projectDir);

args.push(
`-PcompileSdk=android-${toolsInfo.compileSdkVersion}`,
`-PtargetSdk=${toolsInfo.targetSdkVersion}`,
`-PbuildToolsVersion=${toolsInfo.buildToolsVersion}`,
`-PgenerateTypings=${toolsInfo.generateTypings}`,
`-PappPath=${this.$projectData.getAppDirectoryPath()}`,
`-PappResourcesPath=${this.$projectData.getAppResourcesDirectoryPath()}`
);
Expand Down
34 changes: 10 additions & 24 deletions test/services/android/gradle-build-args-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ const ksPath = temp.path({ prefix: "ksPath" });
const expectedInfoLoggingArgs = ["--quiet"];
const expectedTraceLoggingArgs = ["--stacktrace", "--debug"];
const expectedDebugBuildArgs = [
"-PcompileSdk=android-28",
"-PtargetSdk=26",
"-PbuildToolsVersion=my-build-tools-version",
"-PgenerateTypings=true",
"-PappPath=/path/to/projectDir/app".replace(/\//g, path.sep),
"-PappResourcesPath=/path/to/projectDir/app/App_Resources".replace(
/\//g,
Expand Down Expand Up @@ -124,35 +120,31 @@ describe("GradleBuildArgsService", () => {
.concat(expectedReleaseBuildArgs),
},
{
name:
"should return correct args for debug build with info log and android bundle",
name: "should return correct args for debug build with info log and android bundle",
buildConfig: { release: false, androidBundle: true },
logLevel: "INFO",
expectedResult: ["bundleDebug"]
.concat(expectedInfoLoggingArgs)
.concat(expectedDebugBuildArgs),
},
{
name:
"should return correct args for debug build with trace log and android bundle",
name: "should return correct args for debug build with trace log and android bundle",
buildConfig: { release: false, androidBundle: true },
logLevel: "TRACE",
expectedResult: ["bundleDebug"]
.concat(expectedTraceLoggingArgs)
.concat(expectedDebugBuildArgs),
},
{
name:
"should return correct args for release build with info log and android bundle",
name: "should return correct args for release build with info log and android bundle",
buildConfig: { ...releaseBuildConfig, androidBundle: true },
logLevel: "INFO",
expectedResult: ["bundleRelease"]
.concat(expectedInfoLoggingArgs)
.concat(expectedReleaseBuildArgs),
},
{
name:
"should return correct args for release build with trace log and android bundle",
name: "should return correct args for release build with trace log and android bundle",
buildConfig: { ...releaseBuildConfig, androidBundle: true },
logLevel: "TRACE",
expectedResult: ["bundleRelease"]
Expand Down Expand Up @@ -189,53 +181,47 @@ describe("GradleBuildArgsService", () => {
.concat(expectedDebugBuildArgs),
},
{
name:
"should return correct args for release clean build with info log",
name: "should return correct args for release clean build with info log",
buildConfig: releaseBuildConfig,
logLevel: "INFO",
expectedResult: ["clean"]
.concat(expectedInfoLoggingArgs)
.concat(expectedReleaseBuildArgs),
},
{
name:
"should return correct args for release clean build with trace log",
name: "should return correct args for release clean build with trace log",
buildConfig: releaseBuildConfig,
logLevel: "TRACE",
expectedResult: ["clean"]
.concat(expectedTraceLoggingArgs)
.concat(expectedReleaseBuildArgs),
},
{
name:
"should return correct args for debug clean build with info log and android bundle",
name: "should return correct args for debug clean build with info log and android bundle",
buildConfig: { release: false, androidBundle: true },
logLevel: "INFO",
expectedResult: ["clean"]
.concat(expectedInfoLoggingArgs)
.concat(expectedDebugBuildArgs),
},
{
name:
"should return correct args for debug clean build with trace log and android bundle",
name: "should return correct args for debug clean build with trace log and android bundle",
buildConfig: { release: false, androidBundle: true },
logLevel: "TRACE",
expectedResult: ["clean"]
.concat(expectedTraceLoggingArgs)
.concat(expectedDebugBuildArgs),
},
{
name:
"should return correct args for release clean build with info log and android bundle",
name: "should return correct args for release clean build with info log and android bundle",
buildConfig: { ...releaseBuildConfig, androidBundle: true },
logLevel: "INFO",
expectedResult: ["clean"]
.concat(expectedInfoLoggingArgs)
.concat(expectedReleaseBuildArgs),
},
{
name:
"should return correct args for release clean build with trace log and android bundle",
name: "should return correct args for release clean build with trace log and android bundle",
buildConfig: { ...releaseBuildConfig, androidBundle: true },
logLevel: "TRACE",
expectedResult: ["clean"]
Expand Down