From 5634bd1f5aaaf3ad8e7da326e78e96e2fd19507d Mon Sep 17 00:00:00 2001 From: Michael Yan Date: Tue, 7 May 2024 23:34:33 +0800 Subject: [PATCH] Add Stimulus plugin --- build.gradle | 1 + plugins/stimulus/build.gradle | 121 ++++++++++++++++++ plugins/stimulus/gradle.properties | 4 + .../stimulus/StimulusGrailsPlugin.groovy | 58 +++++++++ .../main/resources/META-INF/grails-plugin.xml | 3 + settings.gradle | 1 + 6 files changed, 188 insertions(+) create mode 100644 plugins/stimulus/build.gradle create mode 100644 plugins/stimulus/gradle.properties create mode 100644 plugins/stimulus/src/main/groovy/org/graceframework/plugins/stimulus/StimulusGrailsPlugin.groovy create mode 100644 plugins/stimulus/src/main/resources/META-INF/grails-plugin.xml diff --git a/build.gradle b/build.gradle index 4050979..cc954b4 100644 --- a/build.gradle +++ b/build.gradle @@ -36,6 +36,7 @@ dependencies { developmentOnly('org.springframework.boot:spring-boot-devtools') compileOnly "io.micronaut:micronaut-inject-groovy" console "org.graceframework:grace-console" + implementation project(":plugins:stimulus") implementation project(":plugins:turbo") implementation "org.springframework.boot:spring-boot-starter-logging" implementation "org.springframework.boot:spring-boot-starter-validation" diff --git a/plugins/stimulus/build.gradle b/plugins/stimulus/build.gradle new file mode 100644 index 0000000..6b33d6d --- /dev/null +++ b/plugins/stimulus/build.gradle @@ -0,0 +1,121 @@ +buildscript { + repositories { + mavenCentral() + } +} + +ext."signing.keyId" = project.hasProperty("signing.keyId") ? project.getProperty('signing.keyId') : System.getenv('SIGNING_KEY') +ext."signing.password" = project.hasProperty("signing.password") ? project.getProperty('signing.password') : System.getenv('SIGNING_PASSPHRASE') +ext."signing.secretKeyRingFile" = project.hasProperty("signing.secretKeyRingFile") ? project.getProperty('signing.secretKeyRingFile') : ("${System.properties['user.home']}${File.separator}.gnupg${File.separator}secring.gpg") +ext.isReleaseVersion = !projectVersion.endsWith("SNAPSHOT") + +ext { + springBootVersion = '2.6.6' + servletVersion = '4.0.1' +} + +version projectVersion +group "org.graceframework.plugins" + +apply plugin: "eclipse" +apply plugin: "idea" +apply plugin: "groovy" +apply plugin: "maven-publish" +apply plugin: "signing" + +repositories { + mavenCentral() +} + +dependencies { + compileOnly "org.springframework.boot:spring-boot-autoconfigure:$springBootVersion" + compileOnly "javax.servlet:javax.servlet-api:$servletVersion" + compileOnly "org.graceframework:grace-core:$graceVersion" + compileOnly "org.graceframework:grace-web-common:$graceVersion" +} + +tasks.withType(Sign) { + onlyIf { isReleaseVersion } +} + +tasks.withType(GroovyCompile) { + configure(groovyOptions) { + forkOptions.jvmArgs = ['-Xmx1024m'] + } +} + +tasks.withType(Test) { + useJUnitPlatform() +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + withJavadocJar() + withSourcesJar() +} + +jar { + duplicatesStrategy = DuplicatesStrategy.INCLUDE + manifest.mainAttributes( + "Built-By": System.properties['user.name'], + "Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")", + "Implementation-Title": "Grace Stimulus Plugin", + "Implementation-Version": projectVersion, + "Implementation-Vendor": 'Grace Plugins') + enabled = true + archiveClassifier.set('') + includeEmptyDirs = false +} + +publishing { + publications { + maven(MavenPublication) { + groupId = project.group + artifactId = projectName + version = project.version + + versionMapping { + usage('java-api') { + fromResolutionOf('runtimeClasspath') + } + usage('java-runtime') { + fromResolutionResult() + } + } + + from components.java + + pom { + name = "Grace Stimulus Plugin" + description = "Grace Plugin for using Stimulus with Grace." + url = 'https://github.com/grace-plugins/grace-hotwire' + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'https://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + id = 'rainboyan' + name = 'Michael Yan' + email = 'rain@rainboyan.com' + } + } + scm { + connection = 'scm:git:git://github.com/grace-plugins/grace-hotwire.git' + developerConnection = 'scm:git:ssh://github.com:grace-plugins/grace-hotwire.git' + url = 'https://github.com/grace-plugins/grace-hotwire' + } + } + } + } +} + +afterEvaluate { + signing { + required { isReleaseVersion && gradle.taskGraph.hasTask("publish") } + sign publishing.publications.maven + } +} diff --git a/plugins/stimulus/gradle.properties b/plugins/stimulus/gradle.properties new file mode 100644 index 0000000..efc00cb --- /dev/null +++ b/plugins/stimulus/gradle.properties @@ -0,0 +1,4 @@ +projectName=stimulus +projectVersion=0.0.1-SNAPSHOT +graceVersion=2020.0.0 +groovyVersion=3.0.11 \ No newline at end of file diff --git a/plugins/stimulus/src/main/groovy/org/graceframework/plugins/stimulus/StimulusGrailsPlugin.groovy b/plugins/stimulus/src/main/groovy/org/graceframework/plugins/stimulus/StimulusGrailsPlugin.groovy new file mode 100644 index 0000000..86e2173 --- /dev/null +++ b/plugins/stimulus/src/main/groovy/org/graceframework/plugins/stimulus/StimulusGrailsPlugin.groovy @@ -0,0 +1,58 @@ +/* + * Copyright 2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.graceframework.plugins.stimulus + +import grails.plugins.* + +class StimulusGrailsPlugin extends Plugin { + + def version = '0.0.1-SNAPSHOT' + // the version or versions of Grails the plugin is designed for + def grailsVersion = "3.0.0 > *" + // resources that are excluded from plugin packaging + def pluginExcludes = [ + "grails-app/views/error.gsp" + ] + + def title = "Grace Stimulus Plugin" + def author = "Michael Yan" + def authorEmail = "rain@rainboyan.com" + def description = '''\ +Use Stimulus in your Grace app. +''' + def profiles = ['web'] + + // URL to the plugin's documentation + def documentation = "https://github.com/grace-plugins/grace-hotwire" + + // Extra (optional) plugin metadata + + // License: one of 'APACHE', 'GPL2', 'GPL3' + def license = "APACHE" + + // Details of company behind the plugin (if there is one) + def organization = [ name: "Grace Plugins", url: "https://github.com/grace-plugins/" ] + + // Any additional developers beyond the author specified above. + def developers = [ [ name: "Michael Yan", email: "rain@rainboyan.com" ]] + + // Location of the plugin's issue tracker. + def issueManagement = [ system: "GitHub", url: "https://github.com/grace-plugins/grace-hotwire/issues" ] + + // Online location of the plugin's browseable source code. + def scm = [ url: "https://github.com/grace-plugins/grace-hotwire.git" ] + +} diff --git a/plugins/stimulus/src/main/resources/META-INF/grails-plugin.xml b/plugins/stimulus/src/main/resources/META-INF/grails-plugin.xml new file mode 100644 index 0000000..377ac1b --- /dev/null +++ b/plugins/stimulus/src/main/resources/META-INF/grails-plugin.xml @@ -0,0 +1,3 @@ + + org.graceframework.plugins.stimulus.StimulusGrailsPlugin + \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index a955c14..180b8ef 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,4 @@ rootProject.name = 'grace-hotwire' +include 'plugins:stimulus' include 'plugins:turbo'