question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gradle 6.5.1: 'Could not find any convention object of type JavaPluginConvention'

See original GitHub issue

Environment: macOS, openjdk@11, SpringBoot 2.2.2.RELEASE

  • Jib version: 2.4.0
  • Build tool:
$ gradle --version

------------------------------------------------------------
Gradle 6.5.1
------------------------------------------------------------

Build time:   2020-06-30 06:32:47 UTC
Revision:     66bc713f7169626a7f0134bf452abde51550ea0a

Kotlin:       1.3.72
Groovy:       2.5.11
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          11.0.8 (Oracle Corporation 11.0.8+11)
OS:           Mac OS X 10.15.6 x86_64

  • OS:
$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.15.6
BuildVersion:	19G73

Description of the issue: Thanks for making Jib, it’s a nice improvement over the naive Dockerizing a JAR approach I was heretofore using.

I recently inherited a Gradle project and trying to deploy it using Jib. The trouble is, adding the Jib plugin and running it seems to fail, and I’m not sure what’s wrong. As I understand it, installing Jib (and most Gradle plugins) should usually be a matter of adding jib to the plugins section of the root build.gradle, like so:

plugins {
    id "net.ltgt.apt" version "0.20"
    id "io.spring.dependency-management" version "1.0.8.RELEASE"
    id "com.google.cloud.tools.jib" version "2.4.0"
}

However when I do that, gradle jib fails, in fact gradle by itself fails too. I added another plugin as an experiment (id "org.ajoberstar.pipeline-test" version "0.2.0-rc.13") and gradle still worked OK, so something about Jib seems to be a factor.

$ gradle

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'MyApplication'.
> Could not find any convention object of type JavaPluginConvention.

Meanwhile I was able to get Jib 2.4.0 working in a separate SpringBoot/Maven project, also Java 11, same machine, etc. So I suspect something related to Gradle+Jib interaction. Feels like it’s probably not a Jib bug but something related to Gradle or perhaps this project. Not enough of a Java or Gradle expert to know what to do next…any tips would be appreciated. Thanks!

Expected behavior: gradle jib --image=example should work in the usual way.

Steps to reproduce: These repro steps are a ‘best guess’ b/c I am awaiting permission to share the source. I can, however, share the build.gradle and that’s included below.

  1. Create a Gradle springboot project running 2.2.2.RELEASE
  2. Add id "com.google.cloud.tools.jib" version "2.4.0" to build.gradle:plugins
  3. Run gradle

build.gradle contents:

plugins {
    id "net.ltgt.apt" version "0.20"
    id "io.spring.dependency-management" version "1.0.8.RELEASE"
    id "com.google.cloud.tools.jib" version "2.4.0"
}

ext {
    springBootVersion = "2.2.2.RELEASE"
    testcontainers = "1.12.0"
}

subprojects {
    apply plugin: "java"
    apply plugin: "net.ltgt.apt-idea"
    apply plugin: "io.spring.dependency-management"

    dependencyManagement {
        imports { mavenBom("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") }
    }

    group = "com.example.application"
    version = "2.1.0"
    sourceCompatibility = "11"
    targetCompatibility = "11"

    repositories {
        mavenCentral()
    }

    configurations {
        developmentOnly
    	runtimeClasspath {
    		extendsFrom developmentOnly
    	}
        compileOnly {
            extendsFrom annotationProcessor
        }
    }

    dependencies {
        compileOnly "org.projectlombok:lombok"
        testCompileOnly "org.projectlombok:lombok"
        annotationProcessor "org.projectlombok:lombok"
        testAnnotationProcessor "org.projectlombok:lombok"
    }
}

Log output: If it’s helpful please just ask, happy to provide.

Additional Information: Convention object, JavaPluginConvention 🤔 not sure what that means… https://docs.gradle.org/current/javadoc/org/gradle/api/plugins/JavaPluginConvention.html

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
loosebazookacommented, Jul 30, 2020

It looks like you’re applying the jib plugin on the root project (which as far as I can tell, you don’t want).

You root build.gradle could do something like

plugins {
   ...
    id "com.google.cloud.tools.jib" version "2.4.0" apply "false"
   ...
}

subprojects {
   ...
   apply plugin "com.google.cloud.tools.jib"
   ...
}

The error is just saying that the project you are applying jib on doesn’t have the java plugin applied (since that’s only applied on subprojects).

1reaction
loosebazookacommented, Jul 30, 2020

@onpaws I see that you’ve put a 👍 on the answer. I will close this issue for now. Please reopen if this issues persists or create a new issue if you encounter something new.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gradle MPP + Kotlin Native: Could not find any convention ...
IllegalStateException : Could not find any convention object of type JavaPluginConvention. at org.gradle.api.internal.plugins.DefaultConvention.getPlugin(
Read more >
JavaPluginConvention - Gradle DSL Version 7.6
Returns a file pointing to the root directory supposed to be used for all docs. docsDirName. The name of the docs directory. Can...
Read more >
Upgrading your build from Gradle 4.x to 5.0
This chapter provides the information you need to migrate your older Gradle 4.x builds to Gradle 5.0. In most cases, you will need...
Read more >
userguide.pdf - Gradle User Manual
Gradle makes common types of projects easy to build through conventions. ... Gradle ships with its own Groovy library, therefore Groovy does not...
Read more >
Upgrading your build from Gradle 6.x to the latest
This is so that you can see any deprecation warnings that apply to your build. ... on object of type org.gradle.api.internal.artifacts.dsl.dependencies.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found