gradle / plugin-portal-requests

Gradle Plugin Portal issues and requests.
https://plugins.gradle.org/
12 stars 8 forks source link

Determine whether plugin should be published to Gradle Plugin Portal or not #224

Closed timplifier closed 4 months ago

timplifier commented 4 months ago

Generating Gradle tasks for publishing should be determined whether plugin should be published or not. It would be good if you are developing custom plugin because having composite build with your plugins that are intended for internal use are also gonna have those publish tasks because you have applied gradle-publish plugin. Because of that, you would need to create separate module just to publish the plugin. Of course I rely on publishPlugins task.

Expected Behavior

gradlePlugin {
    plugins {
        create(libs.plugins.cleanwizard.multimodule.pluginId) {
            shouldPublish = false 
            id = multimodule.pluginId
            implementationClass = pluginConfiguration.multimodule.implementation.get()
            displayName = "Clean Wizard Multi Module Plugin"
            description =
                "This plugin is required for Clean Wizard Kotlin Symbol Processor multi-module class generation. " +
                        "If your project is single-module, no need to apply it" +
                        ". It allows you" +
                        "to generate classes in various modules, so if you have data, domain and presentation modules and want to generate classes" +
                        " for each module, use this plugin. "
            tags.set(
                listOf(
                    "kotlin",
                    "ksp",
                    "kotlin-symbol-processing",
                    "android",
                    "clean-architecture",
                    "domain-model",
                    "ui-model",
                    "dto-entity-mapper",
                )
            )
        }
    }
}

Current Behavior

Currently, it is not possible to determine whether plugin should be published or not if you have multiple plugins inside one .build.gradle.kts lets say with gradle-publish plugin inside it. I had to create a separate module just for the sake of publishing. Moreover, I need to duplicate the code for plugins because I also have to test the plugin locally.

Context

I want to make it easier to manage which plugins are gonna be published or not by using simple shouldPublish property that is true or false. I think that it is pretty much easy to make and I can do it myself if you allow me to.

ov7a commented 4 months ago

We need more information to understand the request. Could you please provide more context about what you want to achieve?

If we receive a clear use case description, we may be able to suggest a workaround.


Sorry, I'm not sure if I understand your use case.

First of all, the plugin is published when the publishPlugins task is executed. If you don't want to publish it, you can just skip/exclude the task from your workflow.

Second, if the plugin is never intended to be published, can it be transformed to Convention Plugin?

timplifier commented 4 months ago

I mean, this publishPlugins task is not created for every separate plugin, but for all plugins defined under gradlePlugin block. Take a look at this build-logic module https://github.com/Timbermir/clean-wizard/tree/2.0.0/build-logic

ov7a commented 4 months ago

publishPlugins task is not created for every separate plugin, but for all plugins defined under gradlePlugin block.

If you don't want to publish a plugin, then why is the plugin registered in the publishing block?

If you want to publish plugins separately, you can use multi-project setup.

timplifier commented 4 months ago

Yup, already did it. Created another composite build, works like a charm, thank you for your time.