Skip to content

Could not apply requested plugin error when using version 1.3.1 of Gradle plugin 'org.jsonschema2pojo' #1769

Closed

Description

@NilsDammenhayn

Upgrading to 1.3.0 worked fine. But setting the version to 1.3.1 and doing a Gradle-refresh provides this error:

Could not apply requested plugin [id: 'org.jsonschema2pojo', version: '1.3.1'] as it does not provide a plugin with id 'org.jsonschema2pojo'. This is caused by an incorrect plugin implementation. Please contact the plugin author(s).
> Plugin with id 'org.jsonschema2pojo' not found.

Using Java 17 with Gradle 9.3.1.

Activity

  1. digsim commented on Feb 2, 2026

    @digsim

    Same issue here with gradle 9.3.1 (and Java 21)

  2. joelittlejohn commented on Feb 2, 2026

    @joelittlejohn
    Owner

    Thanks for raising this! I had to resolve a duplicate resource problem and it appeared that a file was not needed, but clearly it was. I'm surprised that our 'example' project did not pick this up.

  3. added this to the 1.3.2 milestone on Feb 2, 2026
  4. unkish commented on Feb 2, 2026

    @unkish
    Collaborator

    Would it be possible to provide a minimal working example of failing build ?

  5. joelittlejohn commented on Feb 2, 2026

    @joelittlejohn
    Owner

    I actually can't replicate this issue @NilsDammenhayn @digsim. I've tried with 1.30 and 1.3.1, using both Gradle 8.9 and Gradle 9.3.1. Could you show us how you are using the plugin in your build.gradle? Or provide a minimal example as @unkish says?

  6. digsim commented on Feb 2, 2026

    @digsim

    I'll try to provide a minimal example this evening after work. We use the plugin like

    plugins {
        id "org.openapi.generator" version "${OPENAPI_GENERATOR_VERSION}"
        id "java" // required for jsonschema2pojo
        id "org.jsonschema2pojo" version "${JSONSCHEMA2POJO_VERSION}"
    }
    ...
    ...
    // All parameters: https://github.com/joelittlejohn/jsonschema2pojo/tree/master/jsonschema2pojo-gradle-plugin
    jsonSchema2Pojo {
        // /!\ The files need to be in different sub-folders in the specs/jsonschemas folder in order to have different
        // packages to avoid name conflicts
        source = files("$rootDir/specs/jsonschemas")
        targetDirectory = project.layout.buildDirectory.dir("generated/js2p").get().asFile
        targetPackage = 'com.acme.model'
        useBigDecimals = true
        useJakartaValidation = true
        targetVersion = "21"
        dateType = "java.time.LocalDate"
        dateTimeType = "java.time.LocalDateTime"
        formatDateTimes = false
        includeHashcodeAndEquals = false
    }
    sourceSets.main.java.srcDirs += "build/generated/js2p"
    ...
    ...
    

    However, I don't think that the jsonSchema2Pojo is even relevant since gradle complains about the line id "org.jsonschema2pojo" version "${JSONSCHEMA2POJO_VERSION}"

    On a side note, we're using the plugin in a multi-module gradle build. I.E we have a structure similar to:

    ├ specs
    │   └── jsonschemas
    ├ java-modules
    │   ├── base
    │   │   └── src
    │   │   └── build.gradle
    │   └── rest-service
    │   │   └── src
    │   │   └── build.gradle
    |── build.gradle 
    

    The snippet above comes from the build.gradle file located in the rest-service subproject folder.

  7. NilsDammenhayn commented on Feb 2, 2026

    @NilsDammenhayn
    Author

    @joelittlejohn I'll try to provide an example tonight!

  8. digsim commented on Feb 2, 2026

    @digsim

    Out of curiosity I tried version 1.3.0 since we went from 1.2.2 directly to 1.3.1 and there I see a different issue:

    * What went wrong:
    Execution failed for task ':rest-service:generateJsonSchema2Pojo'.
    > class org.apache.commons.lang3.Strings$CsStrings tried to access method 'int org.apache.commons.lang3.CharSequenceUtils.indexOf(java.lang.CharSequence, java.lang.CharSequence, int)' (org.apache.commons.lang3.Strings$CsStrings is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @63d617f3; org.apache.commons.lang3.CharSequenceUtils is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @664218d2)
    
    

    BTW with version 1.3.1 I can't even do a ./gradlew tasks without getting

    Could not apply requested plugin [id: 'org.jsonschema2pojo', version: '1.3.1'] as it does not provide a plugin with id 'org.jsonschema2pojo'. This is caused by an incorrect plugin implementation. Please contact the plugin author(s).
    > Plugin with id 'org.jsonschema2pojo' not found.
    
  9. NilsDammenhayn commented on Feb 2, 2026

    @NilsDammenhayn
    Author

    I've created this branch. 1.3.0 works fine, changing that version in gradle/libs.versions.toml to 1.3.1 produces the error

  10. unkish commented on Feb 2, 2026

    @unkish
    Collaborator

    I've looked at @NilsDammenhayn repo branch and indeed it fails.
    Failure though is due to jsonschema2pojo-gradle-plugin-1.3.1.jar being a tiny bit different:

    The one on maven central does not have META-INF/gradle-plugins/org.jsonschema2pojo.properties

    A way to make sure that gradle loads plugins from gradle plugin portal is to change model/build.gradle.kts from:

    buildscript {
      repositories {
        mavenCentral()
      }
    }

    to

    buildscript {
      repositories {
        gradlePluginPortal()
        mavenCentral()
      }
    }
    
  11. digsim commented on Feb 2, 2026

    @digsim

    Indeed, the root-cause is similar on my side. I'm using JFrog as a proxy for all artifact resolution, and I had to re-setup the gradlePluginPortal repo. That proxy has been in place for some years and always worked. Can't explain why it broke today for exactly this dependency...

  12. unkish commented on Feb 2, 2026

    @unkish
    Collaborator

    Can't explain why it broke today for exactly this dependency

    I'll speculate that this is most probably due to JFrog proxying artifact resolution from maven central (maybe even having gradle plugin portal as a failover).
    As version 1.3.1 itself is present in maven central but artifact is missing a org.jsonschema2pojo.properties file - build fails.

  13. NilsDammenhayn commented on Feb 2, 2026

    @NilsDammenhayn
    Author

    Thanks for the workaround @unkish !
    One more hint for others: the order of the repositories is important, gradlePluginPortal has to be checked first here.

  14. unkish commented on Feb 2, 2026

    @unkish
    Collaborator

    Thanks for the workaround @unkish ! One more hint for others: the order of the repositories is important, gradlePluginPortal has to be checked first here.

    Just a minute note: it seems to be in case when buildscript repositories is used.
    I've tried your example with following model/build.gradle.kts:

    plugins {
      alias(libs.plugins.jsonSchema2Pojo)
    }
    
    repositories {
        mavenCentral()
    }
    ...

    Note how there is no

    buildscript {
      repositories {
        mavenCentral()
      }
    }

    in the beginning of the script and jsonSchema2Pojo plugin got downloaded from gradle plugin portal.

    P.S. Thank you for providing a reproducer.

  15. changed the title [-]Version 1.3.1 does not provide a plugin with id 'org.jsonschema2pojo'[/-] [+]Could not apply requested plugin error when using version 1.3.1 of Gradle plugin 'org.jsonschema2pojo'[/+] on Feb 2, 2026
  16. joelittlejohn commented on Feb 2, 2026

    @joelittlejohn
    Owner

    I remember intimately now having to solve this in the past, because depending on the order of repositories some people will get the jar from the maven central and some from the Gradle plugin portal. Publishing to maven central happens differently but we need to make sure that the same metadata is included in both cases.

    This metadata is generated during Gradle publishing, but I had forgotten that the reason this same metadata is included as a file in the project is that it's needed within the jar that goes to Maven Central. Newer versions of Gradle complain about a duplicate file, so I just need to solve this another way.

  17. joelittlejohn commented on Feb 2, 2026

    @joelittlejohn
    Owner

    @digsim Did you get to the bottom of this one:

    * What went wrong:
    Execution failed for task ':rest-service:generateJsonSchema2Pojo'.
    > class org.apache.commons.lang3.Strings$CsStrings tried to access method 'int org.apache.commons.lang3.CharSequenceUtils.indexOf(java.lang.CharSequence, java.lang.CharSequence, int)' (org.apache.commons.lang3.Strings$CsStrings is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @63d617f3; org.apache.commons.lang3.CharSequenceUtils is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @664218d2)
    

    If there's some other issue I'd rather try to fix it before releasing 1.3.2.

  18. digsim commented on Feb 2, 2026

    @digsim

    @joelittlejohn all good, that was a follow-up error due to another library still pulling in an old version of commons-lang3 and could easily be fixed. A quick look at where the classes were loaded gave me enough insights to fix the issue.

  19. added a commit that references this issue on Feb 2, 2026
    fc5b3e3
  20. joelittlejohn commented on Feb 2, 2026

    @joelittlejohn
    Owner

    This should now be fixed, give 1.3.2 a try 👍

  21. digsim commented on Feb 3, 2026

    @digsim

    I reverted back to the Maven style repo definition in Artifactory and tried 1.3.2 which resolves fine. I'll still keep the new Gradle style definition for now to be safe for the future. Thanks for your fast support.

  22. NilsDammenhayn commented on Feb 3, 2026

    @NilsDammenhayn
    Author

    Works here too, thank you very much! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions