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

[XABT] Add ArtifactFilename metadata for @(AndroidMavenLibrary) item. #9479

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Oct 31, 2024

Fixes: #9465

In all of the examples we used when developing and testing @(AndroidMavenLibrary) the Maven artifact filename followed the pattern {artifact.Id}-{artifact.Version}.[jar|aar], so this is the default filename we construct for the user.

However, there exists some packages like React that do not follow this pattern and instead do eg: react-android-0.76.0-release.aar. Attempting to use @(AndroidMavenLibrary) for React produces the following error:

error XA4236: Cannot download Maven artifact 'com.facebook.react:react-android'.
error XA4236: - react-android-0.76.0.jar: Response status code does not indicate success: 404 (Not Found).
error XA4236: - react-android-0.76.0.aar: Response status code does not indicate success: 404 (Not Found).

To support these cases, add a new optional metadata ArtifactFilename that can be specified to override the Maven filename of the artifact.

<AndroidMavenLibrary Include="com.facebook.react:react-android" Version="0.76.0" ArtifactFilename="react-android-0.76.0-release.aar" />

This allows our tasks to properly download the artifact and avoid the error.

@jpobst jpobst changed the title [XABT] Add ArtifactFilename metadata for AndroidMavenLibrary item. [XABT] Add ArtifactFilename metadata for @(AndroidMavenLibrary) item. Oct 31, 2024
@jpobst jpobst marked this pull request as ready for review November 21, 2024 18:57
@jpobst jpobst requested a review from jonpryor November 21, 2024 18:57
Comment on lines +145 to +146
files_to_check.Add (Path.Combine (output_directory, $"{artifact.Id}-{artifact.Version}.jar"));
files_to_check.Add (Path.Combine (output_directory, $"{artifact.Id}-{artifact.Version}.aar"));
Copy link
Member

Choose a reason for hiding this comment

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

We don't have to do this here, but is there some manifest file that we can download to know the exact file name? It seems odd they can choose random names. How does Java tooling know which file to download?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a good question. There doesn't appear to be anything in the .pom that gives the file name: https://repo1.maven.org/maven2/com/facebook/react/react-android/0.76.0/react-android-0.76.0.pom

It looks like React has its own Gradle plugin you need to use, perhaps it knows how to resolve their files?

Copy link
Member

Choose a reason for hiding this comment

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

In the case of react-android, there appears to be a react-android-0.76.0.module file, which is a JSON file which mentions the "real" filenames:

{
  
  "component": {
    "group": "com.facebook.react",
    "module": "react-android",
    "version": "0.76.0",
    "attributes": {
      "org.gradle.status": "release"
    }
  },
  
  "variants": [
    {
      "name": "debugVariantDefaultApiPublication",
      "attributes": {
        "com.android.build.api.attributes.BuildTypeAttr": "debug",
        "org.gradle.category": "library",
        "org.gradle.dependency.bundling": "external",
        "org.gradle.libraryelements": "aar",
        "org.gradle.usage": "java-api"
      },
      
      "files": [
        {
          "name": "react-android-0.76.0-debug.aar",
          "url": "react-android-0.76.0-debug.aar",
          "size": 204696650,
          "sha512": "736141a49db0dbadf34379b832ea858642be172d0d302edca7edc76ae34c93846b98167989854cc3da954b4ac32946f0ca3fc55bd5f7b6b8df17483e04eb342e",
          "sha256": "a131374a0e4aea0bf131746d615c8ba5fcafedf79e809d864d2b2a619714c205",
          "sha1": "a78b8bb37b808263e6757f99ef82f3d75823af0f",
          "md5": "70afd54443016d5b9c2c5d1c7ac9342b"
        }
      ]
    },
   
   {
      "name": "releaseVariantDefaultRuntimePublication",
      "attributes": {
        "com.android.build.api.attributes.BuildTypeAttr": "release",
        "org.gradle.category": "library",
        "org.gradle.dependency.bundling": "external",
        "org.gradle.libraryelements": "aar",
        "org.gradle.usage": "java-runtime"
      },
      
      "files": [
        {
          "name": "react-android-0.76.0-release.aar",
          "url": "react-android-0.76.0-release.aar",
          "size": 128739900,
          "sha512": "bbd62ba818768ab4ef05cdbb463a63cf208933c23419b44f692284f30dc5af5acfa4bb50eb48015b77132c7cb81c33793d3d706dafb30820d9b478ce1d0d18d4",
          "sha256": "ce57d01ab360711f768a2aa46a86f153e3edaf8cf20da25237861bef21c41173",
          "sha1": "f766f97dec77212133f8b3a1b4615d9b5d41ffe5",
          "md5": "7cbeccd4a237fae95035f1bcc2f25f0f"
        }
      ]
    },
  

Which certainly looks interesting! The problems include:

  • What is a .module file? Documentation?
  • How widespread is this construct used?
  • What (and how) should this info be used or surfaced? A %(BuildTypeAttr) metadata which is used to key off of com.android.build.api.attributes.BuildTypeAttr?
  • Is this something we want to support?

%(ArtifactFilename) is a good workaround for now.

@jonpryor jonpryor merged commit b07a0c9 into main Nov 26, 2024
58 checks passed
@jonpryor jonpryor deleted the maven-override branch November 26, 2024 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<AndroidMavenLibrary> support for nonstandard artifact filenames
3 participants