dweiss commented on a change in pull request #1905: URL: https://github.com/apache/lucene-solr/pull/1905#discussion_r500041550
########## File path: lucene/packaging/build.gradle ########## @@ -0,0 +1,171 @@ +/* + * 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, not relevant to binary distribution. + ":lucene:packaging", + // Exclude parent container project of analysis modules (no artifacts). + ":lucene:analysis" + ]) +} + +// 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', configuration: 'docs') +} + +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, { Review comment: This is part of the PR, Uwe - here. https://github.com/apache/lucene-solr/pull/1905/files#diff-d55d7b9fe9d94d4e2e5554e3c1108943R60-R63 I suggested using configuration-based copying instead of pointing at an explicit folder because it has several advantages. First, an artifact exported via configuration is configurable in the place where it logically belongs to. So you can put together a set of documentation artifacts in documentation configuration snippet and just depend on it when you're assembling something that uses those artifacts. The second benefit is that dependencies on tasks assembling those artifacts are automatically resolved - you don't need to know anything beyond the name of the project and configuration from which you're coping. The rest is done by gradle. I think Mike's patch is fine here. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org