I am trying to use a Grails Project as a Plugin to basically have my domain classes in the Plugin and then use them in multiple Grails projects.
I've done this:
grails create-app web
grails create-app plugin
create a settings.gradle in the root directory of both projects with include 'plugin', 'web'
then I added spring security to the plugin and used s2-quickstart to create a user and a role domain class and added some default users to the Bootstrap.groovy.
Starting the plugin project alone doesn't show any issues.
Now I added the plugin as a dependency to the web project: compile (':plugin') This way I can access the domain classes from the plugin inside the web project, it compiles fine. I added the spring config to the application.groovy and am now trying to use the domain classes from the plugin inside the web project.
Trying this however my project does not correctly start and it tells me this:
java.lang.IllegalStateException: Either class [htcommon.HtRole] is not a domain class or GORM has not been initialized correctly or has already been shutdown. If you are unit testing your entities using the mocking APIs
as soon as my code tries to do new HtRole(...).save()
It seems the domain classes from the plugin are not recognized as GORM classes somehow.
create-plugin
instead ofcreate-app
. Also, did import HtRole correctly using the correct namespace? – Treblegrails create-plugin plugin
not withcreate-app
. You really should read the documentation about how to create plugins before writing anything more. You've got a lot of things wrong here. – Visakhapatnamcompile (':web')
should becompile (':plugin')
I think. I'd have to see more of your code to give you more information about that. – Treble