@@ -2,15 +2,23 @@ import java.nio.file.Files
2
2
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING
3
3
4
4
apply plugin : ' java'
5
- apply plugin : ' idea'
6
- apply plugin : ' maven-publish'
7
- apply plugin : ' maven'
8
- apply plugin : " distribution"
5
+ apply from : LOGSTASH_CORE_PATH + " /../rubyUtils.gradle"
9
6
10
- group ' org.logstash.javaapi'
11
- version " ${ file("VERSION").text.trim()} "
12
-
13
- description = " Example Java input implementation"
7
+ // ===========================================================================
8
+ // plugin info
9
+ // ===========================================================================
10
+ group ' org.logstashplugins' // must match the package of the main plugin class
11
+ version " ${ file("VERSION").text.trim()} " // read from required VERSION file
12
+ description = " Example Java input implementation"
13
+ pluginInfo. licenses = [' Apache-2.0' ] // list of SPDX license IDs
14
+ 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"
15
+ pluginInfo. authors = [' Elasticsearch' ]
16
+ pluginInfo. email = [' info@elastic.co' ]
17
+ pluginInfo. homepage = " http://www.elastic.co/guide/en/logstash/current/index.html"
18
+ pluginInfo. pluginType = " input"
19
+ pluginInfo. pluginClass = " JavaInputExample"
20
+ pluginInfo. pluginName = " java_input_example" // must match the @LogstashPlugin annotation in the main plugin class
21
+ // ===========================================================================
14
22
15
23
sourceCompatibility = 1.8
16
24
targetCompatibility = 1.8
@@ -50,14 +58,50 @@ dependencies {
50
58
testCompile ' org.jruby:jruby-complete:9.1.13.0'
51
59
}
52
60
61
+ clean {
62
+ delete " ${ projectDir} /Gemfile"
63
+ delete " ${ projectDir} /" + pluginInfo. pluginFullName() + " .gemspec"
64
+ delete " ${ projectDir} /lib/"
65
+ delete " ${ projectDir} /vendor/"
66
+ new FileNameFinder (). getFileNames(projectDir. toString(), pluginInfo. pluginFullName() + " -?.?.?.gem" ). each { filename ->
67
+ delete filename
68
+ }
69
+ }
70
+
53
71
tasks. withType(JavaCompile ) {
54
72
options. encoding = ' UTF-8'
55
73
}
56
74
57
- task vendor (dependsOn : shadowJar) << {
58
- String vendorPathPrefix = " vendor/jar-dependencies"
59
- String projectGroupPath = project. group. replaceAll(' \\ .' , ' /' )
60
- File projectJarFile = file(" ${ vendorPathPrefix} /${ projectGroupPath} /${ project.name} /${ project.version} /${ project.name} -${ project.version} .jar" )
61
- projectJarFile. mkdirs()
62
- Files . copy(file(" $buildDir /libs/${ project.name} -${ project.version} .jar" ). toPath(), projectJarFile. toPath(), REPLACE_EXISTING )
75
+ task vendor (dependsOn : shadowJar) {
76
+ doLast {
77
+ String vendorPathPrefix = " vendor/jar-dependencies"
78
+ String projectGroupPath = project. group. replaceAll(' \\ .' , ' /' )
79
+ File projectJarFile = file(" ${ vendorPathPrefix} /${ projectGroupPath} /${ pluginInfo.pluginFullName()} /${ project.version} /${ pluginInfo.pluginFullName()} -${ project.version} .jar" )
80
+ projectJarFile. mkdirs()
81
+ Files . copy(file(" $buildDir /libs/${ project.name} -${ project.version} .jar" ). toPath(), projectJarFile. toPath(), REPLACE_EXISTING )
82
+ validatePluginJar(projectJarFile, project. group)
83
+ }
84
+ }
85
+
86
+ task generateRubySupportFiles () {
87
+ doLast {
88
+ generateRubySupportFilesForPlugin(project. description, project. group, version)
89
+ }
90
+ }
91
+
92
+ task removeObsoleteJars () {
93
+ doLast {
94
+ new FileNameFinder (). getFileNames(
95
+ projectDir. toString(),
96
+ " vendor/**/" + pluginInfo. pluginFullName() + " *.jar" ,
97
+ " vendor/**/" + pluginInfo. pluginFullName() + " -" + version + " .jar" ). each { f ->
98
+ delete f
99
+ }
100
+ }
101
+ }
102
+
103
+ task gem (dependsOn : [downloadAndInstallJRuby, removeObsoleteJars, vendor, generateRubySupportFiles]) {
104
+ doLast {
105
+ buildGem(projectDir, buildDir, pluginInfo. pluginFullName() + " .gemspec" )
106
+ }
63
107
}
0 commit comments