blob: 1c4aa3ecc27e42af5a9061d48541847c7e48dc0e [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This project puts together a "distribution", assembling dependencies from
// various other projects.
plugins {
id 'distribution'
}
description = 'Lucene distribution packaging'
// Declare all subprojects that should be included in binary distribution.
// By default everything is included, unless explicitly excluded.
def includeInBinaries = project(":lucene").subprojects.findAll {subproject ->
return !(subproject.path in [
// Exclude packaging & documentation, not relevant to binary distribution.
":lucene:packaging",
":lucene:documentation",
// Exclude parent container project of analysis modules (no artifacts).
":lucene:analysis",
// Exclude native module, which requires manual copying and enabling
":lucene:misc:native"
])
}
// Create a configuration to each subproject and add dependency.
def binaryArtifactsConf = { Project prj ->
"dep-binary" + prj.path.replace(':', '-')
}
def allDepsConf = { Project prj ->
"dep-full" + prj.path.replace(':', '-')
}
configurations {
docs
}
for (Project includedProject : includeInBinaries) {
def confBinaries = binaryArtifactsConf(includedProject)
def confFull = allDepsConf(includedProject)
configurations.create(confBinaries)
configurations.create(confFull)
dependencies { DependencyHandler handler ->
// Just project binaries.
handler.add(confBinaries, project(path: includedProject.path, configuration: "packaging"))
// All project dependencies, including transitive dependencies from the runtime configuration.
handler.add(confFull, project(path: includedProject.path, configuration: "runtimeElements"), {
exclude group: "org.apache.lucene"
// Exclude these from all projects.
exclude group: "commons-logging"
exclude group: "org.slf4j"
})
}
}
dependencies {
docs project(path: ':lucene:documentation', configuration: 'site')
}
distributions {
// The "main" distribution is the binary distribution.
// We should also add 'source' distribution at some point
// (we can't do it now as the build itself is tangled with Solr).
main {
distributionBaseName = 'lucene'
contents {
// Manually correct posix permissions (matters when packaging on Windows).
filesMatching(["**/*.sh", "**/*.bat"]) { copy ->
copy.setMode(0755)
}
// Root distribution files; these are cherry-picked manually.
from(project(':lucene').projectDir, {
include "CHANGES.txt"
include "JRE_VERSION_MIGRATION.md"
include "LICENSE.txt"
include "licenses/*"
include "MIGRATE.md"
include "NOTICE.txt"
include "README.md"
include "SYSTEM_REQUIREMENTS.md"
})
// A couple more missing README files
from(project(':lucene:analysis').projectDir) {
include "README.txt"
into 'analysis'
}
// Copy files from documentation output to 'docs'
from(configurations.docs, {
into 'docs'
})
// Put included project's binary artifacts under their corresponding subfolders.
// This needs to be a for-loop instead of projects.each since the "from" could be resolved at the wrong time
for (Project includedProject : includeInBinaries) {
def basePath = includedProject.path.replaceFirst("^:lucene:", "").replace(':', '/')
def confBinaries = configurations.findByName(binaryArtifactsConf(includedProject))
def confFull = configurations.findByName(allDepsConf(includedProject))
from(confBinaries, {
into basePath
})
from(confFull, {
into "${basePath}/lib"
// Manually exclude the project's main artifact. Don't know if there is any better way to do this.
exclude "lucene-*"
})
}
}
}
}
// Add common packaging artifacts.
configure(project(":lucene").subprojects) {
plugins.withType(JavaPlugin) {
ext {
packagingDir = file("${buildDir}/packaging")
}
configurations {
packaging
}
task assemblePackaging(type: Sync) {
from(projectDir, {
include "README.*"
})
from(tasks.findByName("jar"))
into packagingDir
}
artifacts {
packaging packagingDir, {
builtBy assemblePackaging
}
}
}
}
// Add launch scripts for Luke.
configure(project(":lucene:luke")) {
plugins.withType(JavaPlugin) {
assemblePackaging {
from("${projectDir}/bin", {
})
}
}
}