|
17 | 17 | * under the License.
|
18 | 18 | */
|
19 | 19 |
|
20 |
| -import org.apache.tools.ant.filters.FixCrLfFilter |
21 | 20 | import org.apache.tools.ant.taskdefs.condition.Os
|
| 21 | +import org.apache.tools.ant.filters.FixCrLfFilter |
22 | 22 | import org.elasticsearch.gradle.BuildPlugin
|
23 | 23 | import org.elasticsearch.gradle.EmptyDirTask
|
24 |
| -import org.elasticsearch.gradle.ConcatFilesTask |
25 | 24 | import org.elasticsearch.gradle.MavenFilteringHack
|
26 |
| -import org.elasticsearch.gradle.NoticeTask |
27 |
| -import org.elasticsearch.gradle.precommit.DependencyLicensesTask |
28 |
| -import org.elasticsearch.gradle.precommit.UpdateShasTask |
29 |
| -import org.elasticsearch.gradle.test.RunTask |
| 25 | +import org.elasticsearch.gradle.plugin.PluginBuildPlugin |
30 | 26 |
|
31 |
| -subprojects { |
32 |
| - // CopySpec does not make it easy to create an empty director so we create the directory that we want, and then point CopySpec to its |
33 |
| - // parent to copy to the root of the distribution |
34 |
| - File logs = new File(buildDir, 'logs-hack/logs') |
35 |
| - task createLogDir(type: EmptyDirTask) { |
36 |
| - dir "${logs}" |
37 |
| - dirMode 0755 |
38 |
| - } |
39 |
| - File plugins = new File(buildDir, 'plugins-hack/plugins') |
40 |
| - task createPluginsDir(type: EmptyDirTask) { |
41 |
| - dir "${plugins}" |
42 |
| - dirMode 0755 |
43 |
| - } |
44 |
| - project.ext.archivesFiles = copySpec { |
| 27 | +// need this so Zip/Tar tasks get basic defaults... |
| 28 | +apply plugin: 'base' |
| 29 | + |
| 30 | +// CopySpec does not make it easy to create an empty directory so we |
| 31 | +// create the directory that we want, and then point CopySpec to its |
| 32 | +// parent to copy to the root of the distribution |
| 33 | +ext.logsDir = new File(buildDir, 'logs-hack/logs') |
| 34 | +task createLogsDir(type: EmptyDirTask) { |
| 35 | + dir "${logsDir}" |
| 36 | + dirMode 0755 |
| 37 | +} |
| 38 | +ext.pluginsDir= new File(buildDir, 'plugins-hack/plugins') |
| 39 | +task createPluginsDir(type: EmptyDirTask) { |
| 40 | + dir "${pluginsDir}" |
| 41 | + dirMode 0755 |
| 42 | +} |
| 43 | + |
| 44 | +CopySpec archiveFiles(CopySpec... innerFiles) { |
| 45 | + return copySpec { |
45 | 46 | into("elasticsearch-${version}") {
|
46 | 47 | with libFiles
|
47 | 48 | into('config') {
|
48 | 49 | dirMode 0750
|
49 | 50 | fileMode 0660
|
50 |
| - with configFiles |
| 51 | + with configFiles('def') |
51 | 52 | }
|
52 | 53 | into('bin') {
|
53 | 54 | with copySpec {
|
54 |
| - with binFiles |
55 |
| - from('../../src/main/resources/bin') { |
| 55 | + with binFiles('def') |
| 56 | + from('../src/bin') { |
56 | 57 | include '*.bat'
|
57 | 58 | filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance('crlf'))
|
58 | 59 | }
|
59 |
| - MavenFilteringHack.filter(it, expansions) |
| 60 | + MavenFilteringHack.filter(it, expansionsForDistribution('def')) |
60 | 61 | }
|
61 | 62 | }
|
62 | 63 | into('') {
|
63 | 64 | from {
|
64 | 65 | dirMode 0755
|
65 |
| - logs.getParent() |
| 66 | + logsDir.getParent() |
66 | 67 | }
|
67 | 68 | }
|
68 | 69 | into('') {
|
69 | 70 | from {
|
70 | 71 | dirMode 0755
|
71 |
| - plugins.getParent() |
| 72 | + pluginsDir.getParent() |
72 | 73 | }
|
73 | 74 | }
|
74 | 75 | with commonFiles
|
75 | 76 | with noticeFile
|
76 |
| - from('../../src/main/resources') { |
| 77 | + from('../src') { |
77 | 78 | include 'bin/*.exe'
|
78 | 79 | }
|
79 |
| - if (project.name != 'integ-test-zip') { |
80 |
| - with modulesFiles |
81 |
| - } else { |
82 |
| - with transportModulesFiles |
| 80 | + for (CopySpec files : innerFiles) { |
| 81 | + with files |
83 | 82 | }
|
84 | 83 | }
|
85 | 84 | }
|
86 | 85 | }
|
| 86 | + |
| 87 | +task buildIntegTestZip(type: Zip) { |
| 88 | + dependsOn createLogsDir, createPluginsDir |
| 89 | + destinationDir = file('integ-test-zip/build/distributions') |
| 90 | + baseName = 'elasticsearch' |
| 91 | + with archiveFiles(transportModulesFiles) |
| 92 | +} |
| 93 | + |
| 94 | +task buildZip(type: Zip) { |
| 95 | + dependsOn createLogsDir, createPluginsDir |
| 96 | + destinationDir = file('zip/build/distributions') |
| 97 | + baseName = 'elasticsearch' |
| 98 | + with archiveFiles(modulesFiles) |
| 99 | +} |
| 100 | + |
| 101 | +task buildTar(type: Tar) { |
| 102 | + dependsOn createLogsDir, createPluginsDir |
| 103 | + destinationDir = file('tar/build/distributions') |
| 104 | + baseName = 'elasticsearch' |
| 105 | + extension = 'tar.gz' |
| 106 | + compression = Compression.GZIP |
| 107 | + dirMode 0755 |
| 108 | + fileMode 0644 |
| 109 | + with archiveFiles(modulesFiles) |
| 110 | +} |
| 111 | + |
| 112 | +// This configures the default artifact for the distribution specific |
| 113 | +// subprojects. We have subprojects for two reasons: |
| 114 | +// 1. Gradle project substitutions can only bind to the default |
| 115 | +// configuration of a project |
| 116 | +// 2. The integ-test-zip and zip distributions have the exact same |
| 117 | +// filename, so they must be placed in different directories. |
| 118 | +subprojects { |
| 119 | + apply plugin: 'distribution' |
| 120 | + |
| 121 | + archivesBaseName = 'elasticsearch' |
| 122 | + |
| 123 | + String buildTask = "build${it.name.replaceAll(/-[a-z]/) { it.substring(1).toUpperCase() }.capitalize()}" |
| 124 | + ext.buildDist = parent.tasks.getByName(buildTask) |
| 125 | + artifacts { |
| 126 | + 'default' buildDist |
| 127 | + } |
| 128 | +} |
| 129 | + |
| 130 | +/***************************************************************************** |
| 131 | + * Rest test config * |
| 132 | + *****************************************************************************/ |
| 133 | +subprojects { |
| 134 | + apply plugin: 'elasticsearch.standalone-rest-test' |
| 135 | + apply plugin: 'elasticsearch.rest-test' |
| 136 | + |
| 137 | + if (project.name == 'integ-test-zip') { |
| 138 | + integTest { |
| 139 | + includePackaged true |
| 140 | + } |
| 141 | + } |
| 142 | + |
| 143 | + integTestCluster { |
| 144 | + dependsOn assemble |
| 145 | + distribution = project.name |
| 146 | + } |
| 147 | + integTestRunner { |
| 148 | + if (Os.isFamily(Os.FAMILY_WINDOWS) && System.getProperty('tests.timeoutSuite') == null) { |
| 149 | + // override the suite timeout to 30 mins for windows, because it has the most inefficient filesystem known to man |
| 150 | + systemProperty 'tests.timeoutSuite', '1800000!' |
| 151 | + } |
| 152 | + } |
| 153 | + |
| 154 | + processTestResources { |
| 155 | + inputs.properties(project(':distribution').restTestExpansions) |
| 156 | + MavenFilteringHack.filter(it, project(':distribution').restTestExpansions) |
| 157 | + } |
| 158 | +} |
| 159 | + |
| 160 | +/***************************************************************************** |
| 161 | + * Maven config * |
| 162 | + *****************************************************************************/ |
| 163 | +configure(subprojects.findAll { it.name.contains('zip') }) { |
| 164 | + // only zip distributions go to maven |
| 165 | + BuildPlugin.configurePomGeneration(project) |
| 166 | + apply plugin: 'nebula.info-scm' |
| 167 | + apply plugin: 'nebula.maven-base-publish' |
| 168 | + apply plugin: 'nebula.maven-scm' |
| 169 | + |
| 170 | + // note: the group must be correct before applying the nexus plugin, or |
| 171 | + // it will capture the wrong value... |
| 172 | + project.group = "org.elasticsearch.distribution.${project.name}" |
| 173 | + |
| 174 | + publishing { |
| 175 | + publications { |
| 176 | + nebula { |
| 177 | + artifactId 'elasticsearch' |
| 178 | + artifact buildDist |
| 179 | + } |
| 180 | + /* |
| 181 | + * HUGE HACK: the underlying maven publication library refuses to |
| 182 | + * deploy any attached artifacts when the packaging type is set to |
| 183 | + * 'pom'. But Sonatype's OSS repositories require source files for |
| 184 | + * artifacts that are of type 'zip'. We already publish the source |
| 185 | + * and javadoc for Elasticsearch under the various other subprojects. |
| 186 | + * So here we create another publication using the same name that |
| 187 | + * has the "real" pom, and rely on the fact that gradle will execute |
| 188 | + * the publish tasks in alphabetical order. This lets us publish the |
| 189 | + * zip file and even though the pom says the type is 'pom' instead of |
| 190 | + * 'zip'. We cannot setup a dependency between the tasks because the |
| 191 | + * publishing tasks are created *extremely* late in the configuration |
| 192 | + * phase, so that we cannot get ahold of the actual task. Furthermore, |
| 193 | + * this entire hack only exists so we can make publishing to maven |
| 194 | + * local work, since we publish to maven central externally. |
| 195 | + */ |
| 196 | + nebulaRealPom(MavenPublication) { |
| 197 | + artifactId 'elasticsearch' |
| 198 | + pom.packaging = 'pom' |
| 199 | + pom.withXml { XmlProvider xml -> |
| 200 | + Node root = xml.asNode() |
| 201 | + root.appendNode('name', 'Elasticsearch') |
| 202 | + root.appendNode('description', 'A Distributed RESTful Search Engine') |
| 203 | + root.appendNode('url', PluginBuildPlugin.urlFromOrigin(project.scminfo.origin)) |
| 204 | + Node scmNode = root.appendNode('scm') |
| 205 | + scmNode.appendNode('url', project.scminfo.origin) |
| 206 | + } |
| 207 | + } |
| 208 | + } |
| 209 | + } |
| 210 | +} |
| 211 | + |
0 commit comments