Skip to content

Commit 005efba

Browse files
authored
Prepare version 2.0.0 (#145)
* Update version to 2.0.0 * Update README.md * Update README.md * Update README.md * Update README.md * Update Readme with better example
1 parent 04ef8fd commit 005efba

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ A Gradle plugin that helps keep your module graph healthy and lean.
2525
- Dependency, which will not match any of those rules will fail the assertion.
2626
- `restricted [':feature-[a-z]* -X> :forbidden-to-depend-on']` helps us to define custom rules by using `regex -X> regex` signature.
2727
- `maxHeight = 4` can verify that the [height of the modules tree](https://stackoverflow.com/questions/2603692/what-is-the-difference-between-tree-depth-and-height) with a root in the module will not exceed 4. Tree height is a good metric to prevent module tree degeneration into a list.
28-
- ~~`moduleLayers`~~ are now deprecated in favor of `allowed` syntax.
29-
- Example of migration: `moduleLayers = [":feature:\\S*", ":lib\\S*", ":core\\S*"]` -> `allowed = [":feature:\\S* -> :lib\\S*", ":feature:\\S* -> :core\\S*", :lib\\S* -> :core\\S*"]`
3028

3129
## Usage
3230
Apply the plugin to a module, which dependencies graph you want to assert.
3331
```groovy
3432
plugins {
35-
id "com.jraska.module.graph.assertion" version "1.7.0"
33+
id "com.jraska.module.graph.assertion" version "2.0.0"
3634
}
3735
```
3836

@@ -46,12 +44,33 @@ moduleGraphAssert {
4644
maxHeight = 4
4745
allowed = [':.* -> :core', ':feature.* -> :lib.*'] // regex to match module names
4846
restricted = [':feature-[a-z]* -X> :forbidden-to-depend-on'] // regex to match module names
49-
moduleLayers = [":feature:\\S*", ":lib\\S*", ":core\\S*"] // DEPRECATED - modules prefixed with ":feature:" -> prefix ":lib:" -> prefix :core:
50-
moduleLayersExclude = [":feature-about -> :feature-legacy-about"] // DEPRECATED
5147
configurations = ['api', 'implementation'] // Dependency configurations to look. ['api', 'implementation'] is the default
5248
}
5349
```
5450

51+
### Module name alias
52+
- You don't have to rely on module names and set a property `ext.moduleNameAssertAlias = "ThisWillBeAssertedOn"`
53+
- This can be set on any module and the `allowed`/`restricted` rules would use the alias instead of module name for asserting.
54+
- This is useful for example if you want to use "module types" where eaach module has a type regardless the name and you want to manage only dependnecies of different types.
55+
- It is recommended to use either module names or `moduleNameAssertAlias` everywhere. Mixing both is not recommended.
56+
- Example of module rules you could implement for a flat module graph:
57+
58+
<img src="https://user-images.githubusercontent.com/6277721/142781792-752f39ce-1525-4f59-8a25-94b236476117.png" width="300" />`
59+
- Each module would have set `ext.moduleNameAssertAlias = "Api|Implementation|App"`
60+
- Module rules example for such case: `allowed = ['Implementation -> Api', 'App -> Implementation', 'App -> Api']`
61+
- In case you want to migrate to this structure incrementally, you can set a separate module type like `ext.moduleNameAssertAlias = "NeedsMigration"` and setting
62+
```
63+
allowed = [
64+
'Implementation -> Api',
65+
'App -> Implementation',
66+
'App -> Api',
67+
'NeedsMigration -> .*',
68+
'.* -> NeedsMigration'
69+
]
70+
```
71+
72+
- `"NeedsMigration"` modules can be then tackled one by one to move them into `Implementation` or `Api` type. Example of app with this structure [can be seen here](https://github.com/jraska/github-client).
73+
5574
### Graphviz Graph Export
5675
- Visualising the graph could be useful to help find your dependency issues, therefore a helper `generateModulesGraphvizText` task is included.
5776
- This generates a graph of dependent modules when the plugin is applied.

plugin/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ pluginBundle {
3535
mavenCoordinates {
3636
groupId = 'com.jraska.module.graph.assertion'
3737
artifactId = 'plugin'
38-
version = "1.7.0"
38+
version = "2.0.0"
3939
}
4040
}
4141

4242
gradlePlugin {
4343
plugins {
4444
modulesGraphAssert {
4545
id = 'com.jraska.module.graph.assertion'
46-
version = '1.7.0'
46+
version = '2.0.0'
4747
displayName = 'Modules Graph Assert'
4848
description = 'Gradle plugin to keep your modules graph healthy and lean.'
4949
implementationClass = 'com.jraska.module.graph.assertion.ModuleGraphAssertionsPlugin'

0 commit comments

Comments
 (0)