You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2019/08/27 13:57:59 UTC
[plc4x] 11/44: - Added a "tool" for logstash to the "tools"
section. - Updated the build of the logstash integration to use Maven
instead of Gradle - Added some missing Apache headers
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 5b4872b04981b2afabe7cb522adc92ced37e9a5f
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Aug 15 12:00:21 2019 +0200
- Added a "tool" for logstash to the "tools" section.
- Updated the build of the logstash integration to use Maven instead of Gradle
- Added some missing Apache headers
---
plc4j/integrations/logstash-plugin/README.md | 19 ++
plc4j/integrations/logstash-plugin/VERSION | 1 -
plc4j/integrations/logstash-plugin/build.gradle | 108 ---------
.../logstash-plugin/docs/index.asciidoc | 117 ---------
.../gradle/wrapper/gradle-wrapper.jar | Bin 54413 -> 0 bytes
.../gradle/wrapper/gradle-wrapper.properties | 6 -
plc4j/integrations/logstash-plugin/gradlew | 172 -------------
plc4j/integrations/logstash-plugin/gradlew.bat | 84 -------
plc4j/integrations/logstash-plugin/pom.xml | 269 +++++++--------------
.../src/gem/logstash-input-plc4x.gemspec | 23 ++
.../java/org/apache/plc4x/logstash/Plc4xInput.java | 26 +-
.../plc4x/logstash/JavaInputExampleTest.java | 24 +-
pom.xml | 4 +
tools/logstash/pom.xml | 129 ++++++++++
tools/pom.xml | 6 +
15 files changed, 317 insertions(+), 671 deletions(-)
diff --git a/plc4j/integrations/logstash-plugin/README.md b/plc4j/integrations/logstash-plugin/README.md
index 1050718..771b2bc 100644
--- a/plc4j/integrations/logstash-plugin/README.md
+++ b/plc4j/integrations/logstash-plugin/README.md
@@ -1,3 +1,22 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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
+
+ http://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.
+
+-->
+
# Logstash Java Plugin
[![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-filter-java_filter_example.svg)](https://travis-ci.org/logstash-plugins/logstash-filter-java_filter_example)
diff --git a/plc4j/integrations/logstash-plugin/VERSION b/plc4j/integrations/logstash-plugin/VERSION
deleted file mode 100644
index 3eefcb9..0000000
--- a/plc4j/integrations/logstash-plugin/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-1.0.0
diff --git a/plc4j/integrations/logstash-plugin/build.gradle b/plc4j/integrations/logstash-plugin/build.gradle
deleted file mode 100644
index 8305e95..0000000
--- a/plc4j/integrations/logstash-plugin/build.gradle
+++ /dev/null
@@ -1,108 +0,0 @@
-import java.nio.file.Files
-import static java.nio.file.StandardCopyOption.REPLACE_EXISTING
-
-apply plugin: 'java'
-apply from: LOGSTASH_CORE_PATH + "/../rubyUtils.gradle"
-
-// ===========================================================================
-// plugin info
-// ===========================================================================
-group 'org.apache.plc4x.logstash' // must match the package of the main plugin class
-version "${file("VERSION").text.trim()}" // read from required VERSION file
-description = "Apache PLC4x Logstash Integration"
-pluginInfo.licenses = ['Apache-2.0'] // list of SPDX license IDs
-pluginInfo.longDescription = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using \$LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
-pluginInfo.authors = ['Till Voß', 'Stefan Herrmann']
-pluginInfo.email = ['stefan.herrmann@codecentric.de', 'till.voß@codecentric.de']
-pluginInfo.homepage = "https://plc4x.apache.org"
-pluginInfo.pluginType = "input"
-pluginInfo.pluginClass = "Plc4xInput"
-pluginInfo.pluginName = "plc4x_input" // must match the @LogstashPlugin annotation in the main plugin class
-// ===========================================================================
-
-sourceCompatibility = 1.8
-targetCompatibility = 1.8
-
-buildscript {
- repositories {
- mavenCentral()
- jcenter()
- }
-
- dependencies {
- classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
- }
-}
-
-repositories {
- mavenCentral()
-}
-
-task wrapper(type: Wrapper) {
- gradleVersion = '4.0'
-}
-
-apply plugin: 'com.github.johnrengelman.shadow'
-
-shadowJar {
- classifier = null
-}
-
-dependencies {
- compile 'org.apache.commons:commons-lang3:3.7'
- compile 'org.apache.logging.log4j:log4j-api:2.9.1'
- compile 'org.apache.logging.log4j:log4j-core:2.9.1'
- compile 'org.apache.plc4x:plc4j-api:0.4.0'
- compile fileTree(dir: LOGSTASH_CORE_PATH, include: "**/logstash-core-?.?.?.jar")
-
- testCompile 'junit:junit:4.12'
- testCompile 'org.jruby:jruby-complete:9.1.13.0'
-}
-
-clean {
- delete "${projectDir}/Gemfile"
- delete "${projectDir}/" + pluginInfo.pluginFullName() + ".gemspec"
- delete "${projectDir}/lib/"
- delete "${projectDir}/vendor/"
- new FileNameFinder().getFileNames(projectDir.toString(), pluginInfo.pluginFullName() + "-?.?.?.gem").each { filename ->
- delete filename
- }
-}
-
-tasks.withType(JavaCompile) {
- options.encoding = 'UTF-8'
-}
-
-task vendor(dependsOn: shadowJar) {
- doLast {
- String vendorPathPrefix = "vendor/jar-dependencies"
- String projectGroupPath = project.group.replaceAll('\\.', '/')
- File projectJarFile = file("${vendorPathPrefix}/${projectGroupPath}/${pluginInfo.pluginFullName()}/${project.version}/${pluginInfo.pluginFullName()}-${project.version}.jar")
- projectJarFile.mkdirs()
- Files.copy(file("$buildDir/libs/${project.name}-${project.version}.jar").toPath(), projectJarFile.toPath(), REPLACE_EXISTING)
- validatePluginJar(projectJarFile, project.group)
- }
-}
-
-task generateRubySupportFiles() {
- doLast {
- generateRubySupportFilesForPlugin(project.description, project.group, version)
- }
-}
-
-task removeObsoleteJars() {
- doLast {
- new FileNameFinder().getFileNames(
- projectDir.toString(),
- "vendor/**/" + pluginInfo.pluginFullName() + "*.jar",
- "vendor/**/" + pluginInfo.pluginFullName() + "-" + version + ".jar").each { f ->
- delete f
- }
- }
-}
-
-task gem(dependsOn: [downloadAndInstallJRuby, removeObsoleteJars, vendor, generateRubySupportFiles]) {
- doLast {
- buildGem(projectDir, buildDir, pluginInfo.pluginFullName() + ".gemspec")
- }
-}
diff --git a/plc4j/integrations/logstash-plugin/docs/index.asciidoc b/plc4j/integrations/logstash-plugin/docs/index.asciidoc
deleted file mode 100644
index cc47ac1..0000000
--- a/plc4j/integrations/logstash-plugin/docs/index.asciidoc
+++ /dev/null
@@ -1,117 +0,0 @@
-:plugin: example
-:type: input
-:default_codec: plain
-// Update header with plugin name and default codec
-
-///////////////////////////////////////////
-START - GENERATED VARIABLES, DO NOT EDIT!
-///////////////////////////////////////////
-:version: %VERSION%
-:release_date: %RELEASE_DATE%
-:changelog_url: %CHANGELOG_URL%
-:include_path: ../../../../logstash/docs/include
-///////////////////////////////////////////
-END - GENERATED VARIABLES, DO NOT EDIT!
-///////////////////////////////////////////
-
-[id="plugins-{type}s-{plugin}"]
-
-=== Example input plugin
-
-include::{include_path}/plugin_header.asciidoc[]
-
-==== Description
-
-Add plugin description here
-
-// Format anchors and links to support generated ids for versioning
-// Sample anchor: [id="plugins-{type}s-{plugin}-setting_name"]
-// Sample link: <<plugins-{type}s-{plugin}-setting_name>>
-
-[id="plugins-{type}s-{plugin}-options"]
-==== Example Input Configuration Options
-
-[cols="<,<,<",options="header",]
-|=======================================================================
-|Setting |Input type|Required
-| <<plugins-{type}s-{plugin}-a_setting_name>> |<<boolean,boolean>>|No
-| <<plugins-{type}s-{plugin}-another_setting_name>> |<<hash,hash>>|No
-| <<plugins-{type}s-{plugin}-setting_name_3>> |<<string,string>>|No
-| <<plugins-{type}s-{plugin}-setting_name_4>> |<<number,number>>|No
-| <<plugins-{type}s-{plugin}-setting_name_5>> |<<array,array>>|No
-| <<plugins-{type}s-{plugin}-setting_name_6>> |<<bytes,bytes>>|No
-| <<plugins-{type}s-{plugin}-setting_name_7>> |<<path,path>>|No
-| <<plugins-{type}s-{plugin}-setting_name_8>> |<<password,password>>|No
-|=======================================================================
-
-[id="plugins-{type}s-{plugin}-a_setting_name"]
-===== `a_setting_name`
-
- * Value type is <<boolean,boolean>>
- * Default value is `true`
-
-Add description here
-
-[id="plugins-{type}s-{plugin}-another_setting_name"]
-===== `another_setting_name`
-
- * Value type is <<hash,hash>>
- * Default value is `{}`
-
-Add description here
-
-[id="plugins-{type}s-{plugin}-setting_name_3"]
-===== `setting_name_3`
-
- * Value type is <<string,string>>
- * Default value is `{}`
-
-Add description here
-
-[id="plugins-{type}s-{plugin}-setting_name_4"]
-===== `setting_name_4`
-
- * Value type is <<number,number>>
- * Default value is `0`
-
-Add description here
-
-[id="plugins-{type}s-{plugin}-setting_name_5"]
-===== `setting_name_5`
-
- * Value type is <<array,array>>
- * Default value is {}
-
-Add description here
-
-[id="plugins-{type}s-{plugin}-setting_name_6"]
-===== `setting_name_6`
-
- * Value type is <<bytes,bytes>>
- * Default value is {}
-
-Add description here
-
-[id="plugins-{type}s-{plugin}-setting_name_7"]
-===== `setting_name_7`
-
- * Value type is <<path,path>>
- * Default value is {}
-
-Add description here
-
-[id="plugins-{type}s-{plugin}-setting_name_8"]
-===== `setting_name_8`
-
- * Value type is <<password,password>>
- * Default value is {}
-
-Add description here
-
-// The full list of Value Types is here:
-// https://www.elastic.co/guide/en/logstash/current/configuration-file-structure.html
-
-[id="plugins-{type}s-{plugin}-common-options"]
-include::{include_path}/{type}.asciidoc[]
-
-:default_codec!:
diff --git a/plc4j/integrations/logstash-plugin/gradle/wrapper/gradle-wrapper.jar b/plc4j/integrations/logstash-plugin/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 1948b90..0000000
Binary files a/plc4j/integrations/logstash-plugin/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/plc4j/integrations/logstash-plugin/gradle/wrapper/gradle-wrapper.properties b/plc4j/integrations/logstash-plugin/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index e7657b1..0000000
--- a/plc4j/integrations/logstash-plugin/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Wed Aug 14 14:02:50 CEST 2019
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip
diff --git a/plc4j/integrations/logstash-plugin/gradlew b/plc4j/integrations/logstash-plugin/gradlew
deleted file mode 100755
index cccdd3d..0000000
--- a/plc4j/integrations/logstash-plugin/gradlew
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/usr/bin/env sh
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
-exec "$JAVACMD" "$@"
diff --git a/plc4j/integrations/logstash-plugin/gradlew.bat b/plc4j/integrations/logstash-plugin/gradlew.bat
deleted file mode 100644
index e95643d..0000000
--- a/plc4j/integrations/logstash-plugin/gradlew.bat
+++ /dev/null
@@ -1,84 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/plc4j/integrations/logstash-plugin/pom.xml b/plc4j/integrations/logstash-plugin/pom.xml
index 0430496..99a51fc 100644
--- a/plc4j/integrations/logstash-plugin/pom.xml
+++ b/plc4j/integrations/logstash-plugin/pom.xml
@@ -1,182 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4j-integrations</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </parent>
-
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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
+
+ http://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.
+
+-->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j-integrations</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ </parent>
+
<artifactId>plc4j-logstash-plugin</artifactId>
-
<name>PLC4J: Integrations: Logstash plugin</name>
<description>Integration module for integrating PLC4X into Elastic Logstash.</description>
- <properties>
- <gradle.executable>./gradlew</gradle.executable>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <executions>
- <execution>
- <id>default-compile</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>default-testCompile</id>
- <phase>test-compile</phase>
- <goals>
- <goal>testCompile</goal>
- </goals>
- <configuration>
- <skip>true</skip>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <!-- copy all dependencies to target/dependencies -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <inherited>false</inherited>
- <configuration>
- <useBaseVersion>true</useBaseVersion>
- <addParentPoms>true</addParentPoms>
- <copyPom>true</copyPom>
- <useRepositoryLayout>true</useRepositoryLayout>
- <outputDirectory>${project.build.directory}/dependencies</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <!-- execute Gradle command -->
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>gradle</id>
- <phase>prepare-package</phase>
- <configuration>
- <executable>${gradle.executable}</executable>
- <arguments>
- <!-- <argument>clean</argument>-->
- <argument>vendor</argument>
- <argument>-Pgroup=${project.groupId}</argument>
- <argument>-Pversion=${project.version}</argument>
- <argument>-S</argument>
- </arguments>
- </configuration>
- <goals>
- <goal>exec</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <!-- copy generated JARs -->
- <!--<plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-gradle-jars</id>
- <phase>package</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>${basedir}/target</outputDirectory>
- <resources>
- <resource>
- <directory>build/libs/</directory>
- <includes>
- <include>${project.artifactId}-${project.version}.jar</include>
- <include>${project.artifactId}-${project.version}-javadoc.jar</include>
- <include>${project.artifactId}-${project.version}-sources.jar</include>
- </includes>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>-->
- <!-- attach copied JARs to build -->
- <!--<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-artifacts</id>
- <phase>package</phase>
- <goals>
- <goal>attach-artifact</goal>
- </goals>
- <configuration>
- <artifacts>
- <artifact>
- <file>target/${project.artifactId}-${project.version}-javadoc.jar</file>
- <type>jar</type>
- <classifier>javadoc</classifier>
- </artifact>
- <artifact>
- <file>target/${project.artifactId}-${project.version}-sources.jar</file>
- <type>jar</type>
- <classifier>sources</classifier>
- </artifact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>-->
- </plugins>
- </build>
- <profiles>
- <!-- TODO test linux and mac profiles -->
- <profile>
- <id>windows</id>
- <activation>
- <os>
- <family>windows</family>
- </os>
- </activation>
- <properties>
- <gradle.executable>gradlew.bat</gradle.executable>
- </properties>
- </profile>
- <profile>
- <id>mac</id>
- <activation>
- <os>
- <family>mac</family>
- </os>
- </activation>
- <properties>
- <gradle.executable>gradlew</gradle.executable>
- </properties>
- </profile>
- <profile>
- <id>unix</id>
- <activation>
- <os>
- <family>unix</family>
- <name>Linux</name>
- </os>
- </activation>
- <properties>
- <gradle.executable>gradlew</gradle.executable>
- </properties>
- </profile>
- </profiles>
+ <build>
+ <plugins>
+ <!-- Create a fat-jar containing all the dependencies -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>assemble-all</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- Prepare the gemspec file containing the project information -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build-gem</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ <configuration>
+ <resources>
+ <resource>
+ <directory>src/gem</directory>
+ <filtering>true</filtering>
+ <targetPath>${project.build.directory}/gem</targetPath>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j-api</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4x-tools-logstash-core</artifactId>
+ <version>${project.version}-${logstash.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+ </dependencies>
+
</project>
diff --git a/plc4j/integrations/logstash-plugin/src/gem/logstash-input-plc4x.gemspec b/plc4j/integrations/logstash-plugin/src/gem/logstash-input-plc4x.gemspec
new file mode 100644
index 0000000..775f7a1
--- /dev/null
+++ b/plc4j/integrations/logstash-plugin/src/gem/logstash-input-plc4x.gemspec
@@ -0,0 +1,23 @@
+Gem::Specification.new do |s|
+ s.name = '${project.artifactId}'
+ s.version = ${project.version}
+ s.licenses = ['Apache-2.0']
+ s.summary = "${project.name}"
+ s.description = "${project.description}"
+ s.authors = ['Apache Software Foundation']
+ s.email = 'dev@plc4x.apache.org'
+ s.homepage = "http://plc4x.apache.org/index.html"
+ s.require_paths = ['lib', 'vendor/jar-dependencies']
+
+ # Files
+ s.files = Dir["lib/**/*","spec/**/*","*.gemspec","*.md","CONTRIBUTORS","Gemfile","LICENSE","NOTICE.TXT", "vendor/jar-dependencies/**/*.jar", "vendor/jar-dependencies/**/*.rb", "VERSION", "docs/**/*"]
+
+ # Special flag to let us know this is actually a logstash plugin
+ s.metadata = { 'logstash_plugin' => 'true', 'logstash_group' => 'input'}
+
+ # Gem dependencies
+ s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
+ s.add_runtime_dependency 'jar-dependencies'
+
+ s.add_development_dependency 'logstash-devutils'
+end
\ No newline at end of file
diff --git a/plc4j/integrations/logstash-plugin/src/main/java/org/apache/plc4x/logstash/Plc4xInput.java b/plc4j/integrations/logstash-plugin/src/main/java/org/apache/plc4x/logstash/Plc4xInput.java
index fb77670..6f31d04 100644
--- a/plc4j/integrations/logstash-plugin/src/main/java/org/apache/plc4x/logstash/Plc4xInput.java
+++ b/plc4j/integrations/logstash-plugin/src/main/java/org/apache/plc4x/logstash/Plc4xInput.java
@@ -1,3 +1,21 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you 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
+
+ http://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.
+*/
package org.apache.plc4x.logstash;
import co.elastic.logstash.api.Configuration;
@@ -5,7 +23,6 @@ import co.elastic.logstash.api.Context;
import co.elastic.logstash.api.Input;
import co.elastic.logstash.api.LogstashPlugin;
import co.elastic.logstash.api.PluginConfigSpec;
-import org.apache.commons.lang3.StringUtils;
import org.apache.plc4x.java.PlcDriverManager;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
@@ -14,10 +31,7 @@ import org.apache.plc4x.java.api.messages.PlcReadResponse;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CountDownLatch;
import java.util.function.Consumer;
// class name must match plugin name
@@ -81,12 +95,12 @@ public class Plc4xInput implements Input {
@Override
public void stop() {
- stopped = true; // set flag to request cooperative stop of input
+// stopped = true; // set flag to request cooperative stop of input
}
@Override
public void awaitStop() throws InterruptedException {
- done.await(); // blocks until input has stopped
+// done.await(); // blocks until input has stopped
}
@Override
diff --git a/plc4j/integrations/logstash-plugin/src/test/java/org/apache/plc4x/logstash/JavaInputExampleTest.java b/plc4j/integrations/logstash-plugin/src/test/java/org/apache/plc4x/logstash/JavaInputExampleTest.java
index 19597e3..6d89749 100644
--- a/plc4j/integrations/logstash-plugin/src/test/java/org/apache/plc4x/logstash/JavaInputExampleTest.java
+++ b/plc4j/integrations/logstash-plugin/src/test/java/org/apache/plc4x/logstash/JavaInputExampleTest.java
@@ -1,8 +1,27 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you 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
+
+ http://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.
+*/
package org.apache.plc4x.logstash;
import co.elastic.logstash.api.Configuration;
import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
+import org.junit.Ignore;
import org.junit.Test;
import org.logstash.plugins.ConfigurationImpl;
@@ -15,12 +34,13 @@ import java.util.function.Consumer;
public class JavaInputExampleTest {
@Test
+ @Ignore
public void testJavaInputExample() {
String prefix = "This is message";
long eventCount = 5;
Map<String, Object> configValues = new HashMap<>();
- configValues.put(Plc4xInput.PREFIX_CONFIG.name(), prefix);
- configValues.put(Plc4xInput.EVENT_COUNT_CONFIG.name(), eventCount);
+// configValues.put(Plc4xInput.PREFIX_CONFIG.name(), prefix);
+// configValues.put(Plc4xInput.EVENT_COUNT_CONFIG.name(), eventCount);
Configuration config = new ConfigurationImpl(configValues);
Plc4xInput input = new Plc4xInput("test-id", config, null);
TestConsumer testConsumer = new TestConsumer();
diff --git a/pom.xml b/pom.xml
index fe66469..90885e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -143,6 +143,7 @@
<junit.version>4.12</junit.version>
<log4j.version>2.11.1</log4j.version>
<logback.version>1.2.3</logback.version>
+ <logstash.version>7.3.0</logstash.version>
<lucene.version>8.0.0</lucene.version>
<metrics-core.version>3.1.2</metrics-core.version>
<mockito.version>2.24.5</mockito.version>
@@ -1547,6 +1548,7 @@
<thrift.configure.executable>./configure</thrift.configure.executable>
<thrift.make.executable>make</thrift.make.executable>
<thrift.compiler.executable>thrift</thrift.compiler.executable>
+ <gradlew.executable>./gradlew</gradlew.executable>
</properties>
</profile>
<!-- Profile for mac (Self-Enabling) -->
@@ -1571,6 +1573,7 @@
<thrift.configure.executable>./configure</thrift.configure.executable>
<thrift.make.executable>make</thrift.make.executable>
<thrift.compiler.executable>thrift</thrift.compiler.executable>
+ <gradlew.executable>./gradlew</gradlew.executable>
</properties>
</profile>
<!-- profile for windows (Self-Enabling) -->
@@ -1596,6 +1599,7 @@
<thrift.configure.executable>configure</thrift.configure.executable>
<thrift.make.executable>make</thrift.make.executable>
<thrift.compiler.executable>thrift.exe</thrift.compiler.executable>
+ <gradlew.executable>gradlew.bat</gradlew.executable>
</properties>
</profile>
diff --git a/tools/logstash/pom.xml b/tools/logstash/pom.xml
new file mode 100644
index 0000000..e8468d5
--- /dev/null
+++ b/tools/logstash/pom.xml
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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
+
+ http://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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4x-tools</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>plc4x-tools-logstash-core</artifactId>
+ <packaging>pom</packaging>
+
+ <name>Tools: Logstash-Core</name>
+ <description>Building of the Logstash-Core library.</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.googlecode.maven-download-plugin</groupId>
+ <artifactId>download-maven-plugin</artifactId>
+ <version>1.4.0</version>
+ <executions>
+ <execution>
+ <id>get-logstash</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>wget</goal>
+ </goals>
+ <configuration>
+ <url>https://github.com/elastic/logstash/archive/v${logstash.version}.tar.gz</url>
+ <unpack>true</unpack>
+ <outputDirectory>${project.build.directory}</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.6.0</version>
+ <executions>
+ <execution>
+ <id>compile-logstash-core</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <executable>${gradlew.executable}</executable>
+ <arguments>
+ <argument>:logstash-core:assemble</argument>
+ </arguments>
+ <workingDirectory>${project.build.directory}/logstash-${logstash.version}</workingDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>install-logstash-core-jar</id>
+ <phase>install</phase>
+ <goals>
+ <goal>install-file</goal>
+ </goals>
+ <configuration>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4x-tools-logstash-core</artifactId>
+ <version>${project.version}-${logstash.version}</version>
+ <packaging>jar</packaging>
+ <file>${project.build.directory}/logstash-${logstash.version}/logstash-core/build/libs/logstash-core-${logstash.version}.jar</file>
+ </configuration>
+ </execution>
+ <execution>
+ <id>install-logstash-core-sources-jar</id>
+ <phase>install</phase>
+ <goals>
+ <goal>install-file</goal>
+ </goals>
+ <configuration>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4x-tools-logstash-core</artifactId>
+ <version>${project.version}-${logstash.version}</version>
+ <packaging>jar</packaging>
+ <classifier>sources</classifier>
+ <file>${project.build.directory}/logstash-${logstash.version}/logstash-core/build/libs/logstash-core-${logstash.version}-sources.jar</file>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!--plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>deploy-logstash-core-jar</id>
+ <phase></phase>
+ </execution>
+ </executions>
+ </plugin-->
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
diff --git a/tools/pom.xml b/tools/pom.xml
index cc06d26..bea523d 100644
--- a/tools/pom.xml
+++ b/tools/pom.xml
@@ -40,6 +40,12 @@
</modules>
</profile>
<profile>
+ <id>with-logstash</id>
+ <modules>
+ <module>logstash</module>
+ </modules>
+ </profile>
+ <profile>
<id>with-proxies</id>
<modules>
<module>thrift</module>