From 21d2e9b4b82c889ef4459d35871c7b470049e1d2 Mon Sep 17 00:00:00 2001 From: Sachin Verma Date: Tue, 3 Dec 2024 16:29:57 +0530 Subject: [PATCH] Add Grails mail 4.0.0 plugin support. (#8) * Add Grails mail 4.0.0 plugin support. Move AsynchronousMailService.groovy to src folder to save it from SendMail trait enrich. * Fix failing test case due to metaclass methods access etc. --- README.md | 6 ++++++ build.gradle | 2 +- .../plugin/asyncmail/AsynchronousMailGrailsPlugin.groovy | 2 ++ .../grails/plugin/asyncmail/AsynchronousMailService.groovy | 0 .../plugin/asyncmail/CompareMessageBuilderSpec.groovy | 2 +- 5 files changed, 10 insertions(+), 2 deletions(-) rename {grails-app/services => src/main/groovy}/grails/plugin/asyncmail/AsynchronousMailService.groovy (100%) diff --git a/README.md b/README.md index feb5a19..63303c4 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,12 @@ Installation To install just add the plugin to the plugins block of `build.gradle`: +For Grails 6.x.x +```groovy +implementation "io.github.gpc:asynchronous-mail:4.0.0-SNAPSHOT" +``` + + For Grails 5.x.x ```groovy implementation "io.github.gpc:asynchronous-mail:3.1.2" diff --git a/build.gradle b/build.gradle index 0154db1..c711a4b 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,7 @@ dependencies { implementation 'org.grails.plugins:hibernate5' implementation 'org.hibernate:hibernate-core:5.6.15.Final' implementation 'org.grails.plugins:gsp' - implementation 'org.grails.plugins:mail:3.0.0' + implementation 'org.grails.plugins:mail:4.0.0' // This is needed for the quartz-plugin on grails >= 4.0.x, https://github.com/grails-plugins/grails-quartz/issues/107#issuecomment-575951471 implementation('org.quartz-scheduler:quartz:2.3.2') { exclude group: 'slf4j-api', module: 'c3p0' } implementation 'org.grails.plugins:quartz:2.0.13' diff --git a/src/main/groovy/grails/plugin/asyncmail/AsynchronousMailGrailsPlugin.groovy b/src/main/groovy/grails/plugin/asyncmail/AsynchronousMailGrailsPlugin.groovy index 67f9f1a..5acceb0 100644 --- a/src/main/groovy/grails/plugin/asyncmail/AsynchronousMailGrailsPlugin.groovy +++ b/src/main/groovy/grails/plugin/asyncmail/AsynchronousMailGrailsPlugin.groovy @@ -13,6 +13,7 @@ import org.quartz.TriggerKey class AsynchronousMailGrailsPlugin extends Plugin { def grailsVersion = "6.0.0 > *" + def dependsOn = [mail: "* > 4.0.0"] def loadAfter = ['mail', 'quartz', 'hibernate', 'hibernate3', 'hibernate4', 'hibernate5', 'mongodb'] @Override @@ -20,6 +21,7 @@ class AsynchronousMailGrailsPlugin extends Plugin { { -> //noinspection GrUnresolvedAccess asynchronousMailMessageBuilderFactory(AsynchronousMailMessageBuilderFactory) { it.autowire = true } + asynchronousMailService(AsynchronousMailService) { it.autowire = true } //noinspection GrUnresolvedAccess springConfig.addAlias 'asyncMailService', 'asynchronousMailService' } diff --git a/grails-app/services/grails/plugin/asyncmail/AsynchronousMailService.groovy b/src/main/groovy/grails/plugin/asyncmail/AsynchronousMailService.groovy similarity index 100% rename from grails-app/services/grails/plugin/asyncmail/AsynchronousMailService.groovy rename to src/main/groovy/grails/plugin/asyncmail/AsynchronousMailService.groovy diff --git a/src/test/groovy/grails/plugin/asyncmail/CompareMessageBuilderSpec.groovy b/src/test/groovy/grails/plugin/asyncmail/CompareMessageBuilderSpec.groovy index 088d27b..fd6c4fa 100644 --- a/src/test/groovy/grails/plugin/asyncmail/CompareMessageBuilderSpec.groovy +++ b/src/test/groovy/grails/plugin/asyncmail/CompareMessageBuilderSpec.groovy @@ -15,7 +15,7 @@ class CompareMessageBuilderSpec extends Specification { // Remove these methods as they are not part of MailMessageBuilder api and has found to be missing from // AsynchronousMailMessageBuilder with some versions of groovy which will make the test fail - mbMethods.removeAll { ['getProperty', 'setProperty', 'invokeMethod'].contains(it.name) } + mbMethods.removeAll { ['getProperty', 'setProperty', 'invokeMethod', 'access$0', 'pfaccess$0', 'pfaccess$1'].contains(it.name) } expect: mbMethods.every { MetaMethod mbm ->