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

Add developer documentation #678

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DSouzaM
Copy link
Member

@DSouzaM DSouzaM commented Jan 15, 2025

While debugging a NI agent issue I found myself needing to modify and debug the Gradle plugin. This change adds some developer documentation to explain setup and some common workflows (at least, the ones I needed).

Tracked internally as GR-61396.

I also tried to incorporate the suggestions in #656 w.r.t. environment setup.

Copy link

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Jan 15, 2025
@oracle-contributor-agreement oracle-contributor-agreement bot added OCA Verified All contributors have signed the Oracle Contributor Agreement. and removed OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. labels Jan 15, 2025
```shell
./gradlew publishAllPublicationsToCommonRepository
```bash
./gradlew :native-maven-plugin:publishToMavenLocal --no-parallel
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you tried this command if it works?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes it will work. Although personally I'd avoid polluting maven local and stick with the "common repository" (I usually add a local repository to Gradle/Maven builds to avoid the erratic behavior of maven local).


```bash
./gradlew publishToMavenLocal --no-parallel
./gradlew :native-gradle-plugin:publishToMavenLocal --no-parallel
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you tried this command if it works?

# build.gradle
plugins {
...
- id 'org.graalvm.buildtools.native' version '0.9.25'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need both this and SNAPSHOT?

For Maven, simply bump the version and it should try the local repository automatically:
```bash
# pom.xml
- <native.maven.plugin.version>0.9.25</native.maven.plugin.version>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above, why do we need this and SNAPSHOT?

+ <native.maven.plugin.version>0.10.5-SNAPSHOT</native.maven.plugin.version>
```

Then, run your build as usual. Gradle should find the plugin in the local repository and use it for the build.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess not only Gradle but Maven would find it as well. So maybe Gradle/Maven should find...

The native-build-tools repo is set up as a multi-project Gradle project, with the Maven and Gradle plugins declared as subprojects of the root project.
To set the project up in your IDE (e.g., IntelliJ IDEA), import the root project and the IDE should automatically import the subprojects.

## Building & testing
Copy link
Collaborator

Choose a reason for hiding this comment

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

@melix can you please verify this section, because I didn't use these commands in the past?

@dnestoro
Copy link
Collaborator

Hey @DSouzaM, thanks for this PR. It will be really helpful. I just left some minor suggestions/questions, but in general, the PR looks good!

@dnestoro dnestoro requested review from olyagpl and melix February 13, 2025 10:11
@@ -0,0 +1,91 @@
# Documentation for Developers

This document describes how to set up and develop native-build-tools on your local machine.
Copy link
Member

Choose a reason for hiding this comment

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

native-build-tools -> Native Build Tools


Some build tasks require a GraalVM JDK (e.g., tests). You should set `GRAALVM_HOME` to an appropriate GraalVM JDK.

## IDE setup
Copy link
Member

Choose a reason for hiding this comment

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

## IDE Setup


## IDE setup

The native-build-tools repo is set up as a multi-project Gradle project, with the Maven and Gradle plugins declared as subprojects of the root project.
Copy link
Member

Choose a reason for hiding this comment

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

The native-build-tools repo ... -> The Native Build Tools repo

The native-build-tools repo is set up as a multi-project Gradle project, with the Maven and Gradle plugins declared as subprojects of the root project.
To set the project up in your IDE (e.g., IntelliJ IDEA), import the root project and the IDE should automatically import the subprojects.

## Building & testing
Copy link
Member

Choose a reason for hiding this comment

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

Building and Testing

```


## Debugging plugin(s)
Copy link
Member

Choose a reason for hiding this comment

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

Debugging Plugin(s)


For the Maven plugin, simply use the `mvnDebug` command in place of the `mvn` command.

## Testing local changes with an existing project
Copy link
Member

Choose a reason for hiding this comment

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

Testing Local Changes with an Existing Project

```

Then, run your build as usual. Gradle should find the plugin in the local repository and use it for the build.

Copy link
Member

Choose a reason for hiding this comment

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

Three empty lines at the end of the file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants