|
| 1 | +plugins { |
| 2 | + id 'java' |
| 3 | + id 'com.github.johnrengelman.shadow' version '1.2.2' |
| 4 | +} |
| 5 | + |
| 6 | +def xbibGroup = 'org.xbib.elasticsearch.plugin' |
| 7 | +def xbibVersion = '2.2.0.0' |
| 8 | + |
| 9 | +group = xbibGroup |
| 10 | +version = xbibVersion |
| 11 | + |
| 12 | +println "Current JVM: " + org.gradle.internal.jvm.Jvm.current() |
| 13 | + |
| 14 | +ext { |
| 15 | + pluginName = 'knapsack' |
| 16 | + pluginClassname = 'org.xbib.elasticsearch.plugin.knapsack.KnapsackPlugin' |
| 17 | + pluginDescription = 'An import/export plugin for Elasticsearch' |
| 18 | + versions = [ |
| 19 | + 'elasticsearch' : '2.2.0', |
| 20 | + 'elasticsearch-helper' : '2.2.0.3', |
| 21 | + 'log4j': '2.5', |
| 22 | + 'junit' : '4.12', |
| 23 | + 'wagon' : '2.10' |
| 24 | + ] |
| 25 | +} |
| 26 | + |
| 27 | +apply plugin: 'java' |
| 28 | +apply plugin: 'maven' |
| 29 | + |
| 30 | +sourceCompatibility = 1.7 |
| 31 | +targetCompatibility = 1.7 |
| 32 | + |
| 33 | +repositories { |
| 34 | + mavenCentral() |
| 35 | + mavenLocal() |
| 36 | + jcenter() |
| 37 | + maven { |
| 38 | + url "http://xbib.org/repository" |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +sourceSets { |
| 43 | + integrationTest { |
| 44 | + java { |
| 45 | + compileClasspath += main.output + test.output |
| 46 | + runtimeClasspath += main.output + test.output |
| 47 | + srcDir file('src/integration-test/java') |
| 48 | + } |
| 49 | + resources.srcDir file('src/integration-test/resources') |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +configurations { |
| 54 | + wagon |
| 55 | + integrationTestCompile.extendsFrom testCompile |
| 56 | + integrationTestRuntime.extendsFrom testRuntime |
| 57 | + releaseJars { |
| 58 | + extendsFrom runtime |
| 59 | + exclude group: 'org.elasticsearch' |
| 60 | + exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core' |
| 61 | + exclude group: 'org.slf4j' |
| 62 | + exclude group: 'log4j' |
| 63 | + } |
| 64 | +} |
| 65 | + |
| 66 | +dependencies { |
| 67 | + compile "org.elasticsearch:elasticsearch:${versions.elasticsearch}" |
| 68 | + compile "org.xbib.elasticsearch.plugin:elasticsearch-helper:${versions.'elasticsearch-helper'}" |
| 69 | + compile "org.apache.logging.log4j:log4j-slf4j-impl:${versions.log4j}" |
| 70 | + compile "org.apache.logging.log4j:log4j-core:${versions.log4j}" |
| 71 | + testCompile "junit:junit:${versions.junit}" |
| 72 | + integrationTestCompile "junit:junit:${versions.junit}" |
| 73 | + //releaseJars "${project.group}:${project.name}:${project.version}:all" |
| 74 | + wagon "org.apache.maven.wagon:wagon-ssh-external:${versions.wagon}" |
| 75 | +} |
| 76 | + |
| 77 | +tasks.withType(JavaCompile) { |
| 78 | + options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" |
| 79 | +} |
| 80 | + |
| 81 | +test { |
| 82 | + systemProperties['path.home'] = System.getProperty("user.dir") |
| 83 | + testLogging { |
| 84 | + showStandardStreams = false |
| 85 | + exceptionFormat = 'full' |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +task integrationTest(type: Test, dependsOn: ['unpackPlugin']) { |
| 90 | + testClassesDir = sourceSets.integrationTest.output.classesDir |
| 91 | + classpath = configurations.integrationTestCompile |
| 92 | + classpath += fileTree("plugins/${pluginName}").include('*.jar') |
| 93 | + classpath += sourceSets.integrationTest.output |
| 94 | + // without this trick to remove identical jars from classpath, an Elasticsearch bug whines about a "jar hell" |
| 95 | + classpath -= configurations.releaseJars |
| 96 | + outputs.upToDateWhen { false } |
| 97 | + systemProperty 'path.home', projectDir.absolutePath |
| 98 | + testLogging.showStandardStreams = false |
| 99 | +} |
| 100 | + |
| 101 | +integrationTest.mustRunAfter test |
| 102 | +check.dependsOn integrationTest |
| 103 | + |
| 104 | +clean { |
| 105 | + delete "plugins" |
| 106 | + delete "data" |
| 107 | + delete "logs" |
| 108 | +} |
| 109 | + |
| 110 | +task sourcesJar(type: Jar, dependsOn: classes) { |
| 111 | + from sourceSets.main.allSource |
| 112 | + into 'build/tmp/sources' |
| 113 | + classifier 'sources' |
| 114 | +} |
| 115 | + |
| 116 | +shadowJar { |
| 117 | + baseName = project.name |
| 118 | + version = project.version |
| 119 | + classifier = 'all' |
| 120 | +} |
| 121 | + |
| 122 | +task makePluginDescriptor(type: Copy) { |
| 123 | + from 'src/main/templates' |
| 124 | + into 'build/tmp/plugin' |
| 125 | + expand([ |
| 126 | + 'descriptor': [ |
| 127 | + 'name': pluginName, |
| 128 | + 'classname': pluginClassname, |
| 129 | + 'description': pluginDescription, |
| 130 | + 'jvm': true, |
| 131 | + 'site': false, |
| 132 | + 'isolated': true, |
| 133 | + 'version': project.property('version'), |
| 134 | + 'javaVersion': project.property('targetCompatibility'), |
| 135 | + 'elasticsearchVersion' : versions.elasticsearch |
| 136 | + ] |
| 137 | + ]) |
| 138 | +} |
| 139 | + |
| 140 | +task pluginZip(type: Zip, dependsOn: [':jar', ':makePluginDescriptor']) { |
| 141 | + from files(libsDir) |
| 142 | + from configurations.releaseJars |
| 143 | + from 'build/tmp/plugin' |
| 144 | + classifier = 'plugin' |
| 145 | +} |
| 146 | + |
| 147 | +task unpackPlugin(type: Copy, dependsOn: [':pluginZip']) { |
| 148 | + delete "plugins" |
| 149 | + from configurations.releaseJars |
| 150 | + from 'build/tmp/plugin' |
| 151 | + into "plugins/${pluginName}" |
| 152 | +} |
| 153 | + |
| 154 | +artifacts { |
| 155 | + archives sourcesJar, shadowJar, pluginZip |
| 156 | +} |
| 157 | + |
| 158 | +uploadArchives { |
| 159 | + repositories { |
| 160 | + if (project.hasProperty("xbibUsername")) { |
| 161 | + mavenDeployer { |
| 162 | + configuration = configurations.wagon |
| 163 | + repository( |
| 164 | + id: 'xbib.org', |
| 165 | + url: uri('scpexe://xbib.org/repository'), |
| 166 | + authentication: [userName: xbibUsername, privateKey: xbibPrivateKey] |
| 167 | + ) |
| 168 | + pom.project { |
| 169 | + inceptionYear '2012' |
| 170 | + licenses { |
| 171 | + license { |
| 172 | + name 'The Apache Software License, Version 2.0' |
| 173 | + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' |
| 174 | + distribution 'repo' |
| 175 | + } |
| 176 | + } |
| 177 | + } |
| 178 | + } |
| 179 | + } |
| 180 | + } |
| 181 | +} |
0 commit comments