Skip to content

Commit 58608c9

Browse files
feat: Validate Java compiler version based on runtime version
Update calls to `nativescript-doctor` package to pass projectDir where applicable. This allows the package to verify installed Java Compiler version against the project's Android runtime. This is required in case the installed Java version is 10 or above and the Androud runtime in the project is older than 4.1.0. In this case the user cannot build this application for Android, but have to update the Android runtime version or downgrade the Java version.
1 parent 7069672 commit 58608c9

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

lib/definitions/platform.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,5 +381,5 @@ interface IUpdateAppOptions extends IOptionalFilesToSync, IOptionalFilesToRemove
381381
}
382382

383383
interface IPlatformEnvironmentRequirements {
384-
checkEnvironmentRequirements(platform?: string): Promise<boolean>;
384+
checkEnvironmentRequirements(platform?: string, projectDir?: string): Promise<boolean>;
385385
}

lib/services/android-project-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
133133
this.validatePackageName(projectData.projectId);
134134
this.validateProjectName(projectData.projectName);
135135

136-
await this.$platformEnvironmentRequirements.checkEnvironmentRequirements(this.getPlatformData(projectData).normalizedPlatformName);
136+
await this.$platformEnvironmentRequirements.checkEnvironmentRequirements(this.getPlatformData(projectData).normalizedPlatformName, projectData.projectDir);
137137
this.$androidToolsInfo.validateTargetSdk({ showWarningsAsErrors: true });
138138
}
139139

lib/services/doctor-service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ class DoctorService implements IDoctorService {
1717
private $terminalSpinnerService: ITerminalSpinnerService,
1818
private $versionsService: IVersionsService) { }
1919

20-
public async printWarnings(configOptions?: { trackResult: boolean }): Promise<void> {
20+
public async printWarnings(configOptions?: { trackResult: boolean , projectDir?: string }): Promise<void> {
2121
const infos = await this.$terminalSpinnerService.execute<NativeScriptDoctor.IInfo[]>({
2222
text: `Getting environment information ${EOL}`
23-
}, () => doctor.getInfos());
23+
}, () => doctor.getInfos({ projectDir: configOptions && configOptions.projectDir }));
2424

2525
const warnings = infos.filter(info => info.type === constants.WARNING_TYPE_NAME);
2626
const hasWarnings = warnings.length > 0;
@@ -48,7 +48,7 @@ class DoctorService implements IDoctorService {
4848
this.$logger.error("Cannot get the latest versions information from npm. Please try again later.");
4949
}
5050

51-
await this.$injector.resolve("platformEnvironmentRequirements").checkEnvironmentRequirements(null);
51+
await this.$injector.resolve("platformEnvironmentRequirements").checkEnvironmentRequirements(null, configOptions && configOptions.projectDir);
5252
}
5353

5454
public async runSetupScript(): Promise<ISpawnResult> {
@@ -81,12 +81,12 @@ class DoctorService implements IDoctorService {
8181
});
8282
}
8383

84-
public async canExecuteLocalBuild(platform?: string): Promise<boolean> {
84+
public async canExecuteLocalBuild(platform?: string, projectDir?: string): Promise<boolean> {
8585
await this.$analyticsService.trackEventActionInGoogleAnalytics({
8686
action: TrackActionNames.CheckLocalBuildSetup,
8787
additionalData: "Starting",
8888
});
89-
const infos = await doctor.getInfos({ platform });
89+
const infos = await doctor.getInfos({ platform, projectDir });
9090

9191
const warnings = this.filterInfosByType(infos, constants.WARNING_TYPE_NAME);
9292
const hasWarnings = warnings.length > 0;

lib/services/ios-project-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
139139
return;
140140
}
141141

142-
await this.$platformEnvironmentRequirements.checkEnvironmentRequirements(this.getPlatformData(projectData).normalizedPlatformName);
142+
await this.$platformEnvironmentRequirements.checkEnvironmentRequirements(this.getPlatformData(projectData).normalizedPlatformName, projectData.projectDir);
143143

144144
const xcodeBuildVersion = await this.getXcodeVersion();
145145
if (helpers.versionCompare(xcodeBuildVersion, IOSProjectService.XCODEBUILD_MIN_VERSION) < 0) {

lib/services/platform-environment-requirements.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
3030
"deploy": "tns cloud deploy"
3131
};
3232

33-
public async checkEnvironmentRequirements(platform?: string): Promise<boolean> {
33+
public async checkEnvironmentRequirements(platform?: string, projectDir?: string): Promise<boolean> {
3434
if (process.env.NS_SKIP_ENV_CHECK) {
3535
await this.$analyticsService.trackEventActionInGoogleAnalytics({
3636
action: TrackActionNames.CheckEnvironmentRequirements,
@@ -39,7 +39,7 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
3939
return true;
4040
}
4141

42-
const canExecute = await this.$doctorService.canExecuteLocalBuild(platform);
42+
const canExecute = await this.$doctorService.canExecuteLocalBuild(platform, projectDir);
4343
if (!canExecute) {
4444
if (!isInteractive()) {
4545
await this.$analyticsService.trackEventActionInGoogleAnalytics({
@@ -71,7 +71,7 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
7171
if (selectedOption === PlatformEnvironmentRequirements.LOCAL_SETUP_OPTION_NAME) {
7272
await this.$doctorService.runSetupScript();
7373

74-
if (await this.$doctorService.canExecuteLocalBuild(platform)) {
74+
if (await this.$doctorService.canExecuteLocalBuild(platform, projectDir)) {
7575
return true;
7676
}
7777

@@ -102,7 +102,7 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
102102

103103
if (selectedOption === PlatformEnvironmentRequirements.BOTH_CLOUD_SETUP_AND_LOCAL_SETUP_OPTION_NAME) {
104104
await this.processBothCloudBuildsAndSetupScript();
105-
if (await this.$doctorService.canExecuteLocalBuild(platform)) {
105+
if (await this.$doctorService.canExecuteLocalBuild(platform, projectDir)) {
106106
return true;
107107
}
108108

0 commit comments

Comments
 (0)