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

In Gradle 8.0, plugin doesn't work together with gradle-docker-plugin #421

Open
3ric-T opened this issue Feb 17, 2023 · 6 comments
Open

Comments

@3ric-T
Copy link

3ric-T commented Feb 17, 2023

Expected Behavior

As a user of gradle-ospackage-plugin plugin,
I want to have a plugin which runs together with latest version of gradle-docker-plugin under version 8.0 of gradle wrapper
So that I can build both Docker images and RPM packages of my application in the same project

Current Behavior

Build fails with the following error:

Build file '/home/erict/workspaces_xxx/xxx/build.gradle.kts' line: 13

An exception occurred applying plugin request [id: 'com.bmuschko.docker-remote-api', version: '9.2.1']
> Failed to apply plugin 'com.bmuschko.docker-remote-api'.
   > Using internal convention mapping with a Provider backed property.
     Consult the upgrading guide for further information: https://docs.gradle.org/8.0/userguide/upgrading_version_7.html#convention_mapping

Partial stacktrace is:

* Exception is:
org.gradle.api.plugins.InvalidPluginException: An exception occurred applying plugin request [id: 'com.bmuschko.docker-remote-api', version: '9.2.1']
	(...)
	at Program.execute(Unknown Source)
	(...)
	at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:130)
	at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:42)
	(...)
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin 'com.bmuschko.docker-remote-api'.
	... 189 more
Caused by: org.gradle.api.GradleException: Using internal convention mapping with a Provider backed property. Consult the upgrading guide for further information: https://docs.gradle.org/8.0/userguide/upgrading_version_7.html#convention_mapping
	(...)
    com.netflix.gradle.plugins.docker.OsPackageDockerBasePlugin$_createTasks_closure1.doCall(OsPackageDockerBasePlugin.groovy:43)
	(...)
	at com.netflix.gradle.plugins.docker.OsPackageDockerBasePlugin.createTasks(OsPackageDockerBasePlugin.groovy:41)
	(...)
	at com.netflix.gradle.plugins.docker.OsPackageDockerBasePlugin.this$dist$invoke$1(OsPackageDockerBasePlugin.groovy)
	at com.netflix.gradle.plugins.docker.OsPackageDockerBasePlugin$2.methodMissing(OsPackageDockerBasePlugin.groovy)
	(...)
	at com.netflix.gradle.plugins.docker.OsPackageDockerBasePlugin$2.execute(OsPackageDockerBasePlugin.groovy:33)
	at com.netflix.gradle.plugins.docker.OsPackageDockerBasePlugin$2.execute(OsPackageDockerBasePlugin.groovy)
	... 192 more

Full stacktrace is attached to the issue

With version 7.6 of Gradle, there is no issue. It seems that you are using an outdated version of docker-remote-api in root build.gradle file:

implementation 'com.bmuschko:gradle-docker-plugin:3.2.1'

and it can be related to the deprecation of some convention mapping as stated in the error message.

Context

Simple declaration of the plugin, via version catalog file libs.versions.toml:

[versions]
dockerRemoteApiPluginVersion  = "9.2.1"
ospackagePluginVersion        = "11.0.0"  # Released on 04 Jan 2023

[libraries]

[bundles]

[plugins]
dockerRemoteApi = { id = "com.bmuschko.docker-remote-api", version.ref="dockerRemoteApiPluginVersion" }
osPackage       = { id = "com.netflix.nebula.ospackage", version.ref="ospackagePluginVersion" }

Steps to Reproduce (for bugs)

Just declare the plugin as above in build file with Kotlin DSL. Any call to a Gradle task make it fail.
IntelliJ IDEA project is attached to the issue, so that the bug can be easily reproduced.

Your Environment

Gradle 8.0
Openjdk version "17.0.5"

@3ric-T
Copy link
Author

3ric-T commented Feb 17, 2023

  • First option is to bump gradle-docker-plugin from version 3.2.1 to latest 9.2.1.
    In this case, build fails with java.lang.UnsupportedClassVersionError and without any experience in groovy, I don't know how to deal with.
  • Second option is to get rid of all the code linked to Docker packaging, as it hasn't been touched for years.

@karbi
Copy link

karbi commented Feb 28, 2023

@3ric-T Thanks for submitting this issue

I have the same problem. Unfortunately I'm not familiar enough with plugin development to resolve this properly. However I come with workaround and decided to use some ugly hack to resolve this ASAP. I'm using only part of `gradle.ospackage.plugin', so I'm not applying it, but manually registering only required parts. I wasn't testing generated package yet, but it looks valid. Here is part of my build.gradle script:

plugins {
    id 'com.netflix.nebula.ospackage' version '11.0.0' apply false
    id 'com.bmuschko.docker-remote-api' version '9.2.1'
    id 'java'
}

var extension = project.extensions.create('ospackage', com.netflix.gradle.plugins.packaging.ProjectPackagingExtension, project)
com.netflix.gradle.plugins.rpm.RpmPlugin.applyAliases(extension)
project.plugins.apply(com.netflix.gradle.plugins.rpm.RpmPlugin)
project.tasks.register('buildRpm', com.netflix.gradle.plugins.rpm.Rpm)

@3ric-T
Copy link
Author

3ric-T commented Mar 1, 2023

Thanks for this workaround, @karbi !
It will be very useful, indeed, as you, I'm using only the RPM part of the ospackage plugin.
On the other hand, it seems that the affected lines are in an abandoned piece of code. Instead of deleting this part, I tried to comment out the line that caused the error. After that, it works perfectly with the docker plugin. So I intend to submit a patch in the next few days to fix this problem.

@gjvoosten
Copy link

@3ric-T Anything happening on this issue?

@3ric-T
Copy link
Author

3ric-T commented Jul 5, 2023

@gjvoosten No news unfortunately.

We finally migrate from

[versions]
ospackagePluginVersion        = "11.0.0"

[plugins]
osPackage       = { id = "com.netflix.nebula.ospackage", version.ref="ospackagePluginVersion" }

to

[versions]
ospackagePluginVersion        = "11.3.0"

[plugins]
osPackage       = { id = "com.netflix.nebula.rpm", version.ref = "ospackagePluginVersion" }``` 

which seems to be the RPM dedicated part of the preceding but packaged alone. So it does not suffer from the bug.

@gjvoosten
Copy link

Thanks @3ric-T, as it happens we also only need Rpm, so we'll be making the same change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants