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

HDDS-11630. Add Build from Maven guide #100

Open
wants to merge 9 commits into
base: HDDS-9225-website-v2
Choose a base branch
from

Conversation

ptlrs
Copy link

@ptlrs ptlrs commented Oct 31, 2024

What changes were proposed in this pull request?

Added content for the developer guide to build ozone sources using maven

Please describe your PR in detail:

  • Updated the content for building ozone sources using maven
  • Added new words to the dictionary to fix the spelling linter

What is the link to the Apache Jira?

https://issues.apache.org/jira/browse/HDDS-11630

How was this patch tested?

Ran the website locally via docker-compose
CI:
https://github.com/ptlrs/ozone-site/actions/runs/11606635045
https://github.com/ptlrs/ozone-site/actions/runs/11811331336
https://github.com/ptlrs/ozone-site/actions/runs/11823796643
https://github.com/ptlrs/ozone-site/actions/runs/11842696659
https://github.com/ptlrs/ozone-site/actions/runs/11842732645

@github-actions github-actions bot added the website-v2 Tasks for the new ozone website targeting the HDDS-9225-website-v2 branch label Oct 31, 2024
@errose28 errose28 self-requested a review November 1, 2024 17:31
@errose28 errose28 added the docs Changes updating documentation on the website label Nov 1, 2024
Copy link
Contributor

@errose28 errose28 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @ptlrs. There's a fair amount of maven options hidden in Ozone that would be good to document here too. We can probably collect input from other devs on what they are using. Some that I have saved:

  • Skip pnpm build of Recon front-end: -Dskip.npx=true
  • Skip shading Hadoop client jars: -DskipShade

These options greatly speed up the build if you are a developer and know you do not need either of these components.

cspell.yaml Outdated Show resolved Hide resolved

## Prerequisites

**TODO** : [HDDS-11625](https://issues.apache.org/jira/browse/HDDS-11625) Finalize the version numbers of prerequisite packages
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's see if we can finalize this as part of this change as well. The only thing I'm not sure about is the maven version. Really Ozone should define this in its pom probably using something like the Maven enforcer plugin. Maybe we should raise a PR to add this to the main Ozone repo and then update the docs.

Copy link
Author

Choose a reason for hiding this comment

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

That's a good point we should take advantage of the enforcer plugin to have reproducible builds.

However, what should be considered the minimum version for Maven and Git? We depend on Hadoop and I can see if they have a minimum version specified for Maven.

On that note, it is also not clear what the minimum version of Java should be. We do build with versions 8, 11, 17. Some of the pom files specify the compiler source and target versions to Java 8. Some of the tests fail when run from the IDE with a newer JDK and need extra JVM parameters to allow Java lang and util modules and the security manager.

docs/08-developer-guide/01-build/02-maven.md Outdated Show resolved Hide resolved
docs/08-developer-guide/01-build/02-maven.md Outdated Show resolved Hide resolved
docs/08-developer-guide/01-build/02-maven.md Outdated Show resolved Hide resolved
docs/08-developer-guide/01-build/02-maven.md Outdated Show resolved Hide resolved
docs/08-developer-guide/01-build/02-maven.md Outdated Show resolved Hide resolved
- `-Pdist`: Enable the distribution profile to create deployment tarballs
- `-Pnative`: Build native libraries (requires additional system dependencies)
- `-T 4`: Use 4 threads for parallel building (adjust number based on your CPU)
- `-am -pl module-name`: Build a specific module and its dependencies
Copy link
Contributor

@errose28 errose28 Nov 5, 2024

Choose a reason for hiding this comment

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

I think this needs mvn install run previously to work correctly, otherwise it will try to download the dependencies and for source builds from an arbitrary commit this will not be present. The previous build commands here have only mentioned mvn package.

Copy link
Author

Choose a reason for hiding this comment

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

I update the package commands to install.

Copy link
Contributor

@adoroszlai adoroszlai Dec 12, 2024

Choose a reason for hiding this comment

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

-am is short for --also-make. It builds all modules that are required for the specified module(s). E.g. -am -pl :hdds-server-scm will build hdds-common, hdds-server-framework, etc.

Prior install is required only if you omit -am.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok we need to add some more details to get this to work properly:

  • The command must be run from the root of the repository.
    • Running it from within a module without -pl or passing it a module that exists in your current working directory fails.
    • Maybe this is common sense for more seasoned maven users but it is generally unintuitive behavior.
  • The module name must be preceded with a module specifier :

Putting this together, mvn package -am -pl :hdds-server-scm gives the expected behavior when run from the repository root.

docs/08-developer-guide/01-build/02-maven.md Outdated Show resolved Hide resolved
docs/08-developer-guide/01-build/02-maven.md Outdated Show resolved Hide resolved
@ptlrs ptlrs requested a review from errose28 November 14, 2024 17:53
@ptlrs ptlrs marked this pull request as ready for review November 14, 2024 17:53
@errose28
Copy link
Contributor

See also some updates to the way we skip Recon frontend build in apache/ozone#7454

Co-authored-by: Siyao Meng <50227127+smengcl@users.noreply.github.com>
| `-T 4` | Use 4 threads for parallel building (adjust number based on your CPU) |
| `-T 2C` | Use 2 threads per core for parallel building (adjust number based on your CPU) |
| `-am -pl module-name` | Build a specific module and its dependencies |
| `-DskipShade` | Skip shading. This saves a ton of time by e.g. skipping the ozone-filesystem-hadoop3 fat jar build |
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| `-DskipShade` | Skip shading. This saves a ton of time by e.g. skipping the ozone-filesystem-hadoop3 fat jar build |
| `-DskipShade` | Skip shading. This saves a ton of time by e.g. skipping the ozone-filesystem-hadoop3 fat jar build |
| `-DskipRecon` | Skip Recon frontend build. This saves a ton of time by e.g. skipping the Recon frontend npm build |

Copy link
Contributor

Choose a reason for hiding this comment

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

e.g. usually means there are more examples. Is skipShade skipping anything else other than the fat jar? We should probably also specify that jar is only used on the client side.

Copy link
Contributor

@errose28 errose28 left a comment

Choose a reason for hiding this comment

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

Thanks for the updates @ptlrs. I left a few more comments but overall flow and content looks pretty good.

Comment on lines +44 to +46
Use this option if you only want the released version of Ozone.
<br/>Obtain the Ozone sources from the [download](/download) page.
<br/>Next, unpack the tarball
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Use this option if you only want the released version of Ozone.
<br/>Obtain the Ozone sources from the [download](/download) page.
<br/>Next, unpack the tarball
Use this option if you only want a released version of Ozone. Source code for Ozone releases can be obtained from the [download page](/download).

Just a little more concise and IMO reads smoother without the line breaks.


## Build the Project

Apache Ozone uses Maven as its build system. The build process compiles the source code, runs tests, and creates deployable artifacts. The project supports various build configurations to accommodate different development and deployment needs.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Apache Ozone uses Maven as its build system. The build process compiles the source code, runs tests, and creates deployable artifacts. The project supports various build configurations to accommodate different development and deployment needs.
Apache Ozone uses [Maven](https://maven.apache.org/) as its build system. The build process compiles the source code, runs tests, and creates deployable artifacts. The project supports various build configurations to accommodate different development and deployment needs.

For a basic build that skips tests:

```bash
mvn clean install -DskipTests=true
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can change these commands back to package per this discussion

| `-T 4` | Use 4 threads for parallel building (adjust number based on your CPU) |
| `-T 2C` | Use 2 threads per core for parallel building (adjust number based on your CPU) |
| `-am -pl module-name` | Build a specific module and its dependencies |
| `-DskipShade` | Skip shading. This saves a ton of time by e.g. skipping the ozone-filesystem-hadoop3 fat jar build |
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| `-DskipShade` | Skip shading. This saves a ton of time by e.g. skipping the ozone-filesystem-hadoop3 fat jar build |
| `-DskipShade` | Skip shading. This saves a ton of time by e.g. skipping the `ozone-filesystem-hadoop3` fat jar build |

In addition to helping readability this tells the markdownlint CI check it is ok for Ozone to be lowercase in this context.

| `-T 2C` | Use 2 threads per core for parallel building (adjust number based on your CPU) |
| `-am -pl module-name` | Build a specific module and its dependencies |
| `-DskipShade` | Skip shading. This saves a ton of time by e.g. skipping the ozone-filesystem-hadoop3 fat jar build |
| `-Dmaven.artifact.threads=30` | Allow maven to download 30 artifacts at once. The default value is 5. This could speed up the build process by a lot when the maven cache was not previously populated. |
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| `-Dmaven.artifact.threads=30` | Allow maven to download 30 artifacts at once. The default value is 5. This could speed up the build process by a lot when the maven cache was not previously populated. |
| `-Dmaven.artifact.threads=30` | Allow Maven to download 30 artifacts at once. The default value is 5. This could speed up the build process by a lot when the Maven cache was not previously populated. |

CI correctly flagged the inconsistent capitalization of maven here.

Comment on lines +95 to +99
#### Maven Build Options

Several Maven options are available to customize the build process:

Here's the conversion to a markdown table:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#### Maven Build Options
Several Maven options are available to customize the build process:
Here's the conversion to a markdown table:
#### Common Maven Build Options

IMO the title explains it all. This is getting published as a website and all traces of markdown will be erased.

| Command | Description |
|---------|-------------|
| `-DskipTests=true` | Skip all tests |
| `-Dskip.installnpm -Dskip.installnpx -Dskip.installyarn -Dskip.npm -Dskip.npx -Dskip.yarn` | Skip building the Javascript frontend for Recon |
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove this and just use the -DskipRecon option.

| `-Pdist` | Enable the distribution profile to create deployment tarballs |
| `-T 4` | Use 4 threads for parallel building (adjust number based on your CPU) |
| `-T 2C` | Use 2 threads per core for parallel building (adjust number based on your CPU) |
| `-am -pl module-name` | Build a specific module and its dependencies |
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| `-am -pl module-name` | Build a specific module and its dependencies |
| `-am -pl :<module-name>` | Build a specific module and its dependencies when run from the root of the project |

| `-T 4` | Use 4 threads for parallel building (adjust number based on your CPU) |
| `-T 2C` | Use 2 threads per core for parallel building (adjust number based on your CPU) |
| `-am -pl module-name` | Build a specific module and its dependencies |
| `-DskipShade` | Skip shading. This saves a ton of time by e.g. skipping the ozone-filesystem-hadoop3 fat jar build |
Copy link
Contributor

Choose a reason for hiding this comment

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

e.g. usually means there are more examples. Is skipShade skipping anything else other than the fat jar? We should probably also specify that jar is only used on the client side.

Comment on lines +115 to +125
You can test the result of the compilation process by running a simple Ozone command which will display the Ozone version

```bash
./hadoop-ozone/dist/target/ozone-<version>-SNAPSHOT/bin/ozone version
```

The build process creates several important artifacts:

- **Distribution Tarball**: `hadoop-ozone/dist/target/ozone-<version>.tar.gz` (when using `-Pdist`)
- **Distribution Directory**: `hadoop-ozone/dist/target/ozone-<version>/`
- **Individual Module JARs**: `hadoop-ozone/dist/target/ozone-<version>-SNAPSHOT/share/ozone/lib`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
You can test the result of the compilation process by running a simple Ozone command which will display the Ozone version
```bash
./hadoop-ozone/dist/target/ozone-<version>-SNAPSHOT/bin/ozone version
```
The build process creates several important artifacts:
- **Distribution Tarball**: `hadoop-ozone/dist/target/ozone-<version>.tar.gz` (when using `-Pdist`)
- **Distribution Directory**: `hadoop-ozone/dist/target/ozone-<version>/`
- **Individual Module JARs**: `hadoop-ozone/dist/target/ozone-<version>-SNAPSHOT/share/ozone/lib`
The build process creates several important artifacts:
- **Distribution Tarball**: `hadoop-ozone/dist/target/ozone-<version>.tar.gz` (when using `-Pdist`)
- **Distribution Directory**: `hadoop-ozone/dist/target/ozone-<version>/`
- **Individual Module JARs**: `hadoop-ozone/dist/target/ozone-<version>/share/ozone/lib`
You can test the result of the compilation process by running a simple Ozone command which will display the Ozone version:
```bash
hadoop-ozone/dist/target/ozone-<version>/bin/ozone version

I think this order of presentation makes more sense.

  • I removed SNAPSHOT, we can leave that as part of <version>. Not every build will be a snapshot build.
  • ./ is not technically required here since we are already providing a relative path to the executable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Changes updating documentation on the website website-v2 Tasks for the new ozone website targeting the HDDS-9225-website-v2 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants