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

Disable kotlinSourcesJar since it conflicts with sourcesJar #5151

Closed
refeccd opened this issue May 28, 2024 · 5 comments
Closed

Disable kotlinSourcesJar since it conflicts with sourcesJar #5151

refeccd opened this issue May 28, 2024 · 5 comments
Labels
bug A general bug build A change in our build-system
Milestone

Comments

@refeccd
Copy link

refeccd commented May 28, 2024

This is the archive of the source jar in the central repository

https://repo1.maven.org/maven2/io/micrometer/micrometer-core/1.13.0/micrometer-core-1.13.0-sources.jar

It looks like it adds an extra layer of main directory?

image
@jonatan-ivanov jonatan-ivanov added bug A general bug build A change in our build-system and removed waiting-for-triage labels Jun 14, 2024
@jonatan-ivanov jonatan-ivanov added this to the 1.13.2 milestone Jun 14, 2024
@jonatan-ivanov
Copy link
Member

Thank you for the issue!
I'm not sure what is causing this yet, it seems:

git checkout v1.13.0
./gradlew -Prelease.disableGitChecks=true -Prelease.useLastTag=true -Prelease.stage=milestone final pTML -x test
  • But if I just run pTML, I can't:
./gradlew pTML

Diffing 1.12.x with 1.13.x does not help much, I can't see any suspicious changes.

I'm continuing the investigations tomorrow but is this causing any issues to you right now? Can the IDE automatically attach source for 1.13.0?

@jonatan-ivanov jonatan-ivanov changed the title The source jar for micrometer 1.3.0 in the central repository appears to be wrong micrometer-core-1.13.0-sources.jar contains and extra main folder Jun 14, 2024
@jonatan-ivanov jonatan-ivanov changed the title micrometer-core-1.13.0-sources.jar contains and extra main folder micrometer-core-1.13.0-sources.jar contains an extra main folder Jun 14, 2024
@shakuzen shakuzen modified the milestones: 1.13.2, 1.13.x Jul 9, 2024
@jonatan-ivanov
Copy link
Member

jonatan-ivanov commented Jul 9, 2024

I investigated this a bit further, I found a simpler way of reproducing it (than the above) with micrometer-core (1.13.x) if I run sourcesJar and pTML (publishToMavenLocal) together:

./gradlew :micrometer-core:sourcesJar :micrometer-core:pTML -x check --console=plain --no-build-cache

If I run just one of these tasks or run them after each other in separate gradle commands, I cannot repro it so these are ok:

./gradlew :micrometer-core:sourcesJar -x check --console=plain --no-build-cache
./gradlew :micrometer-core:pTML -x check --console=plain --no-build-cache

It seems I can "fix" this by downgrading the Kotlin plugin(!), i.e. changing this line:

alias(libs.plugins.kotlin19)

to

alias(libs.plugins.kotlin17)

Here are the steps you should be able to repro this too (first checkout 1.13.x):

./gradlew clean
rm -rf ~/.gradle/caches/build-cache-1/
./gradlew :micrometer-core:sourcesJar :micrometer-core:pTML -x check --console=plain --no-build-cache
unzip -l micrometer-core/build/libs/micrometer-core-*-sources.jar | head -n20

Then downgrade the Kotlin plugin: alias(libs.plugins.kotlin17) instead of alias(libs.plugins.kotlin19) in micrometer-core/build.gradle and the main folder should be gone.

I tried to upgrade the Kotlin plugin from 1.9.23 to 1.9.24, it did not help.

There is another interesting thing I found, the META-INF folder contains only the MANIFEST.MF file when main is the root folder (I don't think this is a problem, the "norlam jar contains the necessary files").
When main folder is not present (Kotlin 1.7 plugin):

Archive:  micrometer-core/build/libs/micrometer-core-1.13.3-SNAPSHOT-sources.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  07-09-2024 13:24   META-INF/
      817  07-09-2024 13:24   META-INF/MANIFEST.MF
      762  07-09-2024 13:24   META-INF/micrometer-core.properties
        0  07-09-2024 11:50   META-INF/native-image/
        0  07-09-2024 11:50   META-INF/native-image/io.micrometer/
        0  07-09-2024 11:50   META-INF/native-image/io.micrometer/micrometer-core/
      871  07-09-2024 11:50   META-INF/native-image/io.micrometer/micrometer-core/reflect-config.json
      541  07-09-2024 11:50   META-INF/native-image/io.micrometer/micrometer-core/proxy-config.json
        0  11-17-2023 16:20   io/
        0  11-17-2023 16:20   io/micrometer/
        0  03-15-2024 14:07   io/micrometer/core/

When main folder is present (Kotlin 1.9 plugin):

Archive:  micrometer-core/build/libs/micrometer-core-1.13.3-SNAPSHOT-sources.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  02-01-1980 00:00   META-INF/
       25  02-01-1980 00:00   META-INF/MANIFEST.MF
        0  02-01-1980 00:00   main/
        0  02-01-1980 00:00   main/io/
        0  02-01-1980 00:00   main/io/micrometer/
        0  02-01-1980 00:00   main/io/micrometer/core/

@jonatan-ivanov
Copy link
Member

jonatan-ivanov commented Jul 9, 2024

It seems the kotlinSourcesJar task does this (it overwrites the jar generated by sourcesJar).
If kotlinSourcesJar runs first, there is no main folder:

./gradlew :micrometer-core:kotlinSourcesJar :micrometer-core:sourcesJar --no-build-cache

If sourcesJar runs first, the main folder is present:

./gradlew :micrometer-core:sourcesJar :micrometer-core:kotlinSourcesJar --no-build-cache

or just:

./gradlew :micrometer-core:sourcesJar --no-build-cache

and

./gradlew :micrometer-core:kotlinSourcesJar --no-build-cache

This seems to be the same issue: https://youtrack.jetbrains.com/issue/KT-54207/Kotlin-has-two-sources-tasks-kotlinSourcesJar-and-sourcesJar-that-archives-sources-to-the-same-artifact

Disabling kotlinSourcesJar resolves the issue.

@jonatan-ivanov jonatan-ivanov changed the title micrometer-core-1.13.0-sources.jar contains an extra main folder Disable kotlinSourcesJar since it conflicts with sourcesJar Jul 9, 2024
@jonatan-ivanov jonatan-ivanov modified the milestones: 1.13.x, 1.12.x, 1.12.9 Jul 9, 2024
@jonatan-ivanov
Copy link
Member

I think this should be fixed in earlier versions too (whenever we use the Kotlin plugin): 1.12.x since that's the oldest OSS supported branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A general bug build A change in our build-system
Projects
None yet
Development

No branches or pull requests

3 participants