Skip to content

Add minimal example project for Gradle Java libraries#3155

Open
s-stumbo wants to merge 7 commits intomainfrom
gradle-example
Open

Add minimal example project for Gradle Java libraries#3155
s-stumbo wants to merge 7 commits intomainfrom
gradle-example

Conversation

@s-stumbo
Copy link
Copy Markdown
Contributor

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

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

Type of change

Adding minimal example project for Java libraries with Gradle

What should this PR do?

  • Add minimal example project
  • Update existing env vars example to use Gradle's recommended format

Why are we making this change?

For consistency across libraries docs, we're adding minimal example projects

What are the acceptance criteria?

Content should be clear and accurate

How should this PR be tested?

Follow the steps to create the example

s-stumbo added 2 commits April 2, 2026 15:08
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
@s-stumbo s-stumbo requested a review from a team as a code owner April 2, 2026 19:19
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 2, 2026

Deploy Preview for ornate-narwhal-088216 ready!

Name Link
🔨 Latest commit d50b04c
🔍 Latest deploy log https://app.netlify.com/projects/ornate-narwhal-088216/deploys/69d3f24a41d3ee00081805e3
😎 Deploy Preview https://deploy-preview-3155--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.

@mosabua mosabua requested a review from britter April 2, 2026 19:25

```bash
./gradlew app:assemble
find ~/.gradle/caches/modules-2/files-2.1/com.google.guava -name "*.jar" | sort
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.

What is that supposed to do? Also .. add chainctl libraries verify ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had trouble with this one trying to find the file. I just updated this part to separate the build command and then explain what I'm doing with find in the second command. If there's a better way, we can change this

s-stumbo added 5 commits April 3, 2026 08:25
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>
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
@s-stumbo s-stumbo requested a review from mosabua April 6, 2026 18:04
Copy link
Copy Markdown
Member

@mosabua mosabua left a comment

Choose a reason for hiding this comment

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

Seems good overall. Somebody should test this to confirm. I wont be able to get around to that

}
}
```
>Note: Do not store credentials directly in build files; use environment
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.

Not sure if this renders correctly without space between > and Note:

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.

FWIW, this does render correctly in the preview but for precision's sake I'd just add a space.

Also, I prefer to bold the "Note:" so it pops a bit

Copy link
Copy Markdown
Collaborator

@SharpRake SharpRake left a comment

Choose a reason for hiding this comment

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

I had a few thoughts mostly around presentation. Approving so as not to block you, but let me know if you have any questions.

EDIT: BTW, I tested the instructions out and they worked beautifully! 🎉

}
}
```
>Note: Do not store credentials directly in build files; use environment
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.

FWIW, this does render correctly in the preview but for precision's sake I'd just add a space.

Also, I prefer to bold the "Note:" so it pops a bit

users home directory. Use the following command to delete it:
Java you must delete that local cache so that libraries
are downloaded again. By default the cache is located in a hidden
`~/.gradle/caches` directory in your users home directory.
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.

Suggested change
`~/.gradle/caches` directory in your users home directory.
`~/.gradle/caches` directory in your user's home directory.

repository group or virtual repository from your repository manager
`https://repo.example.com/group/` and any applicable authentication details.

Open `app/build.gradle` and update the `repositories` block to include the following repository. Ensure it is located above the `mavenCentral` repository and any
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.

ngl, i don't believe in an 80 char limit for docs because i find it hard to maintain consistently, and here's an example of why. You have one very long line followed by a short one

Use the following steps to create a minimal example project for Gradle with Chainguard Libraries for Java. For testing purposes, you can use direct access and environment variables as
detailed in the [access documentation](/chainguard/libraries/access/#use-environment-variables-for-pull-token-credentials).

**Step 1: Clear the cache**
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.

I'm not crazy about having two 'Step 1s' under the same H2. Like, if this is it's own set of steps it should be a separate doc or something


**Step 2: Create the example project**

Run the following command:
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.

Suggested change
Run the following command:
First, create a project directory and navigate into it:

Run the following command:

```bash
mkdir gradle-example
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.

Suggested change
mkdir gradle-example
mkdir gradle-example && cd $_
```


```bash
mkdir gradle-example
cd gradle-example
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.

Suggested change
cd gradle-example
Next, initialize an example project:
```
cd gradle-example

not sure the instruction is right, but def add some more context here


Edit the `repositories` block in `app/build.gradle` to point to Chainguard and use the environment variables for your pull token credentials:

```groovy
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.

I think since we're editing a file that we know exists we should give more indication that that's what we're doing. Like, I would give the command to open the file for editing (nano app/build.gradle) and label the code block with the file name:

Suggested change
```groovy
```app/build.gradle

version catalog in `gradle/libs.versions.toml`, so guava is downloaded from
Chainguard Libraries as part of the build.

Following the build, find the guava jar declared in the version catalog at:
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.

We don't uses this guava jar, right? if not I think we should just say "you can" since it isn't necessary to continue:

Suggested change
Following the build, find the guava jar declared in the version catalog at:
Following the build, you can find the guava jar declared in the version catalog at `~/.gradle/caches/modules-2/files-2.1/com.google.guava`.

Comment on lines +618 to +620
```bash
~/.gradle/caches/modules-2/files-2.1/com.google.guava
```
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.

Suggested change
```bash
~/.gradle/caches/modules-2/files-2.1/com.google.guava
```

This isn't a command, so it definitely shouldn't have a bash/shell label on the code block. Unless I'm misunderstanding, it seems clearer to just leave it in the paragraph above.

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.

3 participants