Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow lang-painless maven package to add compile dependencies #11356

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Don't over-allocate in HeapBufferedAsyncEntityConsumer in order to consume the response ([#9993](https://github.com/opensearch-project/OpenSearch/pull/9993))
- [BUG] Fix the thread context that is not properly cleared and messes up the traces ([#10873](https://github.com/opensearch-project/OpenSearch/pull/10873))
- Handle canMatchSearchAfter for frozen context scenario ([#11249](https://github.com/opensearch-project/OpenSearch/pull/11249))
- [BUG] lang-painless missing compile dependencies ([#11353](https://github.com/opensearch-project/OpenSearch/issues/11353))

### Security

Expand Down
11 changes: 9 additions & 2 deletions modules/lang-painless/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,16 @@ shadowJar {
}
}

tasks.validateNebulaPom.dependsOn tasks.generatePomFileForShadowPublication
// Allowing the task generatePomFileForNebulaPublication to generate the POM file with added compile dependencies.
gradle.taskGraph.whenReady {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prudhvigodithi I don't think we are addressing the root of the problem here, there are multiple publications that conflict (apparently, for no reason):

> Task :modules:lang-painless:publishShadowPublicationToMavenLocal                                                                                                         

Multiple publications with coordinates 'org.opensearch.plugin:lang-painless:3.0.0-SNAPSHOT' are published to repository 'mavenLocal'. The publications 'nebula' in project ':modules:lang-painless' and 'shadow' in project ':modules:lang-painless' will overwrite each other!

I am looking why that happens, mind if I push some changes to your pull request?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure @reta please do, I have just focused on the POM generation, which has the problem with the task generatePomFileForShadowPublication coming from the shadow plugin.

Copy link
Contributor Author

@prudhvigodithi prudhvigodithi Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume there is a some issue with shadow plugin with gradle version 8.4, as notice the POM file generated (via generatePomFileForShadowPublication) also is not in right structure where it has the XML ending value <dependencies/>, but not the starting.


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.opensearch.plugin</groupId>
<artifactId>lang-painless</artifactId>
<version>2.10.0</version>
<name>lang-painless</name>
<description>An easy, safe and fast scripting language for OpenSearch</description>
<inceptionYear>2021</inceptionYear>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<name>OpenSearch</name>
<url>https://github.com/opensearch-project/OpenSearch</url>
</developer>
</developers>
<url>https://github.com/opensearch-project/OpenSearch.git</url>
<scm>
<url>https://github.com/opensearch-project/OpenSearch.git</url>
</scm>
<dependencies/>
</project>

Since generatePomFileForNebulaPublication already does the POM generation, I have disabled the generatePomFileForShadowPublication.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also @reta I see task publishShadowPublicationToMavenLocal works on my local.

../../gradlew :modules:lang-painless:publishShadowPublicationToMavenLocal
Picked up JAVA_TOOL_OPTIONS: -Dlog4j2.formatMsgNoLookups=true

> Configure project :
========================= WARNING =========================
         Backwards compatibility tests are disabled!
See https://github.com/opensearch-project/OpenSearch/issues/4173
===========================================================
=======================================
OpenSearch Build Hamster says Hello!
  Gradle Version        : 8.4
  OS Info               : Mac OS X 13.6 (aarch64)
  JDK Version           : 11 (Homebrew JDK)
  JAVA_HOME             : /opt/homebrew/Cellar/openjdk@11/11.0.16.1/libexec/openjdk.jdk/Contents/Home
  Random Testing Seed   : AD775C78920E6AF4
  In FIPS 140 mode      : false
=======================================

BUILD SUCCESSFUL in 5s
54 actionable tasks: 6 executed, 3 from cache, 45 up-to-date

Copy link
Collaborator

@reta reta Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prudhvigodithi the issue is that Shadow publication does not generate the correct POM file anymore (the dependencies) and Nebula does not generate the POM we need either (dependencies are but not other elements), I think I found the place where is is happening.

taskGraph ->
if (taskGraph.hasTask(generatePomFileForShadowPublication)) {
generatePomFileForShadowPublication.enabled = false
}
}

tasks.validateShadowPom.dependsOn tasks.generatePomFileForNebulaPublication
tasks.withType(AbstractPublishToMaven)*.dependsOn "generatePomFileForShadowPublication", "generatePomFileForNebulaPublication"
tasks.withType(AbstractPublishToMaven)*.dependsOn "generatePomFileForNebulaPublication"

tasks.named("dependencyLicenses").configure {
mapping from: /asm-.*/, to: 'asm'
Expand Down
Loading