Skip to content

Commit 5fdc2a9

Browse files
committed
refactor: don't explicitly pass through sdk info, let user app.gradle handle it
1 parent 5797d0b commit 5fdc2a9

File tree

3 files changed

+10
-50
lines changed

3 files changed

+10
-50
lines changed

lib/services/android-plugin-build-service.ts

-16
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { Builder, parseString } from "xml2js";
1313
import {
1414
IRuntimeGradleVersions,
1515
INodePackageManager,
16-
IAndroidToolsInfo,
1716
IWatchIgnoreListService,
1817
} from "../declarations";
1918
import { IPlatformsDataService } from "../definitions/platform";
@@ -47,7 +46,6 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
4746
private $fs: IFileSystem,
4847
private $childProcess: IChildProcess,
4948
private $hostInfo: IHostInfo,
50-
private $androidToolsInfo: IAndroidToolsInfo,
5149
private $logger: ILogger,
5250
private $packageManager: INodePackageManager,
5351
private $projectData: IProjectData,
@@ -802,18 +800,6 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
802800
private async buildPlugin(
803801
pluginBuildSettings: IBuildAndroidPluginData
804802
): Promise<void> {
805-
if (!pluginBuildSettings.androidToolsInfo) {
806-
this.$androidToolsInfo.validateInfo({
807-
showWarningsAsErrors: true,
808-
validateTargetSdk: true,
809-
projectDir: pluginBuildSettings.projectDir,
810-
});
811-
pluginBuildSettings.androidToolsInfo =
812-
this.$androidToolsInfo.getToolsInfo({
813-
projectDir: pluginBuildSettings.projectDir,
814-
});
815-
}
816-
817803
const gradlew =
818804
pluginBuildSettings.gradlePath ??
819805
(this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew");
@@ -823,8 +809,6 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
823809
pluginBuildSettings.pluginDir,
824810
"assembleRelease",
825811
`-PtempBuild=true`,
826-
`-PcompileSdk=android-${pluginBuildSettings.androidToolsInfo.compileSdkVersion}`,
827-
`-PbuildToolsVersion=${pluginBuildSettings.androidToolsInfo.buildToolsVersion}`,
828812
`-PappPath=${this.$projectData.getAppDirectoryPath()}`,
829813
`-PappResourcesPath=${this.$projectData.getAppResourcesDirectoryPath()}`,
830814
];

lib/services/android/gradle-build-args-service.ts

-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import * as path from "path";
22
import { Configurations } from "../../common/constants";
33
import { IGradleBuildArgsService } from "../../definitions/gradle";
4-
import { IAndroidToolsInfo } from "../../declarations";
54
import { IAndroidBuildData } from "../../definitions/build";
65
import { IHooksService, IAnalyticsService } from "../../common/declarations";
76
import { injector } from "../../common/yok";
87
import { IProjectData } from "../../definitions/project";
98

109
export class GradleBuildArgsService implements IGradleBuildArgsService {
1110
constructor(
12-
private $androidToolsInfo: IAndroidToolsInfo,
1311
private $hooksService: IHooksService,
1412
private $analyticsService: IAnalyticsService,
1513
private $staticConfig: Config.IStaticConfig,
@@ -49,18 +47,10 @@ export class GradleBuildArgsService implements IGradleBuildArgsService {
4947
private getBaseTaskArgs(buildData: IAndroidBuildData): string[] {
5048
const args = this.getBuildLoggingArgs();
5149

52-
const toolsInfo = this.$androidToolsInfo.getToolsInfo({
53-
projectDir: buildData.projectDir,
54-
});
55-
5650
// ensure we initialize project data
5751
this.$projectData.initializeProjectData(buildData.projectDir);
5852

5953
args.push(
60-
`-PcompileSdk=android-${toolsInfo.compileSdkVersion}`,
61-
`-PtargetSdk=${toolsInfo.targetSdkVersion}`,
62-
`-PbuildToolsVersion=${toolsInfo.buildToolsVersion}`,
63-
`-PgenerateTypings=${toolsInfo.generateTypings}`,
6454
`-PappPath=${this.$projectData.getAppDirectoryPath()}`,
6555
`-PappResourcesPath=${this.$projectData.getAppResourcesDirectoryPath()}`
6656
);

test/services/android/gradle-build-args-service.ts

+10-24
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ const ksPath = temp.path({ prefix: "ksPath" });
6262
const expectedInfoLoggingArgs = ["--quiet"];
6363
const expectedTraceLoggingArgs = ["--stacktrace", "--debug"];
6464
const expectedDebugBuildArgs = [
65-
"-PcompileSdk=android-28",
66-
"-PtargetSdk=26",
67-
"-PbuildToolsVersion=my-build-tools-version",
68-
"-PgenerateTypings=true",
6965
"-PappPath=/path/to/projectDir/app".replace(/\//g, path.sep),
7066
"-PappResourcesPath=/path/to/projectDir/app/App_Resources".replace(
7167
/\//g,
@@ -124,35 +120,31 @@ describe("GradleBuildArgsService", () => {
124120
.concat(expectedReleaseBuildArgs),
125121
},
126122
{
127-
name:
128-
"should return correct args for debug build with info log and android bundle",
123+
name: "should return correct args for debug build with info log and android bundle",
129124
buildConfig: { release: false, androidBundle: true },
130125
logLevel: "INFO",
131126
expectedResult: ["bundleDebug"]
132127
.concat(expectedInfoLoggingArgs)
133128
.concat(expectedDebugBuildArgs),
134129
},
135130
{
136-
name:
137-
"should return correct args for debug build with trace log and android bundle",
131+
name: "should return correct args for debug build with trace log and android bundle",
138132
buildConfig: { release: false, androidBundle: true },
139133
logLevel: "TRACE",
140134
expectedResult: ["bundleDebug"]
141135
.concat(expectedTraceLoggingArgs)
142136
.concat(expectedDebugBuildArgs),
143137
},
144138
{
145-
name:
146-
"should return correct args for release build with info log and android bundle",
139+
name: "should return correct args for release build with info log and android bundle",
147140
buildConfig: { ...releaseBuildConfig, androidBundle: true },
148141
logLevel: "INFO",
149142
expectedResult: ["bundleRelease"]
150143
.concat(expectedInfoLoggingArgs)
151144
.concat(expectedReleaseBuildArgs),
152145
},
153146
{
154-
name:
155-
"should return correct args for release build with trace log and android bundle",
147+
name: "should return correct args for release build with trace log and android bundle",
156148
buildConfig: { ...releaseBuildConfig, androidBundle: true },
157149
logLevel: "TRACE",
158150
expectedResult: ["bundleRelease"]
@@ -189,53 +181,47 @@ describe("GradleBuildArgsService", () => {
189181
.concat(expectedDebugBuildArgs),
190182
},
191183
{
192-
name:
193-
"should return correct args for release clean build with info log",
184+
name: "should return correct args for release clean build with info log",
194185
buildConfig: releaseBuildConfig,
195186
logLevel: "INFO",
196187
expectedResult: ["clean"]
197188
.concat(expectedInfoLoggingArgs)
198189
.concat(expectedReleaseBuildArgs),
199190
},
200191
{
201-
name:
202-
"should return correct args for release clean build with trace log",
192+
name: "should return correct args for release clean build with trace log",
203193
buildConfig: releaseBuildConfig,
204194
logLevel: "TRACE",
205195
expectedResult: ["clean"]
206196
.concat(expectedTraceLoggingArgs)
207197
.concat(expectedReleaseBuildArgs),
208198
},
209199
{
210-
name:
211-
"should return correct args for debug clean build with info log and android bundle",
200+
name: "should return correct args for debug clean build with info log and android bundle",
212201
buildConfig: { release: false, androidBundle: true },
213202
logLevel: "INFO",
214203
expectedResult: ["clean"]
215204
.concat(expectedInfoLoggingArgs)
216205
.concat(expectedDebugBuildArgs),
217206
},
218207
{
219-
name:
220-
"should return correct args for debug clean build with trace log and android bundle",
208+
name: "should return correct args for debug clean build with trace log and android bundle",
221209
buildConfig: { release: false, androidBundle: true },
222210
logLevel: "TRACE",
223211
expectedResult: ["clean"]
224212
.concat(expectedTraceLoggingArgs)
225213
.concat(expectedDebugBuildArgs),
226214
},
227215
{
228-
name:
229-
"should return correct args for release clean build with info log and android bundle",
216+
name: "should return correct args for release clean build with info log and android bundle",
230217
buildConfig: { ...releaseBuildConfig, androidBundle: true },
231218
logLevel: "INFO",
232219
expectedResult: ["clean"]
233220
.concat(expectedInfoLoggingArgs)
234221
.concat(expectedReleaseBuildArgs),
235222
},
236223
{
237-
name:
238-
"should return correct args for release clean build with trace log and android bundle",
224+
name: "should return correct args for release clean build with trace log and android bundle",
239225
buildConfig: { ...releaseBuildConfig, androidBundle: true },
240226
logLevel: "TRACE",
241227
expectedResult: ["clean"]

0 commit comments

Comments
 (0)