From 80830e0c68e077e2e3c9a0c818389af4416f9c3c Mon Sep 17 00:00:00 2001 From: Sachin Verma Date: Fri, 29 Nov 2024 11:12:39 +0530 Subject: [PATCH 1/4] Add Grails mail 4.0.0 plugin support. Move AsynchronousMailService.groovy to src folder to save it from SendMail trait enrich. --- README.md | 6 ++++++ build.gradle | 2 +- .../plugin/asyncmail/AsynchronousMailGrailsPlugin.groovy | 2 ++ .../grails/plugin/asyncmail/AsynchronousMailService.groovy | 0 4 files changed, 9 insertions(+), 1 deletion(-) 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 From 714c29cb2cf301b4d8512bd852ff2847ff3bea89 Mon Sep 17 00:00:00 2001 From: Sachin Verma Date: Fri, 29 Nov 2024 11:33:42 +0530 Subject: [PATCH 2/4] Fix failing test case due to metaclass methods access etc. --- .../grails/plugin/asyncmail/CompareMessageBuilderSpec.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -> From c4737856d1aec667c3dacef95e5fb71222ea8af9 Mon Sep 17 00:00:00 2001 From: Sachin Verma Date: Fri, 29 Nov 2024 12:12:20 +0530 Subject: [PATCH 3/4] merge v2.0.3 changes to 6.x.x --- .github/workflows/gradle-github-publish.yml | 45 ++++++++++++ README.md | 12 ++++ build.gradle | 80 ++++++++++++++++++--- buildSrc/build.gradle | 1 + 4 files changed, 130 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/gradle-github-publish.yml diff --git a/.github/workflows/gradle-github-publish.yml b/.github/workflows/gradle-github-publish.yml new file mode 100644 index 0000000..1eeaea5 --- /dev/null +++ b/.github/workflows/gradle-github-publish.yml @@ -0,0 +1,45 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created +# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle + +name: Gradle Package + +on: + release: + types: [created] + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'zulu' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + + - name: Build with Gradle + uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 + with: + arguments: build + + # The USERNAME and TOKEN need to correspond to the credentials environment variables used in + # the publishing section of your build.gradle + - name: Publish to GitHub Packages + uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 + with: + arguments: publish + env: + GITHUB_USERNAME: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 63303c4..497215d 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,18 @@ For grails 4.0.x compile "io.github.gpc:asynchronous-mail:3.0.0" ``` +For Grails 3.3.x (Via jitpack proxy on github registry packages as for grails 3.3.x support on nexus publish not working) + +```groovy + repositories { + maven { url 'https://jitpack.io' } + } +``` + +```groovy + compile "com.github.gpc:asynchronous-mail:2.0.3" +``` + For Grails 3.3.x ```groovy compile "org.grails.plugins:asynchronous-mail:2.0.2" diff --git a/build.gradle b/build.gradle index c711a4b..48530bc 100644 --- a/build.gradle +++ b/build.gradle @@ -6,6 +6,7 @@ plugins { id 'org.grails.grails-gsp' id 'maven-publish' id 'signing' + id "com.gorylenko.gradle-git-properties" } group = 'io.github.gpc' @@ -55,8 +56,6 @@ dependencies { java { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 - withSourcesJar() - withJavadocJar() } tasks.withType(Test).configureEach { @@ -65,15 +64,64 @@ tasks.withType(Test).configureEach { // enable if you wish to package this plugin as a standalone application bootJar.enabled = false -jar { - enabled = true - archiveClassifier = '' -} assets { packagePlugin = true } +task sourceJar(type: Jar) { + classifier = 'sources' + from sourceSets.main.allSource +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +task packageGroovydoc(type: Jar) { + from groovydoc + classifier = 'groovydoc' +} + + +gitProperties { + keys = ['git.branch', 'git.commit.id', 'git.commit.time', 'git.commit.id.abbrev'] + failOnNoGitDirectory = true + extProperty = 'gitProps' // git properties will be put in a map at project.ext.gitProps +} + +javadoc { + source = sourceSets.main.allJava + classpath = configurations.compileClasspath + options + { + setMemberLevel JavadocMemberLevel.PUBLIC + setAuthor true + + links "https://docs.oracle.com/javase/8/docs/api/" + } +} + + +generateGitProperties.outputs.upToDateWhen { false } // make sure the generateGitProperties task always executes (even when git.properties is not changed) + +jar { + enabled = true + archiveClassifier = '' + dependsOn generateGitProperties + manifest { + attributes("Built-By": System.getProperty("user.name")) + attributes(["Plugin-Version" : version, + "Plugin-Title" : project.name, + "Plugin-Build-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + "Git-Commit" : "${-> project.ext.gitProps['git.commit.id.abbrev']}", + "Git-Branch" : "${-> project.ext.gitProps['git.branch']}"]) + } + from sourceSets.main.output + exclude 'git.properties' +} + publishing { publications { maven(MavenPublication) { @@ -82,8 +130,9 @@ publishing { version = project.version from components.java - artifact sourcesJar - artifact javadocJar + artifact sourceJar + artifact packageJavadoc + artifact packageGroovydoc pom { name = 'Grails Asynchronous Mail Plugin' @@ -152,6 +201,10 @@ publishing { id = 'matrei' name = 'Mattias Reichel' } + developer { + id = 'vsachinv' + name = 'Sachin Verma' + } } scm { connection = 'scm:git:git://github.com/gpc/grails-asynchronous-mail.git' @@ -161,6 +214,17 @@ publishing { } } } + + repositories { + maven { + name = "GitHubPackages" + url = "https://maven.pkg.github.com/gpc/grails-asynchronous-mail1" + credentials { + username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_USERNAME") + password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN") + } + } + } } ext."signing.keyId" = project.findProperty('signing.keyId') ?: System.getenv('SIGNING_KEY_ID') diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 239ada5..e907872 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -7,4 +7,5 @@ dependencies { implementation 'org.grails.plugins:hibernate5:8.0.1' implementation 'io.github.gradle-nexus:publish-plugin:1.3.0' implementation 'com.bertramlabs.plugins:asset-pipeline-gradle:4.4.0' + implementation("com.gorylenko.gradle-git-properties:gradle-git-properties:2.4.2") } \ No newline at end of file From 96d1201415646553cf1cc62a200cb466bda8854a Mon Sep 17 00:00:00 2001 From: Sachin Verma Date: Wed, 4 Dec 2024 01:04:33 +0530 Subject: [PATCH 4/4] Correct gradle github publish command. --- .github/workflows/gradle-github-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle-github-publish.yml b/.github/workflows/gradle-github-publish.yml index 1eeaea5..6391f52 100644 --- a/.github/workflows/gradle-github-publish.yml +++ b/.github/workflows/gradle-github-publish.yml @@ -39,7 +39,7 @@ jobs: - name: Publish to GitHub Packages uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 with: - arguments: publish + arguments: publishMavenPublicationToGitHubPackagesRepository env: GITHUB_USERNAME: ${{ github.actor }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}