Skip to content

Commit ed3948c

Browse files
committed
Add developer documentation
1 parent 0d77824 commit ed3948c

File tree

4 files changed

+103
-5
lines changed

4 files changed

+103
-5
lines changed

DEVELOPING.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Documentation for Developers
2+
3+
This document describes how to set up and develop native-build-tools on your local machine.
4+
5+
## Environment
6+
7+
The project uses Gradle as its build system. At the very minimum, you should set `JAVA_HOME` to a [Gradle-compatible JDK](https://docs.gradle.org/current/userguide/compatibility.html).
8+
9+
Some build tasks require a GraalVM JDK (e.g., tests). You should set `GRAALVM_HOME` to an appropriate GraalVM JDK.
10+
11+
## IDE setup
12+
13+
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.
14+
To set the project up in your IDE (e.g., IntelliJ IDEA), import the root project and the IDE should automatically import the subprojects.
15+
16+
## Building & testing
17+
18+
You can use the various commands in the [Gradle build lifecycle](https://docs.gradle.org/current/userguide/build_lifecycle.html) to build and test the project.
19+
Some examples (all executed from the root of the repository):
20+
21+
```bash
22+
# Build all projects
23+
./gradlew assemble
24+
25+
# Build only the native-gradle-plugin (for example)
26+
./gradlew :native-gradle-plugin:assemble
27+
28+
# Build and run all tests
29+
./gradlew build
30+
```
31+
32+
33+
## Debugging plugin(s)
34+
It is often useful to attach a debugger to the Gradle and Maven plugins during a project build.
35+
36+
For the Gradle plugin, this can be accomplished by passing debugger options to the Gradle daemon via `org.gradle.jvmargs`, for example:
37+
38+
```bash
39+
JAVA_OPTS="-Dorg.gradle.jvmargs=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000" ./gradlew assemble
40+
```
41+
42+
The Gradle daemon will suspend on start-up, wait for you to attach a debugger, and then remain attached for subsequent Gradle commands.
43+
44+
For the Maven plugin, simply use the `mvnDebug` command in place of the `mvn` command.
45+
46+
## Testing local changes with an existing project
47+
A common development task is to modify a plugin and then test it with an existing project.
48+
49+
To do this, first modify the project as necessary, and then build and publish the plugins to the local Maven repository:
50+
```bash
51+
./gradlew publishToMavenLocal --no-parallel
52+
```
53+
54+
Next, update the plugin version string in the project build files.
55+
The version can be found manually by searching for the published artifacts in `~/.m2/repository/org/graalvm/buildtools/native/`, or alternatively by checking the `nativeBuildTools` property [here](gradle/libs.versions.toml).
56+
57+
For Gradle, the change looks like the following.
58+
You may also need to direct Gradle to use the local Maven repository to resolve the plugin:
59+
```bash
60+
# build.gradle
61+
plugins {
62+
...
63+
- id 'org.graalvm.buildtools.native' version '0.9.25'
64+
+ id 'org.graalvm.buildtools.native' version '0.10.5-SNAPSHOT'
65+
}
66+
67+
repositories {
68+
+ mavenLocal()
69+
...
70+
}
71+
72+
# settings.gradle
73+
pluginManagement {
74+
repositories {
75+
+ mavenLocal()
76+
...
77+
}
78+
}
79+
```
80+
81+
For Maven, simply bump the version and it should try the local repository automatically:
82+
```bash
83+
# pom.xml
84+
- <native.maven.plugin.version>0.9.25</native.maven.plugin.version>
85+
+ <native.maven.plugin.version>0.10.5-SNAPSHOT</native.maven.plugin.version>
86+
```
87+
88+
Then, run your build as usual. Gradle should find the plugin in the local repository and use it for the build.
89+
90+
91+

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Repository which contains build tool plugins for interoperability with [GraalVM
77
End-user documentation about the plugins can be found [here](https://graalvm.github.io/native-build-tools/).
88

99
## Contributing
10+
11+
Documentation for common developer tasks can be found [here](DEVELOPING.md).
12+
1013
### Projects
1114
* [native-maven-plugin](native-maven-plugin/README.md)
1215
* [native-gradle-plugin](native-gradle-plugin/README.md)

native-gradle-plugin/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ End-user documentation about the plugins can be found [here](https://graalvm.git
66

77
## Building
88

9-
This plugin can be built with this command:
9+
This plugin can be built with this command (from the root directory):
1010

1111
```bash
12-
./gradlew publishToMavenLocal --no-parallel
12+
./gradlew :native-gradle-plugin:publishToMavenLocal --no-parallel
1313
```
1414

15+
For more details, see the [Developer documentation](../DEVELOPING.md).
16+
1517
In order to run testing part of this plugin you need to get (or build) corresponding `junit-platform-native` artifact.
1618

1719
*You can also take a look at CI workflow [here](../.github/workflows/test-native-gradle-plugin.yml).*

native-maven-plugin/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ End-user documentation about the plugins can be found [here](https://graalvm.git
66

77
## Building
88

9-
This plugin follows standard Maven plugin conventions and can be built with this command:
9+
This plugin can be built with this command (from the root directory):
1010

11-
```shell
12-
./gradlew publishAllPublicationsToCommonRepository
11+
```bash
12+
./gradlew :native-maven-plugin:publishToMavenLocal --no-parallel
1313
```
1414

15+
For more details, see the [Developer documentation](../DEVELOPING.md).
16+
1517
*You can also take a look at CI workflow [here](../.github/workflows/test-native-maven-plugin.yml).*

0 commit comments

Comments
 (0)