-
-
Notifications
You must be signed in to change notification settings - Fork 206
feat(android): ship the app and plugin gradle files with the CLI #6129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -578,7 +578,13 @@ interface IAndroidOptions extends IEmbedOptions { | |
| */ | ||
| gradleFlavor: string; | ||
| gradlePath: string; | ||
| gradleArgs: string; | ||
| gradleArgs: string[]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Retain compatibility with scalar Existing JavaScript
📍 Affects 6 files
🤖 Prompt for AI Agents |
||
| /** | ||
| * When true (the default) the gradle files bundled with the CLI are copied | ||
| * over the ones shipped by the android runtime. Pass `--no-override-runtime-gradle-files` | ||
| * to keep the runtime files untouched. | ||
| */ | ||
| overrideRuntimeGradleFiles: boolean; | ||
| } | ||
|
|
||
| interface IIOSOptions extends IEmbedOptions {} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,8 @@ import { injector } from "../common/yok"; | |
| import * as _ from "lodash"; | ||
| import { resolvePackageJSONPath } from "@rigor789/resolve-package-path"; | ||
| import { cwd } from "process"; | ||
| import { IAndroidToolsInfo } from "../declarations"; | ||
| import { IGradleBuildArgsService } from "../definitions/gradle"; | ||
|
|
||
| export class AndroidPluginBuildService implements IAndroidPluginBuildService { | ||
| private get $platformsDataService(): IPlatformsDataService { | ||
|
|
@@ -46,7 +48,9 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService { | |
|
|
||
| constructor( | ||
| private $fs: IFileSystem, | ||
| private $androidToolsInfo: IAndroidToolsInfo, | ||
| private $childProcess: IChildProcess, | ||
| private $gradleBuildArgsService: IGradleBuildArgsService, | ||
| private $hostInfo: IHostInfo, | ||
| private $options: IOptions, | ||
| private $logger: ILogger, | ||
|
|
@@ -263,7 +267,9 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService { | |
| ); | ||
| await this.buildPlugin({ | ||
| gradlePath: options.gradlePath, | ||
| gradleArgs: options.gradleArgs, | ||
| gradleArgs: ( | ||
| this.$projectData.nsConfig?.android?.gradleArgs ?? [] | ||
| ).concat(options.gradleArgs ?? []), | ||
| pluginDir: pluginTempDir, | ||
| pluginName: options.pluginName, | ||
| projectDir: options.projectDir, | ||
|
|
@@ -413,10 +419,11 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService { | |
| this.addCompileDependencies(platformsAndroidDirPath, buildGradlePath); | ||
| const runtimeGradleVersions = | ||
| await this.getRuntimeGradleVersions(projectDir); | ||
| this.replaceGradleVersion( | ||
| pluginTempDir, | ||
| runtimeGradleVersions.gradleVersion, | ||
| ); | ||
| // a gradle version pinned in the project config wins over the runtime one | ||
| const gradleVersion = | ||
| this.$projectData.nsConfig?.android?.gradleVersion ?? | ||
| runtimeGradleVersions.gradleVersion; | ||
| this.replaceGradleVersion(pluginTempDir, gradleVersion); | ||
| this.replaceGradleAndroidPluginVersion( | ||
| buildGradlePath, | ||
| runtimeGradleVersions.gradleAndroidPluginVersion, | ||
|
|
@@ -808,22 +815,38 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService { | |
| pluginBuildSettings.gradlePath ?? | ||
| (this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew"); | ||
|
|
||
| const toolsInfo = this.$androidToolsInfo.getToolsInfo({ | ||
| projectDir: this.$projectData.projectDir, | ||
| }); | ||
|
|
||
| const localArgs = [ | ||
| "-p", | ||
| pluginBuildSettings.pluginDir, | ||
| "assembleRelease", | ||
| `-PtempBuild=true`, | ||
| `-PcompileSdk=${toolsInfo.compileSdkVersion}`, | ||
| `-PtargetSdk=${toolsInfo.targetSdkVersion}`, | ||
| `-PbuildToolsVersion=${toolsInfo.buildToolsVersion}`, | ||
| `-PprojectRoot=${this.$projectData.projectDir}`, | ||
| // settings.gradle runs before the project properties are available, | ||
| // so the same values have to be passed as system properties too | ||
| `-DprojectRoot=${this.$projectData.projectDir}`, | ||
| `-PappBuildPath=${this.$projectData.getBuildRelativeDirectoryPath()}`, | ||
| `-DappBuildPath=${this.$projectData.getBuildRelativeDirectoryPath()}`, | ||
| `-PappPath=${this.$projectData.getAppDirectoryPath()}`, | ||
| `-PappResourcesPath=${this.$projectData.getAppResourcesDirectoryPath()}`, | ||
|
Comment on lines
+818
to
837
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Use
🤖 Prompt for AI Agents |
||
| ]; | ||
|
|
||
| if (pluginBuildSettings.gradleArgs) { | ||
| localArgs.push(pluginBuildSettings.gradleArgs); | ||
| for (const gradleArg of pluginBuildSettings.gradleArgs ?? []) { | ||
| localArgs.push( | ||
| ...gradleArg | ||
| .split(" ") | ||
| .map((arg) => arg.trim()) | ||
| .filter((arg) => !!arg), | ||
| ); | ||
| } | ||
|
|
||
| if (this.$logger.getLevel() === "INFO") { | ||
| localArgs.push("--quiet"); | ||
| } | ||
| localArgs.push(...this.$gradleBuildArgsService.getBuildLoggingArgs()); | ||
|
|
||
| const opts: any = { | ||
| cwd: pluginBuildSettings.pluginDir, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use complete, hyphenated Gradle argument text.
Replace the sentence fragment “Can be passed multiple times” with a complete sentence. Replace “space separated” with “space-separated”.
docs/man_pages/project/testing/build-android.md#L38-L38: revise the--gradleArgsdescription.docs/man_pages/project/testing/debug-android.md#L42-L42: apply the same revised description.docs/man_pages/project/testing/run-android.md#L47-L47: apply the same revised description.🧰 Tools
🪛 LanguageTool
[style] ~38-~38: To form a complete sentence, be sure to include a subject.
Context: ... Passes additional arguments to gradle. Can be passed multiple times, and a single ...
(MISSING_IT_THERE)
[grammar] ~38-~38: Use a hyphen to join words.
Context: ...nd a single value may hold several space separated arguments. Use the
=form so...(QB_NEW_EN_HYPHEN)
📍 Affects 3 files
docs/man_pages/project/testing/build-android.md#L38-L38(this comment)docs/man_pages/project/testing/debug-android.md#L42-L42docs/man_pages/project/testing/run-android.md#L47-L47🤖 Prompt for AI Agents
Source: Linters/SAST tools