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:58:20 UTC
[plc4x] 32/44: - Cleaned up the build (less hacks)
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 dd0455140dffe1a45e4468d1774de04f0005d85e
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Wed Aug 21 16:33:13 2019 +0200
- Cleaned up the build (less hacks)
---
plc4j/integrations/logstash-plugin/pom.xml | 59 +++++++++++++++++++---
.../src/gem/lib/logstash/inputs/plc4x.rb | 10 ++--
.../src/gem/logstash-input-plc4x.gemspec | 16 +++---
3 files changed, 64 insertions(+), 21 deletions(-)
diff --git a/plc4j/integrations/logstash-plugin/pom.xml b/plc4j/integrations/logstash-plugin/pom.xml
index 02539a7..b4934c7 100644
--- a/plc4j/integrations/logstash-plugin/pom.xml
+++ b/plc4j/integrations/logstash-plugin/pom.xml
@@ -39,7 +39,45 @@
<build>
<plugins>
- <!-- Download and unpack jruby -->
+ <!--
+ As ruby and gem seem to have problems wirh Maven SNAPSHOT versions,
+ calculate how the version would be without the "SNAPSHOT" prefix and
+ make this available in the property "current-full-version".
+ -->
+ <plugin>
+ <groupId>org.codehaus.gmaven</groupId>
+ <artifactId>groovy-maven-plugin</artifactId>
+ <version>2.1</version>
+ <executions>
+ <execution>
+ <id>provide-custom-properties</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <source>
+ // Calculate some version related stuff
+ def currentVersion = project.version as String
+ def match = (currentVersion =~ /(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?/)
+ print "\nCurrent version: " + currentVersion
+ if(match.count >= 1) {
+ def majorVersion = match[0][1] as Integer
+ def minorVersion = match[0][2] as Integer
+ def bugfixVersion = match[0][3] as Integer
+
+ def currentFullVersion = majorVersion + "." + minorVersion + "." + bugfixVersion
+
+ print "\nCurrent full version: " + currentFullVersion + " (current-full-version)"
+ project.properties['current-full-version'] = currentFullVersion
+ }
+ print "\n"
+ </source>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- Download and unpack JRuby -->
<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
@@ -97,15 +135,18 @@
</goals>
<configuration>
<descriptors>src/assembly/assembly.xml</descriptors>
- <outputDirectory>${project.build.directory}/gem/vendor/jar-dependencies/org/apache/plc4x/logstash-input-plc4x/0.5.0</outputDirectory>
- <finalName>logstash-input-plc4x-0.5.0</finalName>
+ <!-- Redirect the output to where gem will find it -->
+ <outputDirectory>${project.build.directory}/gem/vendor/jar-dependencies/org/apache/plc4x/logstash-input-plc4x/${current-full-version}</outputDirectory>
+ <!-- Ignore the error ... this variable is calculated in the "validate" phase -->
+ <finalName>logstash-input-plc4x-${current-full-version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
+ <!-- The output is just an intermediate file, so make sure it's not installed or deployed -->
<attach>false</attach>
</configuration>
</execution>
</executions>
</plugin>
- <!-- Execute the gem build using jruby -->
+ <!-- Execute the Gem build using JRuby -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
@@ -123,13 +164,13 @@
<argument>../jruby/jruby-${jruby.version}/bin/gem</argument>
<argument>build</argument>
<argument>logstash-input-plc4x.gemspec</argument>
- <!--argument>-output=${project.artifactId}-${project.version}.gem</argument-->
</arguments>
<workingDirectory>${project.build.directory}/gem</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
+ <!-- JRuby and Gem will produce the output artifact, so lets skip the default exscution -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
@@ -143,7 +184,8 @@
</execution>
</executions>
</plugin>
- <!--plugin>
+ <!-- Manually tell maven to add the gem artifact built by JRuby and Gem -->
+ <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
@@ -157,14 +199,15 @@
<configuration>
<artifacts>
<artifact>
- <file>${project.build.directory}/gem/${project.artifactId}-${project.version}.gem</file>
+ <!-- Ignore the error ... this variable is calculated in the "validate" phase -->
+ <file>${project.build.directory}/gem/${project.artifactId}-${current-full-version}.gem</file>
<type>gem</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
- </plugin-->
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
diff --git a/plc4j/integrations/logstash-plugin/src/gem/lib/logstash/inputs/plc4x.rb b/plc4j/integrations/logstash-plugin/src/gem/lib/logstash/inputs/plc4x.rb
index 262f329..30b8b9b 100644
--- a/plc4j/integrations/logstash-plugin/src/gem/lib/logstash/inputs/plc4x.rb
+++ b/plc4j/integrations/logstash-plugin/src/gem/lib/logstash/inputs/plc4x.rb
@@ -17,13 +17,13 @@
# under the License.
# ----------------------------------------------------------------------------
-require "logstash/inputs/base"
-require "logstash/namespace"
-require "logstash-input-plc4x_jars"
-require "java"
+require 'logstash/inputs/base'
+require 'logstash/namespace'
+require 'logstash-input-plc4x_jars'
+require 'java'
class LogStash::Inputs::Plc4xInput < LogStash::Inputs::Base
- config_name "plc4x"
+ config_name 'plc4x'
def self.javaClass() org.apache.plc4x.logstash.Plc4xInput.java_class; end
end
diff --git a/plc4j/integrations/logstash-plugin/src/gem/logstash-input-plc4x.gemspec b/plc4j/integrations/logstash-plugin/src/gem/logstash-input-plc4x.gemspec
index a440d09..90e85c4 100644
--- a/plc4j/integrations/logstash-plugin/src/gem/logstash-input-plc4x.gemspec
+++ b/plc4j/integrations/logstash-plugin/src/gem/logstash-input-plc4x.gemspec
@@ -19,24 +19,24 @@
Gem::Specification.new do |s|
s.name = '${project.artifactId}'
- s.version = '0.5.0'
+ s.version = '${current-full-version}'
s.licenses = ['Apache-2.0']
- s.summary = "${project.name}"
- s.description = "${project.description}"
+ 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.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/**/*"]
+ s.files = Dir['lib/**/*', '*.gemspec', 'vendor/jar-dependencies/**/*.jar']
# 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_runtime_dependency 'logstash-core-plugin-api', '>= 1.60', '<= 2.99'
+ s.add_runtime_dependency 'jar-dependencies', '~> 0'
- s.add_development_dependency 'logstash-devutils'
+ s.add_development_dependency 'logstash-devutils', '~> 0'
end
\ No newline at end of file