Search code examples
grailsgroovysemantic-versioning

Grails plugin version incompatibility warning


as per Grails official documentation, if I define the following grailsVersion on a plugin

def grailsVersion = "3.3.10 > *"

This means that the grails app on which this plugin is installed should be at least 3.3.10.

I acknowledged this based on this statement on the same official doc:

grailsVersion - The version range of Grails that the plugin supports. eg. "1.2 > *" (indicating 1.2 or higher)

But then I'm not able to understand the following log

2019-10-22 15:11:16.834 +0200 WARN  (ain) [ins.DefaultGrailsPluginManager] Plugin [myplugin:0.1.0-rc3] may not be compatible with this application as the application Grails version is less than the plugin requires. Plugin is compatible with Grails version 3.3.10 > * but app is 4.0.0

Other strange thing is that if I use

def grailsVersion = "3.0.0 > *"

Then no warnings are there... Which is inline with grails doc.

So either I'm misunderstanding or something weird is happening whe using grailsVersion=3.3.10


Solution

  • The reason is when DefaultGrailsPluginManager is converting the grails version in a very simple way and in this case is failing - the grailsVersion is converted to 3310 and 400 (stripping the .'s) - 400 < 3310

    It also explains why 3.0.0 works (3.3.0 -> 300). 400 > 300

    You can see the logic here https://github.com/grails/grails-core/blob/master/grails-core/src/main/groovy/grails/plugins/DefaultGrailsPluginManager.java#L378

    And the string to version number here - https://github.com/grails/grails-core/blob/master/grails-core/src/main/groovy/grails/plugins/DefaultGrailsPluginManager.java#L421

    I would open an issue on grails-core with the details or even better open a PR to fix.