lucene/gradle/publishing/defaults-maven.gradle

227 lines
7.1 KiB
Groovy

/*
* 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.
*/
// Maven publications and configuration.
//
// the 'published' list contains an explicit list of all projects
// which should be published to Maven repositories.
configure(rootProject) {
ext {
published = [
":lucene:analysis:common",
":lucene:analysis:icu",
":lucene:analysis:kuromoji",
":lucene:analysis:morfologik",
":lucene:analysis:nori",
":lucene:analysis:opennlp",
":lucene:analysis:phonetic",
":lucene:analysis:smartcn",
":lucene:analysis:stempel",
":lucene:backward-codecs",
":lucene:benchmark",
":lucene:classification",
":lucene:codecs",
":lucene:core",
":lucene:demo",
":lucene:expressions",
":lucene:facet",
":lucene:grouping",
":lucene:highlighter",
":lucene:join",
":lucene:memory",
":lucene:misc",
":lucene:monitor",
":lucene:queries",
":lucene:queryparser",
":lucene:replicator",
":lucene:sandbox",
":lucene:spatial-extras",
":lucene:spatial3d",
":lucene:suggest",
":lucene:test-framework"
]
apacheNexusSnapshots = "https://repository.apache.org/content/repositories/snapshots"
}
}
configure(subprojects.findAll { it.path in rootProject.published }) { prj ->
apply plugin: 'maven-publish'
apply plugin: 'signing'
publishing {
repositories {
maven {
name = "ApacheSnapshots"
url = apacheNexusSnapshots
credentials {
def nexusUserName = rootProject.propertyOrDefault('asfNexusUsername', null)
def nexusPwd = rootProject.propertyOrDefault('asfNexusPassword', null)
if (nexusUserName && nexusPwd) {
username nexusUserName
password nexusPwd
}
}
}
}
}
// Skip any test fixtures in publishing.
afterEvaluate {
configurations.matching {
return it.name in [
"testFixturesApiElements",
"testFixturesRuntimeElements"
]
}.all {
project.components.java.withVariantsFromConfiguration(it) {
skip()
}
}
}
// Do not generate gradle metadata files.
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
plugins.withType(JavaPlugin) {
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier = 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
// This moves publishing configuration after all the scripts of all projects
// have been evaluated. This is required because we set artifact groups
// and archivesBaseName in other scripts (artifact-naming.gradle) and
// maven pom does not accept lazy property providers (so everything must
// be in its final form).
//
// In theory project.afterEvaluate closure should also work but for some reason
// it fired earlier than artifact-naming.gradle; don't know whether it's a bug
// in gradle or just complex relationships between lazy collection hooks.
gradle.projectsEvaluated {
publishing {
def configurePom = {
name = "Apache Lucene (module: ${project.name})"
description = name
url = 'https://lucene.apache.org/'
licenses {
license {
name = 'Apache 2'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
inceptionYear = "2000"
issueManagement {
system = "JIRA"
url = "https://issues.apache.org/jira/browse/LUCENE"
}
ciManagement {
system = "Jenkins"
url = "https://builds.apache.org/job/Lucene/"
}
mailingLists {
mailingList {
name = "Java User List"
subscribe = "java-user-subscribe@lucene.apache.org"
unsubscribe = "java-user-unsubscribe@lucene.apache.org"
archive = "https://mail-archives.apache.org/mod_mbox/lucene-java-user/"
}
mailingList {
name = "Java Developer List"
subscribe = "dev-subscribe@lucene.apache.org"
unsubscribe = "dev-unsubscribe@lucene.apache.org"
archive = "https://mail-archives.apache.org/mod_mbox/lucene-dev/"
}
mailingList {
name = "Java Commits List"
subscribe = "commits-subscribe@lucene.apache.org"
unsubscribe = "commits-unsubscribe@lucene.apache.org"
archive = "https://mail-archives.apache.org/mod_mbox/lucene-java-commits/"
}
}
scm {
connection = 'scm:git:https://gitbox.apache.org/repos/asf/lucene.git'
developerConnection = 'scm:git:https://gitbox.apache.org/repos/asf/lucene.git'
url = 'https://gitbox.apache.org/repos/asf?p=lucene.git'
}
}
publications {
unsignedJars(MavenPublication)
jars(MavenPublication)
}
publications.each { publication ->
configure(publication) {
from components.java
groupId = project.group
artifactId = project.archivesBaseName
artifact sourcesJar
artifact javadocJar
pom(configurePom)
// LUCENE-9561:
// Remove dependencyManagement section created by a combination of
// Palantir and the publishing plugin.
//
// https://github.com/palantir/gradle-consistent-versions/issues/550
pom({
withXml {
def dm = asNode().dependencyManagement
if (dm) dm.replaceNode {}
}
})
}
}
}
// Add aliases of convention tasks with shorter names.
task mavenToApacheSnapshots() {
group "Publishing"
description "Publish Maven JARs and POMs to Apache Snapshots repository: ${apacheNexusSnapshots}"
dependsOn "publishUnsignedJarsPublicationToApacheSnapshotsRepository"
}
// 'jars' publication is always signed. We currently don't use it anywhere though.
signing {
sign publishing.publications.jars
}
}
}
}