Skip to content

Commit

Permalink
update docs, add GH Actions release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
HomeOfTheWizard committed Jul 7, 2024
1 parent 703ae2c commit 5b3ffdf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 13 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/maven-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish package to the Maven Central Repository
on:
workflow_dispatch: # Only run when manually started
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Publish package
env:
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.JRELEASER_MAVENCENTRAL_PASSWORD }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./mvnw -Ppublication jreleaser:full-release
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ This project is library that allows injecting Spring Beans into maven's DI syste
It is intended to help maven plugin developments by allowing the usage of spring libraries.
It uses [Spring-Guice](https://github.com/spring-projects/spring-guice) to brigde the two systems, and allows the usage of spring beans via [JSR-330](https://maven.apache.org/maven-jsr330.html) annotations within the plugin in development.
To see how to use JSR-330 annotations, this [documentation](https://eclipse-sisu.github.io/sisu-project/plexus/index.html) is a good start.
:warning: Beware, there is an important [declaration](https://eclipse-sisu.github.io/sisu-project/plexus/index.html#custombinding) on this wiki about plugins. Hence the usage of an extension instead of a plugin to do this bridge.

:warning: Beware, there is an important [declaration](https://eclipse-sisu.github.io/sisu-project/plexus/index.html#custombinding) on this wiki about plugins. Hence we need to activate a maven extension so the library can work. See below for more details on how to use the library.

## How to use it ?

Expand All @@ -24,31 +25,34 @@ public class MyMojo extends AbstractMojo {
}
```

You want to use a class that implements Helloer interface, coming from a spring library.
You want to use a class that implements `MyHelloer` interface, coming from a spring library.

#### 1. Add the extension
You should add this extension in the `extensions.xml` file located in your maven config folder `.mvn` of your application (the one that uses the custom plugin). Like below.
You should add the extension below in the `extensions.xml` file located in the maven config folder `.mvn` of the application (the application that will use the plugin you are developing).
This will allow our library to work, hence your plugin will be able to use spring libraries.
```xml
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0"...>
<extension>
<groupId>com.homeofthewizard</groupId>
<artifactId>guice-exporter-maven-extension</artifactId>
<version>1.0-SNAPSHOT</version>
</extension>
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>com.homeofthewizard</groupId>
<artifactId>guice-exporter-maven-extension</artifactId>
<version>1.0.0-alpha</version>
</extension>
</extensions>
```
You can see how to use extensions in more details [here](https://maven.apache.org/guides/mini/guide-using-extensions.html).

#### 2. Add an annotation
Somewhere in your plugin add `@SpringBootPlugin` pointing to the main configuration class of your spring library. As you can guess, this defines the configuration sources for the the spring application context to be used in the plugin. You can specify a class with `@EnableAutoConfiguration` annotation, or just a plain `@Configuration` class. There is an APT processor in the library that writes these out to `spring.factories` for use at runtime.
Somewhere in your plugin add `@SpringBootPlugin` pointing to the main configuration class of the spring library you want to use. As you can guess, this defines the configuration sources for the the spring application context to be used in the plugin. You can specify a class with `@EnableAutoConfiguration` annotation, or just a plain `@Configuration` class. There is an APT processor in the library that writes these out to `spring.factories` for use at runtime.

#### 3. Add a configuration file

Also create an `application.properties` file like below
Create an `application.properties` file like below
```properties
friend.name=Bob
```
Here our library takes a property as parameter to create our `Friend` Bean.
Here our example library takes a property as parameter to create a `MyFriend` Bean (implementing `MyHelloer` interface).

Place this under `src/main/resources` folder. This is the default place Spring Boot will look it up as normal.

Expand All @@ -63,7 +67,7 @@ In your plugin's `pom.xml`
<dependency>
<groupId>com.homeofthewizard</groupId>
<artifactId>spring-bridge-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.0.0-alpha</version>
</dependency>
<!-- your spring library -->
<dependency>
Expand Down

0 comments on commit 5b3ffdf

Please sign in to comment.