Com.gradle.plugin-publish does not respect new Java Library configurations

plugins

(Mike Kobit) #1

implementation dependencies are not included in the generated POM when uploaded to the the plugin portal. I looked at the byte code and the DependenciesBuilder.buildMavenDependencies(ConfigurationContainer configurations) only uses compile and runtime configurations.

It is painful to figure these issues out as well because the plugin does not publish its sources or Javadoc. This bug and com.gradle.publish.PluginBundleExtension usability issue for Gradle Kotlin DSL are only a few of the issues I have ran into while trying to publish a plugin to the portal. Using the java-gradle-plugin is much simpler and straight forward. It would be useful to see the plugins converge, and hopefully see it be in open source as well because the last publish was in December.


(Pepper Lebeck-Jobe) #2

@mkobit,

Thanks for reporting this issue. It’s actually one we’re actively working on and hope to have a fix for complete with a new release of the publish-plugin sometime this week or next.


(Mike Kobit) #3

Thanks Pepper for the quick response and also for working on a new version.

I’ve been working on releasing the first version of https://github.com/mkobit/jenkins-pipeline-shared-libraries-gradle-plugin (a plugin written in Kotlin) to the plugin portal, but have ran into some issues so it may be a good candidate to include in whatever tests you are doing. Here are some of the things I’ve observed and tried with the plugin repository and an example consumer repository.

  1. Gradle test kit tests work using withPluginClasspath and the java-library-plugin for most of the build.gradle use cases I have tested (one issue with build.gradle.kts tests, but seems unrelated)

  2. When using maven-publish, running publishToMavenLocal and consuming from my local .m2 repository using the following pluginManagement in consumer can apply the plugin successfully (haven’t tried using it too much)

    pluginManagement {
      repositories {
        gradlePluginPortal()
      }
      maven {
        url = uri('file:///home/mkobit/.m2/repository')
      }
    }
    
  3. Running publishPlugins (after changing to compile dependencies for now) I see:

     > Task :publishPlugins
     Publishing plugin com.mkobit.jenkins.pipelines.shared-library version 0.1.0
     Publishing artifact build/libs/jenkins-pipeline-shared-libraries-gradle-plugin-0.1.0.jar
     Publishing artifact build/libs/jenkins-pipeline-shared-libraries-gradle-plugin-0.1.0-sources.jar
     Publishing artifact build/libs/jenkins-pipeline-shared-libraries-gradle-plugin-0.1.0-javadoc.jar
     Activating plugin com.mkobit.jenkins.pipelines.shared-library version 0.1.0 
    
  4. Consuming the newly published plugin (see example code here https://github.com/mkobit/jenkins-pipeline-shared-library-example) results in:

     FAILURE: Build failed with an exception.
     
     * Where:
     Build file '/home/mkobit/Workspace/personal/mkobit/jenkins-pipeline-shared-library-example/build.gradle.kts' line: 3
     
     * What went wrong:
     An exception occurred applying plugin request [id: 'com.mkobit.jenkins.pipelines.shared-library', version: '0.1.0']
     > Failed to apply plugin [id 'com.mkobit.jenkins.pipelines.shared-library']
     > Could not create plugin of type 'SharedLibraryPlugin'.
     > Could not initialize class com.mkobit.jenkins.pipelines.SharedLibraryPlugin
     
     * Try:
     Run with --info or --debug option to get more log output.
     
     * Exception is:
     org.gradle.api.plugins.InvalidPluginException: An exception occurred applying plugin request [id: 'com.mkobit.jenkins.pipelines.shared-library', version: '0.1.0']
     at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.exceptionOccurred(DefaultPluginRequestApplicator.java:252)
     at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:234)
     at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugins(DefaultPluginRequestApplicator.java:151)
     at org.gradle.kotlin.dsl.provider.KotlinBuildScriptCompiler.applyPluginsTo(KotlinBuildScriptCompiler.kt:216)
     at org.gradle.kotlin.dsl.provider.KotlinBuildScriptCompiler.executePluginsBlockOn(KotlinBuildScriptCompiler.kt:175)
     at org.gradle.kotlin.dsl.provider.KotlinBuildScriptCompiler.prepareTargetClassLoaderScopeOf(KotlinBuildScriptCompiler.kt:169)
     at org.gradle.kotlin.dsl.provider.KotlinBuildScriptCompiler.prepareAndExecuteScriptBodyOn(KotlinBuildScriptCompiler.kt:107)
     at org.gradle.kotlin.dsl.provider.KotlinBuildScriptCompiler.access$prepareAndExecuteScriptBodyOn(KotlinBuildScriptCompiler.kt:51)
     at org.gradle.kotlin.dsl.provider.KotlinBuildScriptCompiler$compileTopLevelScript$1.invoke(KotlinBuildScriptCompiler.kt:91)
     at org.gradle.kotlin.dsl.provider.KotlinBuildScriptCompiler$compileTopLevelScript$1.invoke(KotlinBuildScriptCompiler.kt:51)
     at org.gradle.kotlin.dsl.provider.KotlinScriptPlugin.apply(KotlinScriptPlugin.kt:48)
     at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:61)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
     at org.gradle.configuration.BuildOperationScriptPlugin.apply(BuildOperationScriptPlugin.java:58)
     at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
     at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
     at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
     at org.gradle.configuration.project.LifecycleProjectEvaluator.doConfigure(LifecycleProjectEvaluator.java:63)
     at org.gradle.configuration.project.LifecycleProjectEvaluator.access$100(LifecycleProjectEvaluator.java:33)
     at org.gradle.configuration.project.LifecycleProjectEvaluator$ConfigureProject.run(LifecycleProjectEvaluator.java:103)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
     at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:49)
     at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:651)
     at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:133)
     at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:35)
     at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:60)
     at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38)
     at org.gradle.initialization.DefaultGradleLauncher$ConfigureBuild.run(DefaultGradleLauncher.java:246)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
     at org.gradle.initialization.DefaultGradleLauncher.configureBuild(DefaultGradleLauncher.java:165)
     at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:124)
     at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:107)
     at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78)
     at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75)
     at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152)
     at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100)
     at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:75)
     at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
     at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
     at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
     at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
     at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
     at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
     at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:45)
     at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:29)
     at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)
     at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)
     at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:71)
     at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:45)
     at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:51)
     at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
     at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
     at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
     at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
     at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
     at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
     at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29)
     at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)
     at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42)
     at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:58)
     at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:33)
     at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
     at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
     at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
     at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
     at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
     at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
     at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
     at org.gradle.util.Swapper.swap(Swapper.java:38)
     at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
     at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
     at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
     at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
     at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)
     at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
     at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
     at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
     at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
     at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
     at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
     at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
     Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'com.mkobit.jenkins.pipelines.shared-library']
     at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:150)
     at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:125)
     at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator$3.run(DefaultPluginRequestApplicator.java:154)
     at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:230)
     ... 99 more
     Caused by: org.gradle.api.plugins.PluginInstantiationException: Could not create plugin of type 'SharedLibraryPlugin'.
     at org.gradle.api.internal.plugins.DefaultPluginManager.instantiatePlugin(DefaultPluginManager.java:74)
     at org.gradle.api.internal.plugins.DefaultPluginManager.producePluginInstance(DefaultPluginManager.java:183)
     at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:159)
     at org.gradle.api.internal.plugins.DefaultPluginManager.access$200(DefaultPluginManager.java:47)
     at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:252)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
     at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
     at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
     ... 102 more
     Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.mkobit.jenkins.pipelines.SharedLibraryPlugin
     at org.gradle.api.internal.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:56)
     at org.gradle.api.internal.plugins.DefaultPluginManager.instantiatePlugin(DefaultPluginManager.java:72)
     ... 111 more
     
     
     * Get more help at https://help.gradle.org
     
     BUILD FAILED in 0s
    
  5. Running buildEnvironment task in the consumer doesn’t seem right:

     > Task :buildEnvironment
     
     ------------------------------------------------------------
         Root project
     ------------------------------------------------------------
     
         classpath
     +--- com.gradle:build-scan-plugin:1.9
     \--- gradle.plugin.com.mkobit.jenkins.pipelines:jenkins-pipeline-shared-libraries-gradle-plugin:0.1.0
    

I’ve been abusing PLUGIN AUTHORS: You can now delete accidentally published plugins for up to 7 days! for the last few days to do publish/delete to see where the issue was (sorry!).


(Mike Kobit) #4

For completeness, I filed https://github.com/gradle/kotlin-dsl/issues/492 regarding the build.gradle.kts issue I mentioned at the the top of this response.


(Mike Kobit) #5

Looks like 0.9.8 was published last week.

I had to remove some of the previous dependencies from my Gradle cache due to bad POM from before, but it looks good so far.

Thanks @eljobe !