2021-11-30 16:03:33 -05:00
|
|
|
import java.util.jar.JarFile
|
|
|
|
import java.util.regex.Matcher
|
|
|
|
|
2020-04-08 13:46:35 -04:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Configures JAR manifest entries
|
|
|
|
|
2021-03-08 08:59:08 -05:00
|
|
|
subprojects {
|
2020-04-08 13:46:35 -04:00
|
|
|
// Declare these inline for now. Don't know if it makes sense to declare them
|
|
|
|
// per-project.
|
2021-03-18 06:04:45 -04:00
|
|
|
def title = "Lucene Search Engine: ${project.name}"
|
|
|
|
def implementationTitle = "org.apache.lucene"
|
2021-10-17 19:24:11 -04:00
|
|
|
def legaleseDir = project(":").projectDir
|
2020-04-08 13:46:35 -04:00
|
|
|
|
2021-10-19 04:04:42 -04:00
|
|
|
// Apply the manifest to any JAR or WAR file created by any project.
|
2020-04-08 13:46:35 -04:00
|
|
|
tasks.withType(Jar)
|
2021-03-18 06:04:45 -04:00
|
|
|
.configureEach { task ->
|
|
|
|
// Compute git status once on the root project prior to assembling manifest.
|
|
|
|
dependsOn ":gitStatus"
|
2020-04-08 13:46:35 -04:00
|
|
|
|
2021-03-18 06:04:45 -04:00
|
|
|
// Because git status is a task we must defer computing this
|
|
|
|
// until status has been computed. We do this with a provider.
|
|
|
|
def implementationVersion = provider {
|
|
|
|
// LUCENE-9310: gitRev should always be there but IntelliJ does something
|
|
|
|
// awkward on import and resolves provider properties even though task dependencies
|
|
|
|
// have not been run yet?
|
|
|
|
def gitRev = rootProject.hasProperty("gitRev") ? rootProject.gitRev : ""
|
2020-06-01 04:00:46 -04:00
|
|
|
|
2021-03-18 06:04:45 -04:00
|
|
|
// For snapshot builds just include the project version and gitRev so that
|
|
|
|
// JARs don't need to be recompiled just because the manifest has changed.
|
|
|
|
if (snapshotBuild) {
|
|
|
|
return "${project.version} ${gitRev} [snapshot build, details omitted]"
|
|
|
|
} else {
|
|
|
|
return "${project.version} ${gitRev} - ${System.properties['user.name']} - ${buildDate} ${buildTime}"
|
|
|
|
}
|
|
|
|
}
|
2020-04-08 13:46:35 -04:00
|
|
|
|
2021-11-30 16:03:33 -05:00
|
|
|
def manifestAttrs = [
|
2021-03-18 06:04:45 -04:00
|
|
|
"Extension-Name" : implementationTitle,
|
2020-04-08 13:46:35 -04:00
|
|
|
|
2021-03-18 06:04:45 -04:00
|
|
|
"Implementation-Vendor" : "The Apache Software Foundation",
|
|
|
|
"Implementation-Title" : implementationTitle,
|
|
|
|
"Implementation-Version": implementationVersion,
|
2020-04-08 13:46:35 -04:00
|
|
|
|
2021-03-18 06:04:45 -04:00
|
|
|
"Specification-Vendor" : "The Apache Software Foundation",
|
|
|
|
"Specification-Version" : project.baseVersion,
|
|
|
|
"Specification-Title" : title,
|
2020-04-08 13:46:35 -04:00
|
|
|
|
2021-08-01 08:14:42 -04:00
|
|
|
// Evaluate these properties lazily so that the defaults are applied properly.
|
|
|
|
"X-Compile-Source-JDK" : "${-> project.sourceCompatibility}",
|
|
|
|
"X-Compile-Target-JDK" : "${-> project.targetCompatibility}",
|
2020-04-08 13:46:35 -04:00
|
|
|
|
2021-03-18 06:04:45 -04:00
|
|
|
"X-Build-JDK" : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
|
2021-11-30 16:03:33 -05:00
|
|
|
"X-Build-OS" : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}"
|
|
|
|
]
|
|
|
|
|
|
|
|
manifest {
|
|
|
|
attributes(manifestAttrs)
|
2021-03-18 06:04:45 -04:00
|
|
|
}
|
2020-04-08 13:46:35 -04:00
|
|
|
|
2021-03-18 06:04:45 -04:00
|
|
|
// Copy legalese into META-INF.
|
|
|
|
metaInf {
|
|
|
|
from(legaleseDir, {
|
|
|
|
include "LICENSE.txt"
|
|
|
|
include "NOTICE.txt"
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2021-11-30 16:03:33 -05:00
|
|
|
}
|