Skip to content
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

feat - Support resolving debug & release variant from Android Java project #173

Merged
merged 15 commits into from
Sep 5, 2024

Conversation

Tanish-Ranjan
Copy link
Contributor

@Tanish-Ranjan Tanish-Ranjan commented Jul 16, 2024

This PR resolves android projects to build GradleSourceSets out of build variants.

@jdneo
Copy link
Member

jdneo commented Aug 19, 2024

Hi @Tanish-Ranjan, I saw there are a lot of android resource files in the test project. Are they all necessary for testing purpose?

@Tanish-Ranjan
Copy link
Contributor Author

No. The project was generated by the Android Studio, so there are a lot of resources generated along with it. I will narrow it down as I add the unit tests.

@Tanish-Ranjan Tanish-Ranjan marked this pull request as ready for review August 20, 2024 03:33
Tanish-Ranjan and others added 9 commits August 22, 2024 07:49
Changes:
- Added Android Library Module to android-test project.
- Added SourceSetUtils file with methods to check for android projects and retrieve source sets.
- Added unit test to GradleApiConnectorTest for android-test project.
…et properties.

Changes:
- Added most of the android build target properties.
- Addressed checkstyle warnings
- Changed GradleSourceSet to store set of resource output directories instead of one directory.
- Removed temporary android testing methods.
Changes:
- Added JavaDocs to AndroidUtils
- Added SourceSetUtils for common utility methods for SourceSets.
- Removed common method declarations from AndroidUtils and SourceSetsModelBuilder into SourceSetUtils.
Changes:
- Removed unnecessary resource files from android-test project.
- Completed AndroidModelBuilder unit test in GradleApiConnectorTest.
- Suppressed and addressed minor warnings in DependencyCollector and SourceSetsModelBuilder.
- Removed classloader approach for retrieving artifact components in AndroidDependencyCollector.
- AndroidBuildVariant SourceSet now stores full task name for compileTask.
- AndroidSDK Jar is also added to AndroidBuildVariant SourceSet compileClasspath.
Changes:
- Fixed android test project.
- Added integration test to verify presence of android sdk component jar.
- Moved android sdk component and R file from classpath to module dependency of a build target.
Changes:
- Removed default proguard files from android-test project.
- Added a utility function for invocation of methods with reflection in AndroidUtils.
@Tanish-Ranjan
Copy link
Contributor Author

testAndroidSourceSets can be ignored. I left a note in the test. The two missing dependencies are from Android SDK which will be added only if ANDROID_HOME is set.

@Tanish-Ranjan Tanish-Ranjan changed the title Android Support Android Java Project Support Aug 24, 2024
@Tanish-Ranjan
Copy link
Contributor Author

There a couple of limitations/improvements possible for Android support:

  1. Intermediate generated sources
    Android generates a lot of intermediate sources such as AIDL, Render script, C/CPP, etc. Unfortunately AGP doesn't provide any APIs to retrieve these files. R.jar is one of these intermediate sources which is crucial for Android development so as a workaround I have retrieved the file using the process task for the build variant however, in some cases the task may not be registered during the sync in which case the dependency for R.jar is not provided.

    I have opened a ticket here: Improve support for Android intermediate generated sources #181

  2. Other project type support
    There various kinds of projects that come under Android development such as Application, Library, Instant App, Dynamic Modules, Android Test, etc. I have added support for the most commonly used projects - Application and Library but the current implementation may require further enhancements to support other kinds of projects.

    I have opened a ticket here: Support for different types of Android projects #182

  3. Test variants
    My implementation takes into account any user defined build variants and the default build variants - debug and release except the default test variants - test and androidTest.

    I have opened a ticket here: Test variants discovery for Android projects #183

  4. ANDROID_HOME fallback logic
    Android Components to be used by an Android project is configured via ANDROID_HOME environment variable. If the property doesn't exist then we are not providing the dependency. This implementation can be improved via fallback logic similar to what we did for JAVA_HOME in Find compatible GradleJavaHome and notify client in case of incompatibility #165.

    I have opened a ticket here: ANDROID_HOME fallback logic #184

@jdneo
Copy link
Member

jdneo commented Aug 26, 2024

Hi @Tanish-Ranjan,

Thank you for listing the follow-ups. Could you please copy the context information to the related issues as well. Currently, the linked issues are all empty.

Changes:
- Added needed notes to Android tests.
- Removed unnecessary support dependency from android-test library project.
Changes:
- Moved supportedLanguageModelBuilders method from the ModelBuilder to AndroidUtils.
- Added JavaLanguageExtension to the android build target extensions property.
@jdneo jdneo added android Android support related enhancement New feature or request labels Aug 30, 2024
@jdneo jdneo added this to the 0.4.0 milestone Aug 30, 2024
Copy link
Member

@jdneo jdneo left a comment

Choose a reason for hiding this comment

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

LGTM

@jdneo jdneo merged commit 3129d53 into microsoft:develop Sep 5, 2024
4 checks passed
@jdneo jdneo changed the title Android Java Project Support feat - Support resolving debug & release variant from Android Java project Sep 5, 2024
@Tanish-Ranjan Tanish-Ranjan deleted the feat/android-support branch September 5, 2024 17:20
@Tanish-Ranjan
Copy link
Contributor Author

Tanish-Ranjan commented Sep 5, 2024

With default build types debug and release, this PR also resolved any other user configured build types. It's the default test variants - unitTest and androidTest which it failed to extract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Android support related enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants