Skip to content

Feature/adjust patrol to add2app#3037

Draft
Kendru98 wants to merge 6 commits into
masterfrom
feature/adjust-patrol-to-add2app
Draft

Feature/adjust patrol to add2app#3037
Kendru98 wants to merge 6 commits into
masterfrom
feature/adjust-patrol-to-add2app

Conversation

@Kendru98
Copy link
Copy Markdown
Collaborator

No description provided.

@github-actions github-actions Bot added the package: patrol_cli Related to the patrol_cli package label Apr 24, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for Flutter "add-to-app" (module) projects within the Patrol CLI. It adds new CLI flags and configuration options in pubspec.yaml to specify external native project paths for Android and iOS. The build logic for both platforms has been updated to resolve working directories dynamically and ensure that configuration-only builds are executed correctly from the module root. Feedback focuses on improving the robustness of the Gradle wrapper detection on Windows, removing redundant type filtering during directory listing, and cleaning up idiomatic type checks in the pubspec reader.

Comment on lines +181 to +187
final gradlew = p.join(resolvedNativePath, 'gradlew');
if (!FileSystemEntity.isFileSync(gradlew)) {
throw Exception(
'No gradlew script found in $resolvedNativePath. '
'The native Android project must have a Gradle wrapper.',
);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

On Windows, the Gradle wrapper script is named gradlew.bat. Checking only for gradlew might lead to false negatives if the extensionless shell script is missing, even though standard Flutter projects usually include both. It is safer to check for either.

    final gradlew = p.join(resolvedNativePath, 'gradlew');
    final gradlewBat = p.join(resolvedNativePath, 'gradlew.bat');
    if (!FileSystemEntity.isFileSync(gradlew) &&
        !FileSystemEntity.isFileSync(gradlewBat)) {
      throw Exception(
        'No gradlew or gradlew.bat script found in $resolvedNativePath. '
        'The native Android project must have a Gradle wrapper.',
      );
    }


final workspaces = dir
.listSync()
.whereType<FileSystemEntity>()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The call to whereType<FileSystemEntity>() is redundant here because listSync() already returns a List<FileSystemEntity>.

Suggested change
.whereType<FileSystemEntity>()
.listSync()

androidConfig.flavor = flavor;
}
final dynamic nativeProjectPath = android['native_project_path'];
if (nativeProjectPath != null && nativeProjectPath is String?) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The type check is String? is redundant when combined with a null check. Since nativeProjectPath != null is already verified, using is String is more precise and idiomatic.

Suggested change
if (nativeProjectPath != null && nativeProjectPath is String?) {
if (nativeProjectPath != null && nativeProjectPath is String) {

iosConfig.flavor = flavor;
}
final dynamic nativeProjectPath = ios['native_project_path'];
if (nativeProjectPath != null && nativeProjectPath is String?) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The type check is String? is redundant when combined with a null check. Since nativeProjectPath != null is already verified, using is String is more precise and idiomatic.

Suggested change
if (nativeProjectPath != null && nativeProjectPath is String?) {
if (nativeProjectPath != null && nativeProjectPath is String) {

…le.properties, enhancing support for custom Android project structures in add-to-app setups.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: patrol_cli Related to the patrol_cli package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant