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

Adding documentation about creation of uber-JARs #3785

Merged
merged 5 commits into from
Aug 15, 2022
Merged

Adding documentation about creation of uber-JARs #3785

merged 5 commits into from
Aug 15, 2022

Conversation

pgtgrly
Copy link
Contributor

@pgtgrly pgtgrly commented Jul 6, 2022

Signed-off-by: Pranav Garg [email protected]

Description

Adding documentation about creation of uber-JARs

Issues Resolved

#3702

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2022

Gradle Check (Jenkins) Run Completed with:

Pranav Garg added 2 commits July 6, 2022 13:08
@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2022

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2022

Gradle Check (Jenkins) Run Completed with:

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

I like where it's going.

Add the shadow plugin:
```
apply plugin: 'com.github.johnrengelman.shadow'
```
Copy link
Member

Choose a reason for hiding this comment

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

And then what? What do I type now to generate the fat JAR and what does it produce? Feel free to include console output, just walk me through it like a 2yo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apologies, I had previously added the following steps but somehow they did not make it to the commit. updating the PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the console output:

(base) garprana@88665a37c3c3 rest-high-level % ../../gradlew shadowJar

> Configure project :qa:os
Cannot add task 'destructiveDistroTest.docker' as a task with that name already exists.
=======================================
OpenSearch Build Hamster says Hello!
  Gradle Version        : 6.6.1
  OS Info               : Mac OS X 12.4 (x86_64)
  JDK Version           : 11 (JDK)
  JAVA_HOME             : /Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home
  Random Testing Seed   : D0C50CCED424B21E
  In FIPS 140 mode      : false
=======================================

BUILD SUCCESSFUL in 9s
36 actionable tasks: 1 executed, 35 up-to-date

Which is not providing a lot of information so have not included it in the document.

DEVELOPER_GUIDE.md Outdated Show resolved Hide resolved
DEVELOPER_GUIDE.md Outdated Show resolved Hide resolved
# Creating uber-JAR/fat-JAR of a module
An uber-JAR is the JAR, which contains classes from all the libraries, on which your project depends and, of course, the classes of current project.

There might be cases where the developer would like to add some custom logic to the code of a module (like the rest client) and generate anuber-JAR that can be directly used by the dependency management tool.
Copy link
Member

Choose a reason for hiding this comment

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

For example, in #3702 a developer needed ...

DEVELOPER_GUIDE.md Outdated Show resolved Hide resolved
Signed-off-by: Pranav Garg <[email protected]>
@pgtgrly pgtgrly requested review from reta and dblock July 15, 2022 06:28
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

Close! I think I want some more about how to use this and an example.

DEVELOPER_GUIDE.md Outdated Show resolved Hide resolved
DEVELOPER_GUIDE.md Outdated Show resolved Hide resolved
apply plugin: 'com.github.johnrengelman.shadow'
```
After applying the plugin you should see a new gradle command `shadowJar`. Run the command using:
```
Copy link
Member

@dblock dblock Jul 18, 2022

Choose a reason for hiding this comment

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

No need to say "After applying ..." it's the next step.

The suggestion is a bit hacky since it implies changing directories. All instructions are usually from root. Let's say

./gradlew :client:rest-high-level:shadowJar

DEVELOPER_GUIDE.md Outdated Show resolved Hide resolved
```
Note: `gradlew` is at the root of OpenSearch project directory. You will have to change the path according to the module you are trying to build the shadowJar for.

This will generate a fat-JAR in the `build/distributions` folder of the module. The default name of the fat-JAR will be `opensearch-[MODULE NAME]-[VERSION].jar`. You can inspect that it contains all the requirements using a decompiler.
Copy link
Member

@dblock dblock Jul 18, 2022

Choose a reason for hiding this comment

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

This will generate a fat-JAR in the build/distributions folder of the module, e.g. ./client/rest-high-level/build/distributions/opensearch-rest-high-level-client-1.4.0-SNAPSHOT.jar.

I think you can remove "the default name..." and the "you can inspect" part because it doesn't really give you much useful info. The example is more helpful.


This will generate a fat-JAR in the `build/distributions` folder of the module. The default name of the fat-JAR will be `opensearch-[MODULE NAME]-[VERSION].jar`. You can inspect that it contains all the requirements using a decompiler.

You can further customize your fat-JAR by customising the plugin, details for this can be found in the Shadow plugin [documentation](https://imperceptiblethoughts.com/shadow/).
Copy link
Member

Choose a reason for hiding this comment

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

More information about shadow plugin can be found here.

DEVELOPER_GUIDE.md Show resolved Hide resolved
Signed-off-by: Pranav Garg <[email protected]>
@pgtgrly pgtgrly requested a review from dblock August 1, 2022 05:35
@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2022

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2022

Gradle Check (Jenkins) Run Completed with:

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

I have some more nitpicks, the only must have is the capitalization of the section title. Also what's up with CI/CD? :(

DEVELOPER_GUIDE.md Outdated Show resolved Hide resolved
DEVELOPER_GUIDE.md Outdated Show resolved Hide resolved
DEVELOPER_GUIDE.md Outdated Show resolved Hide resolved
DEVELOPER_GUIDE.md Outdated Show resolved Hide resolved
Signed-off-by: Pranav Garg <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2022

Gradle Check (Jenkins) Run Completed with:

@pgtgrly
Copy link
Contributor Author

pgtgrly commented Aug 10, 2022

I have some more nitpicks, the only must have is the capitalization of the section title. Also what's up with CI/CD? :(

The jenkins link mentions that there were no ownership configured for the test run, Can that be the issue? All the tests are skipped in the run.

@pgtgrly pgtgrly requested a review from dblock August 10, 2022 07:46
@dblock dblock merged commit a081f2f into opensearch-project:main Aug 15, 2022
@nknize
Copy link
Collaborator

nknize commented Aug 16, 2022

Why are PRs getting merged before passing gradle check?

@dblock
Copy link
Member

dblock commented Aug 16, 2022

Why are PRs getting merged before passing gradle check?

It was a markdown only change (docs). I didn't want the doc to be incorrect regardless of the status of our build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants