Skip to content

Commit

Permalink
Hacking.
Browse files Browse the repository at this point in the history
  • Loading branch information
odrotbohm committed Dec 21, 2023
1 parent 1cef673 commit 9ccb0f5
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package {{root-package}}.{{module}};

import org.springframework.stereotype.Component;

@Component
class {{capitalize name}}EventListener {

@ApplicationModuleListener
void on({{eventType}} event) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
command:
description: Add an application module listener
options:

- name: module
description: The name of the module to create the listener in.
required: true

- name: name
description: The name of the listener type.
required: true

- name: eventType
description: The event type to listen to.
required: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package {{root-package}}.{{name}};

import org.springframework.stereotype.Component;

@Component
class {{capitalize name}}Component {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package {{root-package}}.{{name}};

import org.junit.jupiter.api.Test;
import org.springframework.modulith.test.ApplicationModuleTest;

@ApplicationModuleTest
class {{capitalizeFirst name}}ModuleIntegrationTests {

@Test
void bootstrapsModule() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
actions:
- generate:
to: src/main/java/{{root-package-dir}}/{{name}}/{{capitalize name}}Component.java
from: ApplicationModuleComponent.java
- generate:
to: src/test/java/{{root-package-dir}}/{{name}}/{{capitalize name}}ModuleIntegrationTests.java
from: ApplicationModuleIntegrationTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
command:
description: Add an application module
options:
- name: name
description: The name of the application module.
required: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
actions:
# if: enable-event-publication-registry
- exec:
command: ./mvnw dependency:list | grep 'jakarta.persistence-api' || echo ''
define:
name: jpa-present
- exec:
command: ./mvnw dependency:list | grep 'spring-jdbc' || echo ''
define:
name: spring-jdbc-present
- exec:
command: ./mvnw dependency:list | grep 'spring-data-mongodb' || echo ''
define:
name: spring-data-mongodb-present
- inject-maven-dependency:
text: |
<dependency>
<groupId>org.springframework.modulith</groupId>
{{#if jpa-present}}
<artifactId>spring-modulith-starter-jpa</artifactId>
{{else if spring-jdbc-present}}
<artifactId>spring-modulith-starter-jdbc</artifactId>
{{else if spring-jdbc-present}}
<artifactId>spring-modulith-starter-mongodb</artifactId>
{{/if}}
</dependency>
10 changes: 10 additions & 0 deletions spring-modulith-cli/.spring/commands/modulith/init/command.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
command:
description: Initializes Spring Modulith
options:
- name: enable-event-publication-registry
description: Valid values ["jdbc", "jpa", "mongodb"]
dataType: string
- name: enable-observability
description: Whether to include the modules for observability.
dataType: boolean
defaultValue: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
actions:
- inject-maven-dependency-management:
text: |
<dependency>
<groupId>org.springframework.modulith</groupId>
<artifactId>spring-modulith-bom</artifactId>
<version>1.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
- inject-maven-dependency:
text: |
<dependency>
<groupId>org.springframework.modulith</groupId>
<artifactId>spring-modulith-starter-test</artifactId>
<scope>test</scope>
</dependency>
{{#if enable-observability}}
<dependency>
<groupId>org.springframework.modulith</groupId>
<artifactId>spring-modulith-starter-insight</artifactId>
<scope>runtime</scope>
</dependency>
{{/if}}
96 changes: 96 additions & 0 deletions spring-modulith-cli/readme.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
= Spring Modulith CLI Integration

This module contains the Spring CLI integration for Spring Modulith.
To install the Spring Modulith support into the CLI, issue `command add` and point it to this repo:

[source, bash]
----
$ command add https://github.com/spring-projects/spring-modulith/tree/main/spring-modulith-cli
----

Verify the commands have been installed correctly by issuing `help`.

== Commands

=== Initializing Spring Modulith

`modulith init` initializes Spring Modulith with the current project.


[source]
----
NAME
modulith init - Initializes Spring Modulith
SYNOPSIS
modulith init --enable-event-publication-registry String --enable-observability Boolean --help
OPTIONS
--enable-event-publication-registry String
Valid values ["jdbc", "jpa", "mongodb"]
[Optional]
--enable-observability Boolean
Whether to include the modules for observability.
[Optional, default = false]
--help or -h
help for modulith init
[Optional]
----

=== Adding an Application Module

`modulith add-module` adds a new application module to the application, including:

* A new Java package with the given name.
* A Spring component named after the module.
* An `@ApplicationModuleTest` in the application module package in the test sources.

[source]
----
NAME
modulith add-module - Add an application module
SYNOPSIS
modulith add-module [--name String] --help
OPTIONS
--name String
The name of the application module.
[Mandatory]
--help or -h
help for modulith add-module
[Optional]
----

=== Adding an Application Module Listener

`modulith add-listener`

[source]
----
NAME
modulith add-listener - Add an application module listener
SYNOPSIS
modulith add-listener [--module String] [--name String] [--eventType String] --help
OPTIONS
--module String
The name of the module to create the listener in.
[Mandatory]
--name String
The name of the listener type.
[Mandatory]
--eventType String
The event type to listen to.
[Mandatory]
--help or -h
help for modulith add-listener
[Optional]
----

0 comments on commit 9ccb0f5

Please sign in to comment.