I have an internal grails plugin that has some tes...
# questions
u
I have an internal grails plugin that has some tests that require domain entities. These domain entities are only required to test the plugin code and are not useful to the main project. Is there a way to configure either (a) move test-domain entities out of grails-app/domain and later promote them to domain object when under test environment - or (b) suppress these from being dragged into the main project somehow? Thx
j
why not create a gradle project with just the test dependencies that uses your plugin?
u
That's what I'm having to do... I'm aiming for
myapp.myplugin-support
and
myapp.myplugin-support-test
I just wondered how all the other plugin authors managed to test their plugins without pushing random domain objects to the plugin users?
j
Usually you want different test scenarios, you can easily configure a plugin to not export ocnfiguration, but when it comes to compiled code, a gradle project is that division
you can technically put testImplementation <your gradle project with domains>, but usually you want to test a plugin like other users would
A lot of the "best" plugin practices are seen in this project: https://github.com/longwa/build-test-data
where the plugin is defined as it's own gradle project
and then there's an examples directory with projects that test the plugin
u
Thank you @jdaugherty very helpful info
j
I have a todo in my backlog to write a section in the grails doc for best plugin practices
but i haven't gotten around to it yet
but you can see grails-core, grails-spring-security, & grails-redis have all adopted this strategy
Grails web console is another example: https://github.com/grails-plugins/grails-web-console
u
My client doesn't have any artefact distribution so everything is in-tree. Was attempting ot cut down a bit of noise.
j
you don't need to distribute the test examples, in fact you probably never want to
the multiproject gradle build is how best to model that
all of those links have a plugin / examples directory
u
Indeed - it's because of the lack of artifact distribution that everytihng is in tree, one subproject for the plugin but now another subproject just to test the plugin. (with the adjacent apps depending on the plugin alone)
j
here's the thing people don't consider, having a single app split into several gradle projects will greatly reduce the compilation time / time to development. The groovy incremental compiler isn't the best, but gradle is amazing at caching and only running when code changes. So by having a multiproject build, you can actually save development time.
but that does require you following gradle project best practices - don't use eager registration, etc
u
😎 thanks again for your help
👍 1