Skip to content

Commit

Permalink
Merge 2fda2dd into ed0962b
Browse files Browse the repository at this point in the history
  • Loading branch information
musketyr committed Feb 1, 2022
2 parents ed0962b + 2fda2dd commit fa0908c
Show file tree
Hide file tree
Showing 40 changed files with 247 additions and 101 deletions.
47 changes: 20 additions & 27 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Check

on: [push, pull_request]
on: [ push, pull_request ]
jobs:
check:
name: Check
Expand All @@ -9,30 +9,23 @@ 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 --scan'
- 'check -PmicronautVersion=2.5.13 -PspockVersion=2.0-groovy-3.0 -PgroovyVersion=3.0.9 --scan'
- 'migrateImports check -PmicronautVersion=3.2.1 -PspockVersion=2.0-groovy-3.0 -PgroovyVersion=3.0.9 --scan'
steps:
- uses: actions/checkout@v1

- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8

- uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}-${{ hashFiles('**/gradle.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: eskatos/gradle-command-action@v1
with:
arguments: check coveralls -Dscan.uploadInBackground=false --scan
- name: Show Build Scan
if: always()
run: cat scan-journal.log
- name: Show Reports
uses: actions/upload-artifact@v1
if: failure()
with:
name: reports
path: build/reports/
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: '8'
distribution: zulu
cache: 'gradle'
- uses: eskatos/gradle-command-action@v2
with:
arguments: ${{ matrix.versions }}
- name: Show Build Scan
if: always()
run: cat scan-journal.log
73 changes: 44 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ jobs:
runs-on: ubuntu-latest
env:
GRADLE_OPTS: "-Xmx6g -Xms4g"
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
uses: actions/setup-java@v2
with:
java-version: 1.8
java-version: '8'
distribution: zulu
cache: 'gradle'
- name: Semantic Version
id: version
uses: ncipollo/semantic-version-action@v1
Expand All @@ -24,33 +30,42 @@ jobs:
with:
fileName: 'secret.pgp'
encodedString: ${{ secrets.SIGNING_SECRET_KEY_BASE64 }}
- uses: eskatos/gradle-command-action@v1
- name: Release Micronaut 1.x
env:
SIGNING_SECRET_KEY_PATH: ${{ steps.write_file.outputs.filePath }}
uses: eskatos/gradle-command-action@v2
with:
arguments: -x groovydoc 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: eskatos/gradle-command-action@v2
with:
arguments: -x groovydoc publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=${{ steps.version.outputs.tag }}-micronaut-2.0 -Prelease=true --stacktrace -PmicronautVersion=2.5.13 -PspockVersion=2.0-groovy-3.0 -PgroovyVersion=3.0.9
- name: Release Micronaut 3.x
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_SECRET_KEY_PATH: ${{ steps.write_file.outputs.filePath }}
uses: eskatos/gradle-command-action@v2
with:
arguments: gitPublishPush publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=${{ steps.version.outputs.tag }} -Prelease=true -Dorg.ajoberstar.grgit.auth.username=${{ secrets.AGORAPULSE_BOT_PERSONAL_TOKEN }} --stacktrace
arguments: gitPublishPush -x groovydoc publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=${{ steps.version.outputs.tag }}-micronaut-3.0 -Prelease=true --stacktrace -PmicronautVersion=3.2.3 -PspockVersion=2.0-groovy-3.0 -PgroovyVersion=3.0.9 -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
- agorapulse/agorapulse-oss
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.AGORAPULSE_BOT_PERSONAL_TOKEN }}
repository: ${{ matrix.repository }}
event-type: ap-new-version-released-event
client-payload: '{ "group": "com.agorapulse", "module": "micronaut-newrelic", "version": "${{ steps.version.outputs.tag }}", "property" : "micronaut.newrelic.version", "github" : ${{ toJson(github) }} }'
name: Notify Upstream Repositories
runs-on: ubuntu-latest
needs: [release]
strategy:
matrix:
repository:
- agorapulse/agorapulse-bom
- agorapulse/agorapulse-oss
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.AGORAPULSE_BOT_PERSONAL_TOKEN }}
repository: ${{ matrix.repository }}
event-type: ap-new-version-released-event
client-payload: '{ "group": "com.agorapulse", "module": "micronaut-newrelic", "version": "${{ steps.version.outputs.tag }}-micronaut-1.0", "property" : "micronaut.newrelic.version", "github" : ${{ toJson(github) }} }'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Micronaut Newrelic

[![Build Status](https://github.com/agorapulse/micronaut-newrelic/workflows/Check/badge.svg)](https://github.com/agorapulse/micronaut-newrelic/actions)
[![Download](https://api.bintray.com/packages/agorapulse/libs/micronaut-newrelic/images/download.svg)](https://bintray.com/agorapulse/libs/micronaut-newrelic/_latestVersion)
[![Maven Central](https://img.shields.io/maven-central/v/com.agorapulse/micronaut-newrelic.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.agorapulse%22%20AND%20a:%22micronaut-newrelic%22)
[![Coverage Status](https://coveralls.io/repos/github/agorapulse/micronaut-newrelic/badge.svg?branch=master)](https://coveralls.io/github/agorapulse/micronaut-newrelic?branch=master)

Micronaut Newrelic Library
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2021 Agorapulse.
* Copyright 2022-2022 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -129,6 +129,7 @@ allprojects {
projects {
subprojects {
dirs(['libs', 'test-projects']) {
apply plugin: 'micronaut-compatibility'

// useful for Micronaut
tasks.withType(GroovyCompile) {
Expand Down
34 changes: 34 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2022-2022 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
id 'groovy-gradle-plugin'
id 'groovy'
}

repositories {
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
}

dependencies {
compile gradleApi()
compile localGroovy()

compile 'io.spring.gradle:dependency-management-plugin:1.0.5.RELEASE'
compile 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
}
103 changes: 103 additions & 0 deletions buildSrc/src/main/groovy/micronaut-compatibility.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2022-2022 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import groovy.transform.Field

@Field static final Map<String, String> MICRONAUT_1 = [
'micronaut-runtime-groovy': 'io.micronaut',
'micronaut-function-groovy': 'io.micronaut',
'micronaut-function-aws': 'io.micronaut',
'micronaut-aws-common': 'io.micronaut.configuration',
'micronaut-security': 'io.micronaut',
'micronaut-security-jwt': 'io.micronaut',
'micronaut-jdbc-tomcat': 'io.micronaut.configuration',
'micronaut-hibernate-gorm': 'io.micronaut.configuration',
'micronaut-spring': 'io.micronaut',
]

@Field static final Map<String, String> MICRONAUT_2 = [
'micronaut-runtime-groovy': 'io.micronaut.groovy',
'micronaut-function-groovy': 'io.micronaut.groovy',
'micronaut-function-aws': 'io.micronaut.aws',
'micronaut-aws-common': 'io.micronaut.aws',
'micronaut-security': 'io.micronaut.security',
'micronaut-security-jwt': 'io.micronaut.security',
'micronaut-jdbc-tomcat': 'io.micronaut.sql',
'micronaut-hibernate-gorm': 'io.micronaut.groovy',
'micronaut-spring': 'io.micronaut.spring',
]

@Field static final Map<String, Object> IMPORTS = [
'javax.annotation.Nullable': 'io.micronaut.core.annotation.Nullable',
'javax.annotation.Nonnull': 'io.micronaut.core.annotation.NonNull',
'Nonnull': 'NonNull',
'import javax.inject.': 'import jakarta.inject.',
'io.micronaut.test.annotation.MicronautTest': [
java: 'io.micronaut.test.extensions.junit5.annotation.MicronautTest',
groovy: 'io.micronaut.test.extensions.spock.annotation.MicronautTest',
]
]

ext.micronautMigratedDependency = { String module ->
Map<String, String> groups = project.getProperty('micronautVersion').startsWith('1') ? MICRONAUT_1 : MICRONAUT_2
String group = groups[module]

if (!group) {
throw new IllegalArgumentException("Cannot find group for $module. Known modules: ${groups.keySet()}")
}

return "$group:$module"
}

pluginManager.withPlugin('java') {
tasks.register('migrateImports') { Task task ->
File javaSources = project.file('src/main/java')
File javaTestSources = project.file('src/test/java')
File groovySources = project.file('src/main/groovy')
File groovyTestSources = project.file('src/test/groovy')

List<File> dirs = [javaSources, javaTestSources, groovySources, groovyTestSources]

for (File dir in dirs) {
if (dir.exists()) {
task.inputs.dir dir
task.outputs.dir dir

task.doFirst {
task.inputs.files.forEach { File file ->
String content = file.text
String newContent = content

if (IMPORTS.keySet().any { String original -> content.contains(original) }) {
IMPORTS.each { String original, Object value ->
String replacement = value instanceof CharSequence ? value : (file.name.endsWith('.groovy') ? value['groovy'] : value['java'])
newContent = newContent.replace(original, replacement)
}
}

if (content != newContent) {
project.logger.lifecycle("Migrated imports in $file")
file.text = newContent
}
}
}
}
}
}
}


2 changes: 1 addition & 1 deletion docs/guide/guide.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2021 Agorapulse.
* Copyright 2022-2022 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# Copyright 2021 Agorapulse.
# Copyright 2022-2022 Agorapulse.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -24,5 +24,5 @@ gitPublishPluginVersion=2.1.3
nexusPluginVersion=1.0.0

micronautVersion=1.3.7
micronautGrailsVersion=3.0.3
micronautGrailsVersion=3.1.0-micronaut-1.0
spockVersion=2.0-groovy-2.5
2 changes: 1 addition & 1 deletion gradle/LICENSE_HEADER
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SPDX-License-Identifier: Apache-2.0

Copyright ${copyrightYear} Agorapulse.
Copyright 2022-${copyrightYear} Agorapulse.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2021 Agorapulse.
* Copyright 2022-2022 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2021 Agorapulse.
* Copyright 2022-2022 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2021 Agorapulse.
* Copyright 2022-2022 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2021 Agorapulse.
* Copyright 2022-2022 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,7 +31,7 @@ class NewRelicFilterSpec extends Specification {
@AutoCleanup Gru gru = Gru.create(Http.create(this))

void setup() {
context = ApplicationContext.build().build()
context = ApplicationContext.builder().build()
context.start()

server = context.getBean(EmbeddedServer)
Expand Down

0 comments on commit fa0908c

Please sign in to comment.