fabric-loom icon indicating copy to clipboard operation
fabric-loom copied to clipboard

Consider keeping dependency injection for manual publications.

Open blackd opened this issue 2 years ago • 6 comments

Hi, I'm getting this nice message Loom is applying dependency data manually to publications instead of using a software component (from(components["java"])) I've looked at the Loom sources and it makes sense to remove the dependency injection. However I have artefact that is combination from parts build by several subprojects so from(components["java"]) is not really a possibility for me.

blackd avatar Nov 05 '21 18:11 blackd

Yes, thats correct, you can use loom.disableDeprecatedPomGeneration(publishing.publications.mavenJava) to disable this warning.

The plan is to remove this workaround after the deprecated behavour has been removed, its not ideal but its the best that can be done. (Let me know if you think otherwise?)

You can see a working example of this here: https://github.com/FabricMC/fabric/pull/1802

Let me know if that helps or you have any more issues.

modmuss50 avatar Nov 05 '21 18:11 modmuss50

My project structure is:

  • main-project:
    • common - common sources for all platforms
    • platforms
      • fabric 1.15 - version specific code
      • fabric 1.16 - ...
      • fabric 1.17 - ..
      • ...

As you can imagine every subproject in platforms has a publication. However the source artefact is a combination of the sources in common and the version specific stuff and the javadoc artefact comes only from common. So I have to manually define the publication to accommodate the above.

So I would prefer that the deprecated behaviour stays :smile:. May be leave it in but disabled by default.

Of course the other solution will be to recreate what net.fabricmc.loom.configuration.MavenPublication does in my build scripts I haven't read through but I guess it's possible.

blackd avatar Nov 05 '21 19:11 blackd

Going to CC @Juuxel in here as they made the change.

Im not against leaving the deprecated behaviour in (and removing the message), as its not really wrong but might be hard to maintain?

modmuss50 avatar Nov 05 '21 19:11 modmuss50

@blackd The publications in your project tree should be possible with standard software components (components.java/components["java"]) afaik:

  • You can disable the javadoc jar in the platform jar subprojects and add the common sources to the standard sources jar with from zipTree(project(":common").tasks.sourcesJar.archiveFile) (or something similar) or
  • You can disable both gradle's default sources jar and javadoc jar, then add your own and just add the files to the publication as you would without software components. (You can always add stuff to the defaults made by software components).

@modmuss50 It honestly might be fine to have the legacy option in the future, but as opt-in. What I mostly disliked about the old system (apart from the bugs I fixed there too) was that it automatically does changes to publications without being told to. I could imagine there being something like

publishing {
    publications {
        maven(MavenPublication) { p ->
            loom.setupPom p // or a more accurate name if loom does something else too; can't remember right now
            // could also be called setupNoComponentPublication or something
        }
    }}
}

Juuxel avatar Nov 05 '21 21:11 Juuxel

@Juuxel I think I've started without java doc and sources artefacts using from(components.... but something in the generated pom didn't match the requirements for publishing on maven central. TBH since I took over the mod I've spend more time fighting gradle then developing the mod. At some point I just gave up on making the "right" way.

Any way whether it stays or not is up to you guys. In both cases I'll manage 😂

blackd avatar Nov 05 '21 21:11 blackd

something in the generated pom didn't match the requirements for publishing on maven central

Hmm, it could be that you're missing some metadata (project description, URLs, authors etc) that can be added with gradle's usual API, not sure though

Juuxel avatar Nov 08 '21 00:11 Juuxel