Skip to content

Commit

Permalink
Merge pull request #30 from agorapulse/chore/upgrade-to-micronaut-4
Browse files Browse the repository at this point in the history
Micronaut 4.x Baseline
  • Loading branch information
musketyr authored Dec 6, 2023
2 parents d8b3abf + d5fdf82 commit 2169b3c
Show file tree
Hide file tree
Showing 57 changed files with 255 additions and 636 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/gradle-versions-watchdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Setup Java 8
- name: Setup Java 17
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 8
distribution: zulu
java-version: 17
cache: gradle
- uses: gradle/gradle-command-action@v2
with:
arguments: check --stacktrace
arguments: check --scan
gradle-version: rc
22 changes: 4 additions & 18 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,13 @@ jobs:
GRADLE_OPTS: "-Xmx6g -Xms4g"
CI: true
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
strategy:
fail-fast: false
matrix:
versions:
- 'check coveralls -PmicronautVersion=1.3.7 -PspockVersion=2.0-groovy-2.5 -PgroovyVersion=2.5.15 -PmicronautExampleApplicationVersion=1.3.7'
- 'check -PmicronautVersion=2.5.13 -PspockVersion=2.0-groovy-3.0 -PgroovyVersion=3.0.9 -PmicronautExampleApplicationVersion=3.2.3'
- 'check -PmicronautVersion=3.2.3 -PspockVersion=2.0-groovy-3.0 -PgroovyVersion=3.0.9 -PmicronautExampleApplicationVersion=3.2.3'
steps:
- uses: actions/checkout@v2
- name: Setup Java 8
- name: Setup Java 17
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 8
cache: gradle
distribution: zulu
java-version: 17
- uses: gradle/gradle-command-action@v2
with:
arguments: ${{ matrix.versions }}
- name: Show Reports
uses: actions/upload-artifact@v1
if: failure()
with:
name: reports
path: build/reports/
arguments: check coveralls --scan
10 changes: 4 additions & 6 deletions .github/workflows/license_updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Java 8
- name: Setup Java 17
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 8
cache: gradle
- name: Check (${{ matrix.versions }})
distribution: zulu
java-version: 17
- name: Update License Headers
uses: gradle/gradle-command-action@v2
with:
arguments: licenseFormat
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/publish_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ jobs:
GRADLE_OPTS: "-Xmx6g -Xms4g"
steps:
- uses: actions/checkout@v2
- name: Setup Java 8
- name: Setup Java 17
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 8
distribution: zulu
java-version: 17
cache: gradle
- name: Get Latest Release
id: latest_version
uses: abatilo/[email protected]
with:
owner: agorapulse
repo: micronaut-snitch
repo: micronaut-console
- name: Publish GitHub Pages
uses: gradle/gradle-command-action@v2
with:
arguments: gitPublishPush -Pversion=${{ steps.latest_version.outputs.latest_tag }}-micronaut-3.0 --stacktrace -PmicronautVersion=3.2.3 -PspockVersion=2.0-groovy-3.0 -PgroovyVersion=3.0.9 -PmicronautExampleApplicationVersion=3.2.3 -Dorg.ajoberstar.grgit.auth.username=${{ secrets.AGORAPULSE_BOT_PERSONAL_TOKEN }}
arguments: gitPublishPush -Pversion=${{ steps.latest_version.outputs.latest_tag }} -Dorg.ajoberstar.grgit.auth.username=${{ secrets.AGORAPULSE_BOT_PERSONAL_TOKEN }}
63 changes: 26 additions & 37 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
steps:
- uses: actions/checkout@v2
- name: Setup Java 8
- name: Setup Java 17
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 8
distribution: zulu
java-version: 17
cache: gradle
- name: Semantic Version
id: version
Expand All @@ -30,41 +30,30 @@ jobs:
with:
fileName: 'secret.pgp'
encodedString: ${{ secrets.SIGNING_SECRET_KEY_BASE64 }}
- name: Release Micronaut 1.x
- name: Release
env:
SIGNING_SECRET_KEY_PATH: ${{ steps.write_file.outputs.filePath }}
uses: gradle/gradle-command-action@v2
with:
arguments: publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=${{ steps.version.outputs.tag }}-micronaut-1.0 -Prelease=true --stacktrace
- name: Release Micronaut 2.x
env:
SIGNING_SECRET_KEY_PATH: ${{ steps.write_file.outputs.filePath }}
uses: gradle/gradle-command-action@v2
with:
arguments: publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=${{ steps.version.outputs.tag }}-micronaut-2.0 --stacktrace -PmicronautVersion=2.5.13 -PspockVersion=2.0-groovy-3.0 -PgroovyVersion=3.0.9 -PmicronautExampleApplicationVersion=3.2.3
- name: Release Micronaut 3.x
env:
SIGNING_SECRET_KEY_PATH: ${{ steps.write_file.outputs.filePath }}
uses: gradle/gradle-command-action@v2
with:
arguments: gitPublishPush publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=${{ steps.version.outputs.tag }}-micronaut-3.0 --stacktrace -PmicronautVersion=3.2.3 -PspockVersion=2.0-groovy-3.0 -PgroovyVersion=3.0.9 -PmicronautExampleApplicationVersion=3.2.3 -Dorg.ajoberstar.grgit.auth.username=${{ secrets.AGORAPULSE_BOT_PERSONAL_TOKEN }}
ping:
name: Notify Upstream Repositories
runs-on: ubuntu-latest
needs: [release]
strategy:
matrix:
repository:
- agorapulse/agorapulse-bom
steps:
- uses: actions/checkout@v1
- name: Semantic Version
id: version
uses: ncipollo/semantic-version-action@v1
- name: Dispatch to ${{ matrix.repository }}
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.PERSONAL_TOKEN }}
repository: ${{ matrix.repository }}
event-type: ap-new-version-released-event
client-payload: '{ "group": "com.agorapulse", "module": "micronaut-console", "version": "${{ steps.version.outputs.tag }}-micronaut-1.0", "property" : "micronaut.console.version", "github" : ${{ toJson(github) }} }'
arguments: gitPublishPush publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=${{ steps.version.outputs.tag }} --scan -Dorg.ajoberstar.grgit.auth.username=${{ secrets.AGORAPULSE_BOT_PERSONAL_TOKEN }}
# Disabled until completely migrated to Micronaut 4.x
# ping:
# name: Notify Upstream Repositories
# runs-on: ubuntu-latest
# needs: [release]
# strategy:
# matrix:
# repository:
# - agorapulse/agorapulse-bom
# steps:
# - uses: actions/checkout@v1
# - name: Semantic Version
# id: version
# uses: ncipollo/semantic-version-action@v1
# - name: Dispatch to ${{ matrix.repository }}
# uses: peter-evans/repository-dispatch@v1
# with:
# token: ${{ secrets.PERSONAL_TOKEN }}
# repository: ${{ matrix.repository }}
# event-type: ap-new-version-released-event
# client-payload: '{ "group": "com.agorapulse", "module": "micronaut-console", "version": "${{ steps.version.outputs.tag }}-micronaut-1.0", "property" : "micronaut.console.version", "github" : ${{ toJson(github) }} }'
16 changes: 9 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ config {
enabled = false
}
}

javadoc {
aggregate {
enabled = false
}
}
}

}
Expand Down Expand Up @@ -146,15 +152,11 @@ subprojects { subproject ->

apply plugin: 'groovy'

dependencies {
// add your global dependencies
testCompile("org.spockframework:spock-core:$spockVersion") {
exclude group: "org.codehaus.groovy", module: "groovy-all"
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
testCompile 'net.bytebuddy:byte-buddy:1.10.6'
testCompile "org.objenesis:objenesis:3.1"
}

// useful for Micronaut
tasks.withType(GroovyCompile) {
groovyOptions.forkOptions.jvmArgs.add('-Dgroovy.parameters=true')
Expand Down
Empty file.
9 changes: 1 addition & 8 deletions docs/guide/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@ endif::[]
:toclevels: 4
:docinfo1:

include::{includedir}/_links.adoc[]

:leveloffset: 1
include::{includedir}/introduction.adoc[]
include::{includedir}/installation.adoc[]
include::{includedir}/usage.adoc[]

= Links

link:api/index.html[Javadoc, window="_blank"]

link:api-html/index.html[Source, window="_blank"]
include::{includedir}/releases.adoc[]
8 changes: 3 additions & 5 deletions docs/guide/src/docs/asciidoc/installation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@ dependencies {
implementation 'com.agorapulse:micronaut-console:{project-version}'
// for Groovy integration
implementation 'org.codehaus.groovy:groovy'
implementation 'org.apache.groovy:groovy'
// for Kotlin integration
implementation "org.jetbrains.kotlin:kotlin-scripting-jsr223:${kotlinVersion}"
// for Micronaut Security integration
implementation "io.micronaut:micronaut-security"
implementation "io.micronaut:micronaut-security-jwt"
implementation "io.micronaut.security:micronaut-security"
implementation "io.micronaut.security:micronaut-security-jwt"
}
----

TIP: There are variants for older Micronaut versions as well. You can use `micronaut-1.0` or `micronaut-2.0` suffix for different versions of Micronaut.

The console must be explicitly enabled. Add at least the following configuration to your application configuration.

.application.yml
Expand Down
16 changes: 16 additions & 0 deletions docs/guide/src/docs/asciidoc/releases.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

[[_release_notes_]]
= Release Notes

== 3.0.0

=== Breaking Changes

* Migrated to Micronaut 4.x so the minimum JDK version is now 17 and the Groovy version used for scripting is now 4.x.

== 2.0.0

=== Breaking Changes

* The console is disabled by default. To enable it, set the `console.enabled` property to `true` in the application configuration file or set the CONSOLE_ENABLED environment variable to `true`.

34 changes: 0 additions & 34 deletions docs/guide/src/docs/asciidoc/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,40 +41,6 @@ You can download an up-to-date DSL file from your server by altering the `text`
curl http://localhost:8080/console/dsl/gdsl > console.gdsl
----

== Serverless Functions

You can use Micronaut Console to create a sandbox function to execute arbitrary code on AWS Lambda or similar serverless function platforms.

Add the following to an existing or new Micronaut function:

[source, groovy, role="primary"]
.Basic
----
include::{root-dir}/examples/micronaut-console-example-function/micronaut-console-example-function.gradle[tags=import-runtime]
include::{root-dir}/examples/micronaut-console-example-function/micronaut-console-example-function.gradle[tags=import]
include::{root-dir}/examples/micronaut-console-example-function/micronaut-console-example-function.gradle[tags=tasks]
----

[source, groovy, role="secondary"]
.Authorized
----
include::{root-dir}/examples/micronaut-console-example-function/micronaut-console-example-function.gradle[tags=import-runtime]
include::{root-dir}/examples/micronaut-console-example-function/micronaut-console-example-function.gradle[tags=import-sts]
include::{root-dir}/examples/micronaut-console-example-function/micronaut-console-example-function.gradle[tags=import]
include::{root-dir}/examples/micronaut-console-example-function/micronaut-console-example-function.gradle[tags=auth]
----

Then you can invoke the function from the command line as follows (assuming you have set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_KEY` environment variables)

[source,shell script]
----
./gradlew invokeSanbox -Pscript.file path/to/script.groovy
----

You should use a lambda role restricted to what you are planning to do with the sandbox function to maximize the security.

== Server Applications

The typical use case is to execute a script in your HTTP server application.There are two endpoints,
Expand Down
Loading

0 comments on commit 2169b3c

Please sign in to comment.