From af5a95c22787c7f77cd3098c513d49ad311d6246 Mon Sep 17 00:00:00 2001 From: Luis Toledo Date: Fri, 22 Dec 2023 15:45:23 -0300 Subject: [PATCH 1/5] upgrade gradle upgrade jackson-jq --- build.gradle | 37 +++++++++++++------ gradle/wrapper/gradle-wrapper.properties | 2 +- .../plugins/logging/JsonLogFilter.groovy | 14 ++++--- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/build.gradle b/build.gradle index 2aba393..2cefbf1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,17 +1,20 @@ +import org.gradle.api.tasks.testing.Test + plugins { id 'groovy' id 'java' - id 'pl.allegro.tech.build.axion-release' version '1.7.1' + id 'pl.allegro.tech.build.axion-release' version '1.13.4' + id 'maven-publish' } group 'com.rundeck.plugin' -ext.rundeckVersion='3.0.6-20180917' +ext.rundeckVersion='5.0.0-20231216' defaultTasks 'clean','build' apply plugin: 'java' apply plugin: 'idea' -sourceCompatibility = 1.8 +sourceCompatibility = 1.11 ext.rundeckPluginVersion= '1.2' scmVersion { @@ -39,9 +42,8 @@ project.version = scmVersion.version ext.pluginClassNames='com.rundeck.plugins.logging.JsonLogFilter' -sourceCompatibility = 1.8 - repositories { + mavenLocal() mavenCentral() } @@ -50,22 +52,23 @@ configurations{ pluginLibs //declare compile to extend from pluginLibs so it inherits the dependencies - compile{ + implementation{ extendsFrom pluginLibs } } dependencies { - compile 'org.codehaus.groovy:groovy-all:2.3.11' + implementation 'org.codehaus.groovy:groovy-all:3.0.19' - compile group: 'org.rundeck', name: 'rundeck-core', version: rundeckVersion - pluginLibs (group: 'net.thisptr', name: 'jackson-jq', version: '0.0.10') { + implementation group: 'org.rundeck', name: 'rundeck-core', version: rundeckVersion + + pluginLibs (group: 'net.thisptr', name: 'jackson-jq', version: '1.0.0-preview.20230409') { exclude group: "com.fasterxml.jackson.core" } - testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.spockframework:spock-core:0.7-groovy-2.0" + testImplementation group: 'junit', name: 'junit', version: '4.13.2' + testImplementation "org.spockframework:spock-core:2.0-groovy-3.0" } @@ -75,6 +78,9 @@ task copyToLib(type: Copy) { from configurations.pluginLibs } +tasks.withType(Test).configureEach { + useJUnitPlatform() +} jar { from "$buildDir/output" @@ -97,3 +103,12 @@ jar { } //set jar task to depend on copyToLib jar.dependsOn(copyToLib) + +publishing { + publications { + maven(MavenPublication) { + artifactId = 'jq-json-logfilter' + from components.java + } + } +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f4d7b2b..774fae8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/groovy/com/rundeck/plugins/logging/JsonLogFilter.groovy b/src/main/groovy/com/rundeck/plugins/logging/JsonLogFilter.groovy index 2322421..3b6be39 100644 --- a/src/main/groovy/com/rundeck/plugins/logging/JsonLogFilter.groovy +++ b/src/main/groovy/com/rundeck/plugins/logging/JsonLogFilter.groovy @@ -14,8 +14,10 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.node.JsonNodeType import net.thisptr.jackson.jq.JsonQuery import net.thisptr.jackson.jq.Scope +import net.thisptr.jackson.jq.BuiltinFunctionLoader +import net.thisptr.jackson.jq.Versions -@Plugin(name = JsonLogFilter.PROVIDER_NAME, service = 'LogFilter') +@Plugin(name = PROVIDER_NAME, service = 'LogFilter') @PluginDescription(title = 'JSON jq key/value mapper', description = 'Map a json logoutput on key/value to context data using jq filters') class JsonLogFilter implements LogFilterPlugin{ @@ -92,13 +94,15 @@ See [here](https://github.com/eiiches/jackson-jq#implementation-status-and-curre void processJson(final PluginLoggingContext context){ try{ + Scope rootScope = Scope.newEmptyScope(); + BuiltinFunctionLoader.getInstance().loadFunctions(Versions.JQ_1_6, rootScope); - Scope rootScope = Scope.newEmptyScope() - rootScope.loadFunctions(Scope.class.getClassLoader()) - JsonQuery q = JsonQuery.compile(replacedFilter) JsonNode inData = mapper.readTree(buffer.toString()); - List out = q.apply(rootScope, inData) + JsonQuery q = JsonQuery.compile(replacedFilter, Versions.JQ_1_6); + + final List out = new ArrayList<>(); + q.apply(rootScope, inData, out::add); out.each {it-> //process object From 37a4edea736d336f5e75013832c9e1685e3119e5 Mon Sep 17 00:00:00 2001 From: Luis Toledo Date: Fri, 22 Dec 2023 15:58:23 -0300 Subject: [PATCH 2/5] clean --- build.gradle | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 2cefbf1..9ee63c3 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -import org.gradle.api.tasks.testing.Test +import org.gradle.api.JavaVersion plugins { id 'groovy' @@ -14,7 +14,11 @@ defaultTasks 'clean','build' apply plugin: 'java' apply plugin: 'idea' -sourceCompatibility = 1.11 +java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} + ext.rundeckPluginVersion= '1.2' scmVersion { From f6a1c7b286008b61ca81284cb0d0173c436e1389 Mon Sep 17 00:00:00 2001 From: Luis Toledo Date: Fri, 22 Dec 2023 16:00:20 -0300 Subject: [PATCH 3/5] add github actions --- .github/workflows/gradle.yml | 34 ++++++++++++++++++++++++++ .github/workflows/release.yml | 46 +++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 .github/workflows/gradle.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..2ea183d --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,34 @@ +name: Java CI + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Get Fetch Tags + run: git -c protocol.version=2 fetch --tags --progress --no-recurse-submodules origin + if: "!contains(github.ref, 'refs/tags')" + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew build + - name: Get Release Version + id: get_version + run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo ::set-output name=VERSION::$VERSION + - name: Upload plugin jar + uses: actions/upload-artifact@v1.0.0 + with: + # Artifact name + name: Grails-Plugin-${{ steps.get_version.outputs.VERSION }} + # Directory containing files to upload + path: build/libs/jq-json-logfilter-${{ steps.get_version.outputs.VERSION }}.jar \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0bacd91 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - '*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +name: Upload Release Asset + +jobs: + build: + name: Upload Release Asset + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build with Gradle + run: ./gradlew build + - name: Get Release Version + id: get_version + run: VERSION=$(./gradlew currentVersion -q -Prelease.quiet) && echo ::set-output name=VERSION::$VERSION + - name: Create Release + id: create_release + uses: actions/create-release@v1.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ steps.get_version.outputs.VERSION }} + draft: false + prerelease: false + - name: Upload Release Asset (jar) + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: build/libs/jq-json-logfilter-${{ steps.get_version.outputs.VERSION }}.jar + asset_name: jq-json-logfilter-${{ steps.get_version.outputs.VERSION }}.jar + asset_content_type: application/octet-stream \ No newline at end of file From cadd32cd9271b9ad68521926438bcb34cbe654bb Mon Sep 17 00:00:00 2001 From: Luis Toledo Date: Fri, 22 Dec 2023 16:01:24 -0300 Subject: [PATCH 4/5] use java 11 --- .github/workflows/gradle.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 2ea183d..0b4a1e9 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -14,10 +14,10 @@ jobs: - name: Get Fetch Tags run: git -c protocol.version=2 fetch --tags --progress --no-recurse-submodules origin if: "!contains(github.ref, 'refs/tags')" - - name: Set up JDK 1.8 + - name: Set up JDK 1.11 uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: 1.11 - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0bacd91..51edb4b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,10 +15,10 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 - - name: set up JDK 1.8 + - name: set up JDK 1.11 uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: 1.11 - name: Build with Gradle run: ./gradlew build - name: Get Release Version From 77fde9b0b37dea9e18b80db3c5d70f92926f6a0e Mon Sep 17 00:00:00 2001 From: Luis Toledo Date: Fri, 22 Dec 2023 16:08:48 -0300 Subject: [PATCH 5/5] set jitpack java version --- jitpack.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 jitpack.yml diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..46c8529 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,2 @@ +jdk: + - openjdk11 \ No newline at end of file