Skip to content

Java libraries migration guide#3506

Merged
s-stumbo merged 19 commits into
mainfrom
java-migration-guide
Jul 13, 2026
Merged

Java libraries migration guide#3506
s-stumbo merged 19 commits into
mainfrom
java-migration-guide

Conversation

@s-stumbo

@s-stumbo s-stumbo commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

[ ] Check if this is a typo or other quick fix and ignore the rest :)

Type of change

New guide on migrating to Java libraries

What should this PR do?

Explain how to migrate an existing Java project to use Chainguard libraries

Why are we making this change?

Reduce friction in onboarding

What are the acceptance criteria?

The instructions should be accurate and clear

How should this PR be tested?

Any documentation published to Chainguard Academy is reviewed carefully for accuracy. GUI procedures, API commands, and CLI code snippets in a draft are run and tested thoroughly — by both the author and the reviewer — to confirm they work exactly as written. This helps ensure that readers can follow along and get the same results. See the edu repo's README.

Create a basic Java app with some dependencies, then follow the migration guide to switch the libraries to Chainguard.

Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
@s-stumbo
s-stumbo requested a review from a team July 2, 2026 18:41
@netlify

netlify Bot commented Jul 2, 2026

Copy link
Copy Markdown

Deploy Preview for ornate-narwhal-088216 ready!

Name Link
🔨 Latest commit a0c3732
🔍 Latest deploy log https://app.netlify.com/projects/ornate-narwhal-088216/deploys/6a550446dd63cb00085a07fc
😎 Deploy Preview https://deploy-preview-3506--ornate-narwhal-088216.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread content/chainguard/libraries/java/migration.md Outdated
Comment thread content/chainguard/libraries/java/migration.md Outdated
Comment thread content/chainguard/libraries/java/migration.md Outdated
Comment thread content/chainguard/libraries/java/migration.md
Comment thread content/chainguard/libraries/java/migration.md
Comment thread content/chainguard/libraries/java/migration.md
Comment thread content/chainguard/libraries/java/migration.md
Comment thread content/chainguard/libraries/java/migration.md Outdated
Comment thread content/chainguard/libraries/java/migration.md Outdated

```bash
rm ~/.m2/repository/commons-io/commons-io/2.13.0/commons-io-2.13.0.jar
mvn dependency:resolve

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That resolves a project's dependencies. If you want to resolve the specific JAR you need to use dependency:get or some other tool.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In this case mvn dependency:get -Dartifact=commons-io:commons-io:2.13.0 but it might be best to find an example that is newer so artifactId and groupId are not that same.. thats a very old antipattern that is no longer allowed for new artifacts.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I updated this section to use dependency:get

Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>

@SharpRake SharpRake left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some minor fixes from me, it's overall looking good!

Comment thread content/chainguard/libraries/java/migration.md Outdated
Comment thread content/chainguard/libraries/java/migration.md Outdated
Comment thread content/chainguard/libraries/java/migration.md Outdated
Comment thread content/chainguard/libraries/java/migration.md Outdated
Comment thread content/chainguard/libraries/java/migration.md Outdated
Comment thread content/chainguard/libraries/java/migration.md
Comment thread content/chainguard/libraries/java/migration.md Outdated
Comment thread content/chainguard/libraries/java/migration.md Outdated
Comment thread content/chainguard/libraries/java/migration.md
Comment thread content/chainguard/libraries/java/migration.md
Comment thread content/chainguard/libraries/java/migration.md Outdated
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
@s-stumbo
s-stumbo requested a review from a team as a code owner July 8, 2026 19:36
s-stumbo and others added 2 commits July 10, 2026 13:24
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
@s-stumbo
s-stumbo requested review from SharpRake and mosabua July 10, 2026 17:35

```shell
cd your-project
mvn install

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since you use the Gradle wrapper.. also use the maven wrapper in the examples

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or change Gradle since bazel is directly invoked as well..

Comment thread content/chainguard/libraries/java/migration.md
Comment thread content/chainguard/libraries/java/migration.md Outdated
s-stumbo and others added 5 commits July 10, 2026 14:09
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>

{{% tab title="Maven" %}}

Maven repository configuration is split across two files: repository URLs go in your project's `pom.xml`, and credentials go in `~/.m2/settings.xml`. The `server` IDs in `settings.xml` must match the `repository` IDs in `pom.xml` — Maven pairs them automatically by ID when resolving credentials.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry.. not sure how you came to that. Adding the repos to the pom is a known bad pattern. It should all stay in the settings file. The only thing is if you want to use it only locally in a project, the convention is to have it located in the .mvn folder in the project and use -s in all calls. See https://github.com/chainguard-demo/chainguard-libraries-java/tree/main/cve-2024-38819


<servers>
<server>
<id>repo-manager</id>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this must be nexus .. see comment earlier

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I updated the paragraph before the config. It now links to the GitHub examples for repo manager settings and says to use environment variables for credentials when possible

Then verify using the full path. For example:

```bash
chainctl libraries verify ~/Library/Caches/bazel/_bazel_example/c22a55500fa8462e9bf6b663d5366abd/external/rules_jvm_external++maven+maven/v1/https/45a0c61ea6fd977f050c5fb9ac06a69eed764595/1f4231148aeda823%40libraries.cgr.dev/java/com/fasterxml/jackson/core/jackson-databind/2.9.10/jackson-databind-2.9.10.jar

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would shorten this command

s-stumbo and others added 6 commits July 13, 2026 09:20
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
s-stumbo added 3 commits July 13, 2026 11:06
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>

@mosabua mosabua left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lgtm now. Ship it when you are ready.

@mosabua mosabua left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ship it.

@s-stumbo
s-stumbo merged commit bda70c3 into main Jul 13, 2026
14 checks passed
@s-stumbo
s-stumbo deleted the java-migration-guide branch July 13, 2026 17:39
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