Skip to content

Commit 509bed8

Browse files
committed
Added a working Mojo Plugin
1 parent b2f519f commit 509bed8

File tree

4 files changed

+183
-1
lines changed

4 files changed

+183
-1
lines changed

omod/pom.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,26 @@
105105
<configuration>
106106
<header>${project.parent.basedir}/license-header.txt</header>
107107
</configuration>
108-
</plugin>
108+
</plugin>
109109
<plugin>
110110
<groupId>org.jacoco</groupId>
111111
<artifactId>jacoco-maven-plugin</artifactId>
112112
</plugin>
113+
<!-- OpenAPI Generator Maven Plugin -->
114+
<plugin>
115+
<groupId>org.openmrs.plugin</groupId>
116+
<artifactId>openapi-generator-maven-plugin</artifactId>
117+
<version>1.0-SNAPSHOT</version>
118+
<executions>
119+
<execution>
120+
<id>say-hello</id>
121+
<phase>process-classes</phase>
122+
<goals>
123+
<goal>hello</goal>
124+
</goals>
125+
</execution>
126+
</executions>
127+
</plugin>
113128
</plugins>
114129
</build>
115130

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# OpenAPI Generator Maven Plugin
2+
3+
## Overview
4+
5+
The `openapi-generator-maven-plugin` is a custom Maven plugin designed for the OpenMRS ecosystem. Its primary function is to print a friendly message during the Maven build lifecycle, serving as a foundational tool for future enhancements related to OpenAPI specification generation.
6+
7+
## Purpose
8+
9+
This plugin aims to facilitate integration with OpenMRS modules, particularly the `webservices.rest` module, by providing a simple yet effective way to execute custom build actions.
10+
11+
## Features
12+
13+
- **Maven Goal**: `hello`
14+
- **Output**: Logs "Hello from OpenMRS Maven Plugin! 🎉" during the build process.
15+
- **Lifecycle Phase**: Can be executed during the `process-classes` or `compile` phase.
16+
- **Integration**: Designed to be easily integrated into OpenMRS modules.
17+
18+
## Installation
19+
20+
To install the plugin locally, navigate to the project directory and run:
21+
22+
```bash
23+
mvn clean install
24+
```
25+
26+
This command will compile the plugin and install it into your local Maven repository.
27+
28+
## Usage
29+
30+
To use the plugin in your OpenMRS module, add the following configuration to your `pom.xml`:
31+
32+
```xml
33+
<plugin>
34+
<groupId>org.openmrs.plugin</groupId>
35+
<artifactId>openapi-generator-maven-plugin</artifactId>
36+
<version>1.0-SNAPSHOT</version>
37+
<executions>
38+
<execution>
39+
<id>say-hello</id>
40+
<phase>process-classes</phase>
41+
<goals>
42+
<goal>hello</goal>
43+
</goals>
44+
</execution>
45+
</executions>
46+
</plugin>
47+
```
48+
49+
After adding the plugin configuration, run the build:
50+
51+
```bash
52+
mvn clean install
53+
```
54+
55+
You should see the output: `Hello from OpenMRS Maven Plugin! 🎉`
56+
57+
## Future Enhancements
58+
59+
The plugin is intended to evolve with additional features, including:
60+
61+
- Support for loading resource classes.
62+
- Scanning for annotations like `@Resource` and `@DocumentedResource`.
63+
- Generating OpenAPI JSON specifications.
64+
- Archiving documentation into module artifacts.
65+
66+
## Contribution
67+
68+
Contributions to enhance the functionality of this plugin are welcome. Please ensure to follow the project's coding standards and guidelines when submitting changes.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.openmrs.plugin</groupId>
7+
<artifactId>openapi-generator-maven-plugin</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
<packaging>maven-plugin</packaging>
10+
11+
<name>OpenAPI Generator Maven Plugin</name>
12+
<description>A Maven plugin for generating OpenAPI specifications for OpenMRS modules.</description>
13+
<url>https://example.com/openapi-generator-maven-plugin</url>
14+
15+
<properties>
16+
<maven.compiler.source>1.8</maven.compiler.source>
17+
<maven.compiler.target>1.8</maven.compiler.target>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
</properties>
20+
21+
<dependencies>
22+
<!-- Maven Plugin API -->
23+
<dependency>
24+
<groupId>org.apache.maven</groupId>
25+
<artifactId>maven-plugin-api</artifactId>
26+
<version>3.8.6</version>
27+
<scope>provided</scope>
28+
</dependency>
29+
30+
<!-- Maven Plugin Annotations -->
31+
<dependency>
32+
<groupId>org.apache.maven.plugin-tools</groupId>
33+
<artifactId>maven-plugin-annotations</artifactId>
34+
<version>3.6.4</version>
35+
<scope>provided</scope>
36+
</dependency>
37+
38+
<!-- Maven Core -->
39+
<dependency>
40+
<groupId>org.apache.maven</groupId>
41+
<artifactId>maven-core</artifactId>
42+
<version>3.8.6</version>
43+
<scope>provided</scope>
44+
</dependency>
45+
</dependencies>
46+
47+
<build>
48+
<plugins>
49+
<plugin>
50+
<groupId>org.apache.maven.plugins</groupId>
51+
<artifactId>maven-plugin-plugin</artifactId>
52+
<version>3.6.4</version>
53+
<executions>
54+
<execution>
55+
<id>default-descriptor</id>
56+
<phase>process-classes</phase>
57+
<goals>
58+
<goal>descriptor</goal>
59+
</goals>
60+
</execution>
61+
</executions>
62+
</plugin>
63+
<plugin>
64+
<groupId>org.apache.maven.plugins</groupId>
65+
<artifactId>maven-compiler-plugin</artifactId>
66+
<version>3.10.1</version>
67+
<configuration>
68+
<source>1.8</source>
69+
<target>1.8</target>
70+
</configuration>
71+
</plugin>
72+
</plugins>
73+
</build>
74+
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* This Source Code Form is subject to the terms of the Mozilla Public License,
3+
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
4+
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
5+
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
6+
*
7+
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
8+
* graphic logo is a trademark of OpenMRS Inc.
9+
*/
10+
11+
package org.openmrs.plugin;
12+
13+
import org.apache.maven.plugin.AbstractMojo;
14+
import org.apache.maven.plugin.MojoExecutionException;
15+
import org.apache.maven.plugin.MojoFailureException;
16+
import org.apache.maven.plugins.annotations.LifecyclePhase;
17+
import org.apache.maven.plugins.annotations.Mojo;
18+
19+
@Mojo(name = "hello", defaultPhase = LifecyclePhase.PROCESS_CLASSES)
20+
public class HelloMojo extends AbstractMojo {
21+
@Override
22+
public void execute() throws MojoExecutionException, MojoFailureException {
23+
getLog().info("Hello from OpenMRS Maven Plugin!");
24+
}
25+
}

0 commit comments

Comments
 (0)