Skip to content

Commit 46d9f4b

Browse files
committed
Update README
1 parent 0efef0c commit 46d9f4b

File tree

1 file changed

+72
-13
lines changed

1 file changed

+72
-13
lines changed

README.md

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,55 @@
11
# Grails Dynamic Modules Plugin
22

33
Grails Dynamic Modules Plugin (GDMP) offer new ways of creating modular and maintainable Grails applications.
4+
45
A Grails plugin can implement one or more plugin modules to develop and extend Grails applications.
56
We can use Dynamic Modules to maximize the use of Grails plugins and create an open, shared, and reusable plugin market.
6-
Welcome to contribute more types of modules, as well as plugins for these modules.
7+
8+
I will provide more Module Types in later releases, and also welcome to contribute more types of modules, as well as plugins for these modules.
79

810
## Grails Version
911

1012
- Grails **4.1.2**
1113

1214
## Usage
1315

14-
Add dependency to the `build.gradle`,
16+
This plugin has been released to [Maven Central](https://central.sonatype.com/artifact/org.rainboyan.plugins/grails-plugin-dynamic-modules).
17+
18+
Since this plugin is for building multiple modules, I highly recommend that you read this guide [Grails Multi-Project Build](https://guides.grails.org/grails-multi-project-build/guide/index.html) first.
19+
20+
21+
```bash
22+
.
23+
├── gradle
24+
│   └── wrapper
25+
├── grails-app
26+
│   ├── assets
27+
│   ├── conf
28+
│   ├── controllers
29+
│   ├── domain
30+
│   ├── i18n
31+
│   ├── init
32+
│   ├── services
33+
│   ├── taglib
34+
│   ├── utils
35+
│   └── views
36+
├── plugins
37+
│   └── menu
38+
├── src
39+
│   ├── integration-test
40+
│   ├── main
41+
│   └── test
42+
├── build.gradle
43+
├── gradle.properties
44+
├── gradlew
45+
├── gradlew.bat
46+
├── grails-wrapper.jar
47+
├── grailsw
48+
├── grailsw.bat
49+
└── settings.gradle
50+
```
51+
52+
First, you should add the dependency to your app `build.gradle`,
1553

1654
```gradle
1755
@@ -22,17 +60,15 @@ repositories {
2260
dependencies {
2361
2462
// Grails 4
25-
compile "org.rainboyan.plugins:grails-plugin-dynamic-modules:0.0.5"
63+
compile "org.rainboyan.plugins:grails-plugin-dynamic-modules:0.1.0"
2664
2765
// Grails 5
28-
implementation "org.rainboyan.plugins:grails-plugin-dynamic-modules:0.0.5"
66+
implementation "org.rainboyan.plugins:grails-plugin-dynamic-modules:0.1.0"
2967
}
3068
3169
```
3270

33-
In your Grails Plugin project,
34-
35-
First, we create a Module descriptor: `MenuModuleDescriptor`,
71+
Then in your Grails plugin project: `menu`, create your first Module descriptor: `MenuModuleDescriptor`,
3672

3773
```groovy
3874
@ModuleType('menu')
@@ -58,17 +94,17 @@ class MenuModuleDescriptor extends AbstractModuleDescriptor {
5894
}
5995
```
6096

61-
and then we update the `MyNewGrailsPlugin` to extend `grails.plugins.DynamicPlugin`,
97+
Update the `MenuGrailsPlugin` to extend `grails.plugins.DynamicPlugin`,
6298

6399
```groovy
64-
class MyNewGrailsPlugin extends DynamicPlugin {
100+
class MenuGrailsPlugin extends DynamicPlugin {
65101
66-
// 1. adding custom module types
102+
// 1. add your new module types
67103
def providedModules = [
68104
MenuModuleDescriptor
69105
]
70106
71-
// 2. define 'menu' module in doWithDynamicModules hook
107+
// 2. define 'menu' modules in doWithDynamicModules
72108
void doWithDynamicModules() {
73109
menu(key: 'about', i18n: 'menu.about', title: 'About US', link: '/about', location: 'topnav')
74110
menu(key: 'product', i18n: 'menu.product', title: 'Products', link: '/product', location: 'topnav', enabled: "${Environment.isDevelopmentMode()}") {
@@ -81,7 +117,9 @@ class MyNewGrailsPlugin extends DynamicPlugin {
81117
}
82118
```
83119

84-
now, you can get all the module descriptors in your Grails application throug the extended API of `GrailsPluginManager`,
120+
`DynamicModules` plugin support more methods of `GrailsPluginManager`,
121+
122+
you can get all the `ModuleDescriptor` in your Grails application throug the two methods of `GrailsPluginManager`,
85123

86124
```groovy
87125
@@ -93,7 +131,9 @@ List<MenuModuleDescriptor> menuDescriptors = pluginManager.getEnabledModuleDescr
93131
94132
```
95133

96-
I've created a sample Grails project([Grails Dynamic Modules Demo](https://github.com/rainboyan/grails-dynamic-modules-demo)) that you can run it and learn more.
134+
I've written a demo app for you that you can clone to your local computer, run it, and go through the code to learn more.
135+
136+
* [Grails Dynamic Modules Demo](https://github.com/rainboyan/grails-dynamic-modules-demo)
97137

98138
## Development
99139

@@ -109,6 +149,7 @@ cd grails-plugin-dynamic-modules
109149

110150
* Grails 4.0, 4.1
111151
* Grails 5.0, 5.1, 5.2, 5.3
152+
* Grails 6.0
112153

113154
## Known issues
114155

@@ -134,6 +175,23 @@ this is because the Closure doWithSpring's delegation strategy was not set, `Clo
134175
135176
```
136177

178+
Although 6 months have passed and the [PR#12892](https://github.com/grails/grails-core/pull/12892) for this issue has not been merged [grails-core](https://github.com/grails/grails-core), there is still a way to solve this problem.
179+
180+
That is to use [Java-based Container Configuration](https://docs.spring.io/spring-framework/reference/core/beans/java.html) instead of Grails `Plugin.doWithSpring()`.
181+
182+
```java
183+
@Configuration(proxyBeanMethods = false)
184+
public class MenuModuleAutoConfiguration {
185+
186+
@Bean
187+
@ConditionalOnMissingBean
188+
public WebMenuManager webMenuManager() {
189+
return new DefaultWebMenuManager();
190+
}
191+
192+
}
193+
```
194+
137195
## License
138196

139197
This plugin is available as open source under the terms of the [APACHE LICENSE, VERSION 2.0](http://apache.org/Licenses/LICENSE-2.0)
@@ -148,3 +206,4 @@ This plugin is available as open source under the terms of the [APACHE LICENSE,
148206
- [Project Jigsaw](https://openjdk.org/projects/jigsaw/)
149207
- [OSGi Specifications](https://docs.osgi.org/specification/)
150208
- [Spring Dynamic Modules Reference Guide](https://docs.spring.io/spring-osgi/docs/current/reference/html/)
209+
- [What's a plugin-oriented architecture?](https://spring.io/blog/2010/06/01/what-s-a-plugin-oriented-architecture)

0 commit comments

Comments
 (0)