Skip to content

Commit 42e4210

Browse files
author
Dimitar Tachev
authored
Merge pull request #3731 from NativeScript/tachev/use-runtime-gradle-version
feat: use runtime Gradle version during plugin AAR build
2 parents 4686a4b + 1a881a1 commit 42e4210

10 files changed

+449
-254
lines changed

lib/constants.ts

+5
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ export class Hooks {
207207
public static createProject = "createProject";
208208
}
209209

210+
export class AndroidBuildDefaults {
211+
public static GradleVersion = "4.4";
212+
public static GradleAndroidPluginVersion = "3.1.2";
213+
}
214+
210215
export const PACKAGE_PLACEHOLDER_NAME = "__PACKAGE__";
211216

212217
export class AddPlaformErrors {

lib/declarations.d.ts

+8
Original file line numberDiff line numberDiff line change
@@ -850,3 +850,11 @@ interface IAssetsGenerationService {
850850
*/
851851
generateSplashScreens(splashesGenerationData: ISplashesGenerationData): Promise<void>;
852852
}
853+
854+
/**
855+
* Describes the Gradle versions specified in the package.json of the Android runtime
856+
*/
857+
interface IRuntimeGradleVersions {
858+
gradleVersion?: string;
859+
gradleAndroidPluginVersion?: string;
860+
}

lib/definitions/android-plugin-migrator.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
interface IBuildOptions extends IAndroidBuildOptions{
3+
projectDir?: string
34
}
45

56
interface IAndroidBuildOptions {
@@ -33,5 +34,5 @@ interface IBuildAndroidPluginData {
3334
/**
3435
* Information about tools that will be used to build the plugin, for example compile SDK version, build tools version, etc.
3536
*/
36-
androidToolsInfo: IAndroidToolsInfoData;
37+
androidToolsInfo?: IAndroidToolsInfoData;
3738
}

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

+147-95
Large diffs are not rendered by default.

lib/services/android-project-service.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
100100
return this._platformData;
101101
}
102102

103-
// TODO: Remove prior to the 4.0 CLI release @Pip3r4o @PanayotCankov
104-
// Similar to the private method of the same name in platform-service.
105-
private getCurrentPlatformVersion(platformData: IPlatformData, projectData: IProjectData): string {
103+
public getCurrentPlatformVersion(platformData: IPlatformData, projectData: IProjectData): string {
106104
const currentPlatformData: IDictionary<any> = this.$projectDataService.getNSValue(projectData.projectDir, platformData.frameworkPackageName);
107105

108106
return currentPlatformData && currentPlatformData[constants.VERSION_STRING];
@@ -422,6 +420,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
422420
const pluginPlatformsFolderPath = this.getPluginPlatformsFolderPath(pluginData, AndroidProjectService.ANDROID_PLATFORM_NAME);
423421
if (this.$fs.exists(pluginPlatformsFolderPath)) {
424422
const options: IBuildOptions = {
423+
projectDir: projectData.projectDir,
425424
pluginName: pluginData.name,
426425
platformsAndroidDirPath: pluginPlatformsFolderPath,
427426
aarOutputDir: pluginPlatformsFolderPath,
@@ -533,9 +532,6 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
533532

534533
public async removePluginNativeCode(pluginData: IPluginData, projectData: IProjectData): Promise<void> {
535534
try {
536-
// check whether the dependency that's being removed has native code
537-
// TODO: Remove prior to the 4.1 CLI release @Pip3r4o @PanayotCankov
538-
// the updated gradle script will take care of cleaning the prepared android plugins
539535
if (!this.runtimeVersionIsGreaterThanOrEquals(projectData, "3.3.0")) {
540536
const pluginConfigDir = path.join(this.getPlatformData(projectData).projectRoot, "configurations", pluginData.name);
541537
if (this.$fs.exists(pluginConfigDir)) {
@@ -563,8 +559,6 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
563559
if (shouldUseNewRoutine) {
564560
this.provideDependenciesJson(projectData, dependencies);
565561
} else {
566-
// TODO: Remove prior to the 4.1 CLI release @Pip3r4o @PanayotCankov
567-
568562
const platformDir = path.join(projectData.platformsDir, AndroidProjectService.ANDROID_PLATFORM_NAME);
569563
const buildDir = path.join(platformDir, "build-tools");
570564
const checkV8dependants = path.join(buildDir, "check-v8-dependants.js");
@@ -580,7 +574,6 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
580574
}
581575

582576
if (!shouldUseNewRoutine) {
583-
// TODO: Remove prior to the 4.0 CLI release @Pip3r4o @PanayotCankov
584577
const projectRoot = this.getPlatformData(projectData).projectRoot;
585578
await this.cleanProject(projectRoot, projectData);
586579
}

0 commit comments

Comments
 (0)