JetBrains / intellij-platform-gradle-plugin

Gradle plugin for building plugins for IntelliJ-based IDEs
https://plugins.jetbrains.com/docs/intellij/gradle-prerequisites.html
Apache License 2.0
1.42k stars 270 forks source link

Publishing a plugin with the Maven Publish plugin do not take into account `buildSearchableOptions = false` #1687

Open mr-thierry opened 2 months ago

mr-thierry commented 2 months ago

What happened?

I have a plugin that needs to be publish to an internal Maven repo. To publish to this repo I'm using the Maven Publish plugin.

I configure my plugin like so:

intellijPlatform {
    buildSearchableOptions = false
}

This is how the Maven Publish plugin is configured:

publishing {
    publications {
        create<MavenPublication>("plugin") {
            groupId =  "groupId"
            artifactId = "artifactId"
            version = "1.0.0"

            from(components["java"])
        }
    }
}

When I call the task:

./gradlew publishPluginPublicationToMavenLocal

It fails with the following error:

 /…plugin/build/libs/plugin-1.0-SNAPSHOT-searchableOptions.jar (No such file or directory)

I believe the task that generates the JAR files is not properly configured, and as such the Maven Publish plugin cannot find it.

Relevant log output or stack trace

No response

Steps to reproduce

See the description

Gradle IntelliJ Plugin version

2.0.0-beta8

Gradle version

8.8

Operating System

None

Link to build, i.e. failing GitHub Action job

No response

hsz commented 2 months ago

The jar task produces just the first version of Jar fine, which is later still enhanced — with instrumented code or merged with other submodules. Currently, components["java"] gives you just the bad Jar file.

What I could do here is introduce a custom intellijPlatform component you could use with components["intellijPlatform"].

The searchable options jar case — this is clearly an issue I have to address.

However, the final plugin Zip archive we publish to JetBrains Marketplace is a bit more than just a jar — or contains also other dependencies, submodules, resources, etc.

What's the exact reason for publishing the plugin to Maven Central?

mr-thierry commented 2 months ago

@hsz I am not publishing to Maven Central. I am publishing to an internal Maven repository (artifactory) to deliver my plugin internally.

brian-mcnamara commented 2 months ago

Chiming in here too. My plugin has submodules, which one of them contains shared logic that does not produce any searchable options, so the searchable options task fails for those modules, however disabling the searchable options results in this issue too.

hsz commented 2 months ago

My plugin has submodules

Do you apply there org.jetbrains.intellij.platform.module? This is a limited set of tasks and setups that should be applied to submodules.

brian-mcnamara commented 2 months ago

Do you apply there org.jetbrains.intellij.platform.module? This is a limited set of tasks and setups that should be applied to submodules.

Ahh, I did not know that... Let me play with that

hfhbd commented 1 month ago

BTW if you want to publish your plugin to maven central (or any other repo that requires javadoc/sources jar), you also need to include them:

publications.register<MavenPublication>("mavenJava") {
  from(components["intellijPlatform"])
  artifact(tasks.named("sourcesJar"))
  artifact(tasks.named("javadocJar"))
}