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.logstashplugins' // must match the package of the main plugin class
version "${file(" VERSION ").text.trim()}" // read from required VERSION file
description = "RocketMQ Java output implementation"
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 = [ 'Joe.Yao' ]
pluginInfo . email = [ 'ylz@flyrise.cn' ]
pluginInfo . homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
pluginInfo . pluginType = "output"
pluginInfo . pluginClass = "RocketMQ"
pluginInfo . pluginName = "rocketmq" // 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:4.0.4'
}
}
repositories {
mavenCentral ( )
}
apply plugin: 'com.github.johnrengelman.shadow'
shadowJar {
archiveClassifier = null
}
dependencies {
implementation 'org.apache.logging.log4j:log4j-api:2.17.0'
implementation 'org.apache.rocketmq:rocketmq-client:4.9.4'
implementation 'org.apache.rocketmq:rocketmq-acl:4.9.4'
implementation fileTree ( dir: LOGSTASH_CORE_PATH , include: "**/logstash-core-7.17.2.jar" )
testImplementation 'junit:junit:4.12'
testImplementation 'org.jruby:jruby-complete:9.1.13.0'
testImplementation 'org.apache.logging.log4j:log4j-core:2.9.1'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
testImplementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.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'
}
tasks . register ( "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 )
}
}
tasks . register ( "generateRubySupportFiles" ) {
doLast {
generateRubySupportFilesForPlugin ( project . description , project . group , version )
}
}
tasks . register ( "removeObsoleteJars" ) {
doLast {
new FileNameFinder ( ) . getFileNames (
projectDir . toString ( ) ,
"vendor/**/" + pluginInfo . pluginFullName ( ) + "*.jar" ,
"vendor/**/" + pluginInfo . pluginFullName ( ) + "-" + version + ".jar" ) . each { f - >
delete f
}
}
}
tasks . register ( "gem" ) {
dependsOn = [ downloadAndInstallJRuby , removeObsoleteJars , vendor , generateRubySupportFiles ]
doLast {
buildGem ( projectDir , buildDir , pluginInfo . pluginFullName ( ) + ".gemspec" )
}
}