You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by rh...@apache.org on 2020/04/16 18:49:05 UTC
[geode] branch develop updated: GEODE-7984: Refactor Gradle scripts
for publishing well-formed POM files (#4956)
This is an automated email from the ASF dual-hosted git repository.
rhoughton pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 4e585e0 GEODE-7984: Refactor Gradle scripts for publishing well-formed POM files (#4956)
4e585e0 is described below
commit 4e585e0a35cf03f101be014b66352ce93645bc22
Author: Robert Houghton <rh...@pivotal.io>
AuthorDate: Thu Apr 16 11:48:26 2020 -0700
GEODE-7984: Refactor Gradle scripts for publishing well-formed POM files (#4956)
Don't Repeat Yourself refactor.
---
boms/geode-all-bom/build.gradle | 65 +------------------------------------
gradle/publish-artifacts.gradle | 72 +++++++++++++++++++++++++++++++++++++++++
gradle/publish-common.gradle | 50 ----------------------------
gradle/publish-java.gradle | 8 +++--
gradle/publish-war.gradle | 8 +++--
5 files changed, 83 insertions(+), 120 deletions(-)
diff --git a/boms/geode-all-bom/build.gradle b/boms/geode-all-bom/build.gradle
index e20dbf5..3237833 100644
--- a/boms/geode-all-bom/build.gradle
+++ b/boms/geode-all-bom/build.gradle
@@ -17,28 +17,10 @@
plugins {
id 'java-platform'
- id 'maven-publish'
id 'geode-dependency-constraints'
- id 'signing'
}
-
-def apacheLicense = '''
- 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.
- '''
+apply from: "${rootDir}/gradle/publish-common.gradle"
publishing {
publications {
@@ -46,22 +28,6 @@ publishing {
from components.javaPlatform
pom {
- name = 'Apache Geode'
- description = 'Apache Geode provides a database-like consistency model, reliable transaction processing and a shared-nothing architecture to maintain very low latency performance with high concurrency processing'
- url = 'http://geode.apache.org'
-
- scm {
- url = 'https://github.com/apache/geode'
- connection = 'scm:git:https://github.com:apache/geode.git'
- developerConnection = 'scm:git:https://github.com:apache/geode.git'
- }
-
- licenses {
- license {
- name = 'The Apache Software License, Version 2.0'
- url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- }
- }
withXml {
// Published Geode artifacts are constrained to match the version of this BOM.
// We exclude any child of the :boms subproject
@@ -79,36 +45,7 @@ publishing {
}
thisNode
}
- withXml {
- def providerAsElement = asElement()
- providerAsElement.insertBefore(
- providerAsElement.ownerDocument().createComment(apacheLicense),
- providerAsElement.firstChild)
- }
-
}
}
}
- repositories {
- maven {
- // Use specified mavenRepository if provided, else use release or snapshot defaults.
- url = project.findProperty("mavenRepository") ?:
- project.isReleaseVersion ? project.mavenReleaseUrl : project.mavenSnapshotUrl
- if (url.toString().startsWith("http") || url.toString().startsWith("sftp")) {
- // Username / password credentials are only supported for http, https, and sftp repos.
- // See the Gradle documentation on Repository Types for more information.
- credentials {
- username project.findProperty("mavenUsername")
- password project.findProperty("mavenPassword")
- }
- }
- }
- }
-}
-
-signing {
- required({project.isReleaseVersion && project.hasProperty('signing.keyId') && project.hasProperty('signing.secretKeyRingFile')})
- sign publishing.publications.maven
}
-
-apply from: "${rootDir}/${scriptDir}/check-pom.gradle"
diff --git a/gradle/publish-artifacts.gradle b/gradle/publish-artifacts.gradle
new file mode 100644
index 0000000..3a0048d
--- /dev/null
+++ b/gradle/publish-artifacts.gradle
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+
+
+task sourcesJar(type: Jar) {
+ from {
+ sourceSets.main.allJava
+ }
+ classifier = 'sources'
+}
+
+task javadocJar(type: Jar) {
+ from {
+ javadoc
+ }
+ classifier = 'javadoc'
+}
+
+publishing {
+ publications {
+ maven(MavenPublication) {
+ pom {
+ withXml {
+ // This black magic checks to see if a dependency has the flag ext.optional=true
+ // set on it, and if so marks the dependency as optional in the maven pom
+ def depMap = project.configurations.compile.dependencies.collectEntries { [it.name, it] }
+ def runtimeDeps = project.configurations.runtime.dependencies.collectEntries {
+ [it.name, it]
+ }
+ depMap.putAll(runtimeDeps)
+ def runtimeOnlyDeps = project.configurations.runtimeOnly.dependencies.collectEntries {
+ [it.name, it]
+ }
+ depMap.putAll(runtimeOnlyDeps)
+ def implementationDependencies = project.configurations.implementation.dependencies.collectEntries {
+ [it.name, it]
+ }
+ depMap.putAll(implementationDependencies)
+ def apiDependencies = project.configurations.api.dependencies.collectEntries {
+ [it.name, it]
+ }
+ depMap.putAll(apiDependencies)
+ asNode().dependencies.dependency.findAll {
+ def dep = depMap.get(it.artifactId.text())
+ return dep?.hasProperty('optional') && dep.optional
+ }.each {
+ if (it.optional) {
+ it.optional.value = 'true'
+ } else {
+ it.appendNode('optional', 'true')
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/gradle/publish-common.gradle b/gradle/publish-common.gradle
index 6d1dab9..c35292e 100644
--- a/gradle/publish-common.gradle
+++ b/gradle/publish-common.gradle
@@ -21,18 +21,6 @@ apply plugin: 'signing'
// The published bom will constrain versions within geode of any subproject with this property set.
project.ext.set('constrainVersionInBom', true)
-if (project.name != 'geode-assembly') {
- task sourcesJar(type: Jar) {
- from sourceSets.main.allJava
- classifier = 'sources'
- }
-
- task javadocJar(type: Jar) {
- from javadoc
- classifier = 'javadoc'
- }
-}
-
def apacheLicense = '''
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -53,12 +41,6 @@ def apacheLicense = '''
publishing {
publications {
maven(MavenPublication) {
- if (project.name != 'geode-assembly') {
- // use the (possibly empty) Jar tasks above for sources and javadoc
- artifact sourcesJar
- artifact javadocJar
- }
-
pom {
name = 'Apache Geode'
description = 'Apache Geode provides a database-like consistency model, reliable transaction processing and a shared-nothing architecture to maintain very low latency performance with high concurrency processing'
@@ -78,38 +60,6 @@ publishing {
}
withXml {
- // This black magic checks to see if a dependency has the flag ext.optional=true
- // set on it, and if so marks the dependency as optional in the maven pom
- def depMap = project.configurations.compile.dependencies.collectEntries { [it.name, it] }
- def runtimeDeps = project.configurations.runtime.dependencies.collectEntries {
- [it.name, it]
- }
- depMap.putAll(runtimeDeps)
- def runtimeOnlyDeps = project.configurations.runtimeOnly.dependencies.collectEntries {
- [it.name, it]
- }
- depMap.putAll(runtimeOnlyDeps)
- def implementationDependencies = project.configurations.implementation.dependencies.collectEntries {
- [it.name, it]
- }
- depMap.putAll(implementationDependencies)
- def apiDependencies = project.configurations.api.dependencies.collectEntries {
- [it.name, it]
- }
- depMap.putAll(apiDependencies)
- asNode().dependencies.dependency.findAll {
- def dep = depMap.get(it.artifactId.text())
- return dep?.hasProperty('optional') && dep.optional
- }.each {
- if (it.optional) {
- it.optional.value = 'true'
- } else {
- it.appendNode('optional', 'true')
- }
- }
- }
-
- withXml {
// Geode dependency versions, as with all versions, are locked by the
// Spring dependency-management plugin. We remove version specification as injected by
// project dependencies, e.g., compile project(':geode-core')
diff --git a/gradle/publish-java.gradle b/gradle/publish-java.gradle
index 4abecae..3a47b6a 100644
--- a/gradle/publish-java.gradle
+++ b/gradle/publish-java.gradle
@@ -16,13 +16,15 @@
*/
apply from: "${rootDir}/gradle/publish-common.gradle"
+apply from: "${rootDir}/gradle/publish-artifacts.gradle"
publishing {
publications {
maven(MavenPublication) {
- if (project.name != 'geode-assembly') {
- from components.java
- }
+ from components.java
+ // use the (possibly empty) Jar tasks above for sources and javadoc
+ artifact sourcesJar
+ artifact javadocJar
}
}
}
diff --git a/gradle/publish-war.gradle b/gradle/publish-war.gradle
index e5a8283..4710062 100644
--- a/gradle/publish-war.gradle
+++ b/gradle/publish-war.gradle
@@ -16,13 +16,15 @@
*/
apply from: "${rootDir}/gradle/publish-common.gradle"
+apply from: "${rootDir}/gradle/publish-artifacts.gradle"
publishing {
publications {
maven(MavenPublication) {
- if (project.name != 'geode-assembly') {
- from components.web
- }
+ from components.web
+ // use the (possibly empty) Jar tasks above for sources and javadoc
+ artifact sourcesJar
+ artifact javadocJar
}
}
}