Kotlin/kotlinx.coroutines

Play Services artifact Gradle Module Metadata doesn't advertise the sources jar's existence

EdricChan03 opened this issue · 2 comments

Describe the bug

Currently, sources for the kotlinx-coroutines-play-services artifact aren't recognised, resulting in IntelliJ decompiling the Kotlin source-code when viewing the source of a method, for example the Task.await() method.

This appears to be because the Gradle Module Metadata file that's published onto Maven Central doesn't advertise to end consumers that a sources jar is available, so IntelliJ doesn't download one:

(from https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-play-services/1.8.0/kotlinx-coroutines-play-services-1.8.0.module)

Expand to view GMM file for kotlinx-coroutines-play-services 1.8.0

{
  "formatVersion": "1.1",
  "component": {
    "group": "org.jetbrains.kotlinx",
    "module": "kotlinx-coroutines-play-services",
    "version": "1.8.0",
    "attributes": {
      "org.gradle.status": "release"
    }
  },
  "createdBy": {
    "gradle": {
      "version": "8.5"
    }
  },
  "variants": [
    {
      "name": "apiElements",
      "attributes": {
        "org.gradle.category": "library",
        "org.gradle.dependency.bundling": "external",
        "org.gradle.jvm.environment": "standard-jvm",
        "org.gradle.jvm.version": 8,
        "org.gradle.libraryelements": "jar",
        "org.gradle.usage": "java-api",
        "org.jetbrains.kotlin.platform.type": "jvm"
      },
      "dependencies": [
        /* truncated */
      ],
      "files": [
        {
          "name": "kotlinx-coroutines-play-services-1.8.0.jar",
          "url": "kotlinx-coroutines-play-services-1.8.0.jar",
          "size": 13181,
          "sha512": "3930d6e68f13ff1a49b4de2a35c12f009a2a21c2e7eb21dbffe62ac1e7b7d5de1f08cd823fe92b952f5c4362223f80993e14e1335162bc3f7afa5f5dd90c657e",
          "sha256": "2d6e60b3db6300e20319f30c7c7736267f57b93324b32e94916e6f6028b5b9c5",
          "sha1": "ebdce55873a91b132fd11bf9c8315a8d7f10de75",
          "md5": "13e363f35f10b0b93207666c19e049e5"
        }
      ]
    },
    {
      "name": "runtimeElements",
      "attributes": {
        "org.gradle.category": "library",
        "org.gradle.dependency.bundling": "external",
        "org.gradle.jvm.environment": "standard-jvm",
        "org.gradle.jvm.version": 8,
        "org.gradle.libraryelements": "jar",
        "org.gradle.usage": "java-runtime",
        "org.jetbrains.kotlin.platform.type": "jvm"
      },
      "dependencies": [
        /* truncated */
      ],
      "files": [
        {
          "name": "kotlinx-coroutines-play-services-1.8.0.jar",
          "url": "kotlinx-coroutines-play-services-1.8.0.jar",
          "size": 13181,
          "sha512": "3930d6e68f13ff1a49b4de2a35c12f009a2a21c2e7eb21dbffe62ac1e7b7d5de1f08cd823fe92b952f5c4362223f80993e14e1335162bc3f7afa5f5dd90c657e",
          "sha256": "2d6e60b3db6300e20319f30c7c7736267f57b93324b32e94916e6f6028b5b9c5",
          "sha1": "ebdce55873a91b132fd11bf9c8315a8d7f10de75",
          "md5": "13e363f35f10b0b93207666c19e049e5"
        }
      ]
    }
  ]
}

This is compared to the other artifacts (such as kotlinx-coroutines-core-jvm), which does expose that a sources jar exists:

Expand to view GMM file for kotlinx-coroutines-core-jvm 1.8.0

{
  "formatVersion": "1.1",
  "component": {
    "url": "../../kotlinx-coroutines-core/1.8.0/kotlinx-coroutines-core-1.8.0.module",
    "group": "org.jetbrains.kotlinx",
    "module": "kotlinx-coroutines-core",
    "version": "1.8.0",
    "attributes": {
      "org.gradle.status": "release"
    }
  },
  "createdBy": {
    "gradle": {
      "version": "8.5"
    }
  },
  "variants": [
    {
      "name": "jvmApiElements-published",
      "attributes": {
        "org.gradle.category": "library",
        "org.gradle.libraryelements": "jar",
        "org.gradle.usage": "java-api",
        "org.jetbrains.kotlin.platform.type": "jvm"
      },
      "dependencies": [
        /* truncated */
      ],
      "files": [
        {
          "name": "kotlinx-coroutines-core-jvm-1.8.0.jar",
          "url": "kotlinx-coroutines-core-jvm-1.8.0.jar",
          "size": 1548360,
          "sha512": "081391dcc0b66e4f71401a0684c8f0fe0fa10f195ca5e50208419b4f6110d9b0f90250a43950114d75c79455b9d304afadc069b98c5bc86afa7701ddaed51af1",
          "sha256": "9860906a1937490bf5f3b06d2f0e10ef451e65b95b269f22daf68a3d1f5065c5",
          "sha1": "ac1dc37a30a93150b704022f8d895ee1bd3a36b3",
          "md5": "d29200b10d99a82fafcceabc3a48f7e0"
        }
      ]
    },
    {
      "name": "jvmRuntimeElements-published",
      "attributes": {
        "org.gradle.category": "library",
        "org.gradle.libraryelements": "jar",
        "org.gradle.usage": "java-runtime",
        "org.jetbrains.kotlin.platform.type": "jvm"
      },
      "dependencies": [
        /* truncated */
      ],
      "files": [
        {
          "name": "kotlinx-coroutines-core-jvm-1.8.0.jar",
          "url": "kotlinx-coroutines-core-jvm-1.8.0.jar",
          "size": 1548360,
          "sha512": "081391dcc0b66e4f71401a0684c8f0fe0fa10f195ca5e50208419b4f6110d9b0f90250a43950114d75c79455b9d304afadc069b98c5bc86afa7701ddaed51af1",
          "sha256": "9860906a1937490bf5f3b06d2f0e10ef451e65b95b269f22daf68a3d1f5065c5",
          "sha1": "ac1dc37a30a93150b704022f8d895ee1bd3a36b3",
          "md5": "d29200b10d99a82fafcceabc3a48f7e0"
        }
      ]
    },
    {
      "name": "jvmSourcesElements-published",
      "attributes": {
        "org.gradle.category": "documentation",
        "org.gradle.dependency.bundling": "external",
        "org.gradle.docstype": "sources",
        "org.gradle.libraryelements": "jar",
        "org.gradle.usage": "java-runtime",
        "org.jetbrains.kotlin.platform.type": "jvm"
      },
      "files": [
        {
          "name": "kotlinx-coroutines-core-jvm-1.8.0-sources.jar",
          "url": "kotlinx-coroutines-core-jvm-1.8.0-sources.jar",
          "size": 390254,
          "sha512": "9fb6527120a76cd4a6a0749983a02835f81c747692b3f12a90700fe98f6d463e026d4e7cdb84c003424e0cf3029db30cf6b423e49cab99bd9e06d917f6cf9374",
          "sha256": "451599ff2044e6a98f975b28d106891cc664ae69ad7a30c572dffb5413202179",
          "sha1": "037cb5fe79f895c0900ab9422b14ac91b7b3b37b",
          "md5": "1dd8ed7ce1d91fb7e4e017b4b085c09a"
        }
      ]
    }
  ]
}

Provide a Reproducer

  1. Create a Gradle module which has the play-services artifact:

(gradle/libs.versions.toml)

[versions]
firebase-bom = "32.8.1"
kotlinx-coroutines = "1.8.0"

[libraries]
kotlinx-coroutines-playServices = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-play-services", version.ref = "kotlinx-coroutines" }

firebase-bom = { module = "com.google.firebase:firebase-bom", version.ref = "firebase-bom" }
firebase-auth = { module = "com.google.firebase:firebase-auth" }
dependencies {
  implementation(platform(libs.firebase.bom))
  implementation(libs.firebase.auth)
  implementation(libs.kotlinx.coroutines.playServices)
}
  1. Add some code which uses Task.await()
/**
 * Asynchronously creates a user using the email + password authentication method,
 * with the given [email] and [password].
 * @return The result of the user creation request.
 * @see FirebaseAuth.createUserWithEmailAndPassword
 */
suspend fun FirebaseAuth.createUserWithEmailAndPasswordAsync(
    email: String, password: String
): AuthResult = createUserWithEmailAndPassword(email, password).await()
  1. View source on the await() method
  2. Notice that it navigates to the decompiled Kotlin class rather than the source code (and also showing a licensing warning)
Screenshot of decompilation licensing warning dialog Screenshot of Tasks.kt decompiled output, with no source code

This also appears to affect kotlinx-coroutines-guava as well, which doesn't indicate that a sources jar is available:

Expand to view kotlinx-coroutines-guava GMM

{
  "formatVersion": "1.1",
  "component": {
    "group": "org.jetbrains.kotlinx",
    "module": "kotlinx-coroutines-guava",
    "version": "1.8.0",
    "attributes": {
      "org.gradle.status": "release"
    }
  },
  "createdBy": {
    "gradle": {
      "version": "8.5"
    }
  },
  "variants": [
    {
      "name": "apiElements",
      "attributes": {
        "org.gradle.category": "library",
        "org.gradle.dependency.bundling": "external",
        "org.gradle.jvm.environment": "standard-jvm",
        "org.gradle.jvm.version": 8,
        "org.gradle.libraryelements": "jar",
        "org.gradle.usage": "java-api",
        "org.jetbrains.kotlin.platform.type": "jvm"
      },
      "dependencies": [
        /* truncated */
      ],
      "files": [
        {
          "name": "kotlinx-coroutines-guava-1.8.0.jar",
          "url": "kotlinx-coroutines-guava-1.8.0.jar",
          "size": 20285,
          "sha512": "387d72b5cebc7b821c13dc168ff84c952bb76c5ced7ffcce07e40ba62e35ee5460f77778d50280c02853d387e3edf900564feda5837a6c8a00d5135039fef9c0",
          "sha256": "650b3681fef3c82b900367fa3e1d8645f41891b3abe00b27bc6dbdeb2c2fa22b",
          "sha1": "6109cffec886d6e112e5e2cbd3e0ec29f0bf6fee",
          "md5": "c1faac8d2ec0b507acbcfa22999a6efb"
        }
      ]
    },
    {
      "name": "runtimeElements",
      "attributes": {
        "org.gradle.category": "library",
        "org.gradle.dependency.bundling": "external",
        "org.gradle.jvm.environment": "standard-jvm",
        "org.gradle.jvm.version": 8,
        "org.gradle.libraryelements": "jar",
        "org.gradle.usage": "java-runtime",
        "org.jetbrains.kotlin.platform.type": "jvm"
      },
      "dependencies": [
        /* truncated */
      ],
      "files": [
        {
          "name": "kotlinx-coroutines-guava-1.8.0.jar",
          "url": "kotlinx-coroutines-guava-1.8.0.jar",
          "size": 20285,
          "sha512": "387d72b5cebc7b821c13dc168ff84c952bb76c5ced7ffcce07e40ba62e35ee5460f77778d50280c02853d387e3edf900564feda5837a6c8a00d5135039fef9c0",
          "sha256": "650b3681fef3c82b900367fa3e1d8645f41891b3abe00b27bc6dbdeb2c2fa22b",
          "sha1": "6109cffec886d6e112e5e2cbd3e0ec29f0bf6fee",
          "md5": "c1faac8d2ec0b507acbcfa22999a6efb"
        }
      ]
    }
  ]
}

I'm having this problem with kotlinx-coroutines-rx3 too!