Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUN-2121: upgrade dependencies for compatibility with rundeck 5 #11

Merged
merged 5 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -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.11
uses: actions/setup-java@v1
with:
java-version: 1.11
- 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
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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.11
uses: actions/setup-java@v1
with:
java-version: 1.11
- 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
41 changes: 30 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import org.gradle.api.JavaVersion

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
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

ext.rundeckPluginVersion= '1.2'

scmVersion {
Expand Down Expand Up @@ -39,9 +46,8 @@ project.version = scmVersion.version
ext.pluginClassNames='com.rundeck.plugins.logging.JsonLogFilter'


sourceCompatibility = 1.8

repositories {
mavenLocal()
mavenCentral()
}

Expand All @@ -50,22 +56,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'

implementation group: 'org.rundeck', name: 'rundeck-core', version: rundeckVersion

compile group: 'org.rundeck', name: 'rundeck-core', version: rundeckVersion
pluginLibs (group: 'net.thisptr', name: 'jackson-jq', version: '0.0.10') {
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"
}


Expand All @@ -75,6 +82,9 @@ task copyToLib(type: Copy) {
from configurations.pluginLibs
}

tasks.withType(Test).configureEach {
useJUnitPlatform()
}

jar {
from "$buildDir/output"
Expand All @@ -97,3 +107,12 @@ jar {
}
//set jar task to depend on copyToLib
jar.dependsOn(copyToLib)

publishing {
publications {
maven(MavenPublication) {
artifactId = 'jq-json-logfilter'
from components.java
}
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk11
14 changes: 9 additions & 5 deletions src/main/groovy/com/rundeck/plugins/logging/JsonLogFilter.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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<JsonNode> out = q.apply(rootScope, inData)
JsonQuery q = JsonQuery.compile(replacedFilter, Versions.JQ_1_6);

final List<JsonNode> out = new ArrayList<>();
q.apply(rootScope, inData, out::add);

out.each {it->
//process object
Expand Down
Loading