Skip to content

Commit

Permalink
Bump com.netflix.nebula:gradle-extra-configurations-plugin from 9.0.0…
Browse files Browse the repository at this point in the history
… to 10.0.0 in /buildSrc (opensearch-project#7068)

* Bump com.netflix.nebula:gradle-extra-configurations-plugin in /buildSrc

Bumps [com.netflix.nebula:gradle-extra-configurations-plugin](https://github.com/nebula-plugins/gradle-extra-configurations-plugin) from 9.0.0 to 10.0.0.
- [Release notes](https://github.com/nebula-plugins/gradle-extra-configurations-plugin/releases)
- [Changelog](https://github.com/nebula-plugins/gradle-extra-configurations-plugin/blob/main/CHANGELOG.md)
- [Commits](nebula-plugins/gradle-extra-configurations-plugin@v9.0.0...v10.0.0)

---
updated-dependencies:
- dependency-name: com.netflix.nebula:gradle-extra-configurations-plugin
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Added CHANGELOG entry

Signed-off-by: owaiskazi19 <[email protected]>

* Add OptionalDependenciesPlugin to support Maven/Ivy style optional dependencies

Signed-off-by: Andriy Redko <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: owaiskazi19 <[email protected]>
Signed-off-by: Andriy Redko <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: owaiskazi19 <[email protected]>
Co-authored-by: Andriy Redko <[email protected]>
Signed-off-by: Shivansh Arora <[email protected]>
  • Loading branch information
3 people authored and shiv0408 committed Apr 25, 2024
1 parent 6f5b0b5 commit 4098fdc
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Dependencies
- Bump `jackson` from 2.15.1 to 2.15.2 ([#7897](https://github.com/opensearch-project/OpenSearch/pull/7897))
- Bump `netty` from 4.1.91.Final to 4.1.93.Final ([#7901](https://github.com/opensearch-project/OpenSearch/pull/7901))
- Bump `com.netflix.nebula:gradle-extra-configurations-plugin` from 9.0.0 to 10.0.0 in /buildSrc ([#7068](https://github.com/opensearch-project/OpenSearch/pull/7068))

### Changed
- Replace jboss-annotations-api_1.2_spec with jakarta.annotation-api ([#7836](https://github.com/opensearch-project/OpenSearch/pull/7836))
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ dependencies {
api 'commons-codec:commons-codec:1.15'
api 'org.apache.commons:commons-compress:1.23.0'
api 'org.apache.ant:ant:1.10.13'
api 'com.netflix.nebula:gradle-extra-configurations-plugin:9.0.0'
api 'com.netflix.nebula:gradle-extra-configurations-plugin:10.0.0'
api 'com.netflix.nebula:nebula-publishing-plugin:20.3.0'
api 'com.netflix.nebula:gradle-info-plugin:12.1.3'
api 'org.apache.rat:apache-rat:0.15'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
* Copyright 2014-2016 Netflix, Inc.
*
* Licensed 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.
*/
package org.opensearch.gradle.plugin

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.ivy.IvyPublication
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.plugins.PublishingPlugin

/**
* Including the support of `optional` dependencies: https://github.com/nebula-plugins/gradle-extra-configurations-plugin/blob/v9.0.0/src/main/groovy/nebula/plugin/extraconfigurations/OptionalBasePlugin.groovy
*/
class OptionalDependenciesPlugin implements Plugin<Project> {
static final String OPTIONAL_IDENTIFIER = 'optional'

@Override
void apply(Project project) {
enhanceProjectModel(project)
configureMavenPublishPlugin(project)
configureIvyPublishPlugin(project)
}

/**
* Enhances the Project domain object by adding
*
* a) a extra property List that holds optional dependencies
* b) a extra method that can be executed as parameter when declaring dependencies
*
* @param project Project
*/
private void enhanceProjectModel(Project project) {
project.ext.optionalDeps = []

project.ext.optional = { dep ->
project.ext.optionalDeps << dep
}
}

/**
* Configures Maven Publishing plugin to ensure that published dependencies receive the optional element.
*
* @param project Project
*/
private void configureMavenPublishPlugin(Project project) {
project.plugins.withType(PublishingPlugin) {
project.publishing {
publications {
project.extensions.findByType(PublishingExtension)?.publications?.withType(MavenPublication) { MavenPublication pub ->
pub.pom.withXml {
project.ext.optionalDeps.each { dep ->
def foundDep = asNode().dependencies.dependency.find {
it.groupId.text() == dep.group && it.artifactId.text() == dep.name
}

if (foundDep) {
if (foundDep.optional) {
foundDep.optional.value = 'true'
} else {
foundDep.appendNode(OPTIONAL_IDENTIFIER, 'true')
}
}
}
}
}
}
}
}
}

/**
* Configures Ivy Publishing plugin to ensure that published dependencies receive the correct conf attribute value.
*
* @param project Project
*/
private void configureIvyPublishPlugin(Project project) {
project.plugins.withType(PublishingPlugin) {
project.publishing {
publications {
project.extensions.findByType(PublishingExtension)?.publications?.withType(IvyPublication) { IvyPublication pub ->
pub.descriptor.withXml {
def rootNode = asNode()

// Add optional configuration if it doesn't exist yet
if (!rootNode.configurations.find { it.@name == OPTIONAL_IDENTIFIER }) {
rootNode.configurations[0].appendNode('conf', [name: OPTIONAL_IDENTIFIER, visibility: 'public'])
}

// Replace dependency "runtime->default" conf attribute value with "optional"
project.ext.optionalDeps.each { dep ->
def foundDep = rootNode.dependencies.dependency.find { it.@name == dep.name }
foundDep?.@conf = OPTIONAL_IDENTIFIER
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.
#

implementation-class=org.opensearch.gradle.plugin.OptionalDependenciesPlugin
1 change: 0 additions & 1 deletion libs/cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* under the License.
*/
apply plugin: 'opensearch.build'
apply plugin: 'com.netflix.nebula.optional-base'
apply plugin: 'opensearch.publish'

dependencies {
Expand Down
1 change: 0 additions & 1 deletion libs/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

import org.opensearch.gradle.info.BuildParams

apply plugin: 'com.netflix.nebula.optional-base'
apply plugin: 'opensearch.publish'

archivesBaseName = 'opensearch-core'
Expand Down
2 changes: 1 addition & 1 deletion server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ import org.opensearch.gradle.info.BuildParams
plugins {
id('com.google.protobuf') version 'latest.release'
id('opensearch.build')
id('com.netflix.nebula.optional-base')
id('opensearch.publish')
id('opensearch.internal-cluster-test')
id('opensearch.optional-dependencies')
}

publishing {
Expand Down

0 comments on commit 4098fdc

Please sign in to comment.