Skip to content

Commit

Permalink
Use common repo instead of local repo
Browse files Browse the repository at this point in the history
  • Loading branch information
DSouzaM committed Mar 4, 2025
1 parent 6a250b4 commit d7102c6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 22 deletions.
61 changes: 43 additions & 18 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ For the Maven plugin, simply use the `mvnDebug` command in place of the `mvn` co
## Testing Local Changes with an Existing Project
A common development task is to modify a plugin and then test it with an existing project.

To do this, first modify the project as necessary, and then build and publish the plugins to the local Maven repository:
To do this, first modify the project as necessary, and then build and publish the plugins:
```bash
./gradlew publishToMavenLocal --no-parallel
./gradlew publishAllPublicationsToCommonRepository --no-parallel
```
The above command publishes to a "common" repository located at `build/common-repo`.

Next, update the plugin version string in the project build files.
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).
Next, update the project build files:
1. Update the version string. 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).
2. Update the list of repositories to include and prioritize the common repo.

For Gradle, the change looks like the following.
You may also need to direct Gradle to use the local Maven repository to resolve the plugin:
### Gradle
Make the following changes to the build files:
```bash
# build.gradle
plugins {
Expand All @@ -64,25 +66,48 @@ You may also need to direct Gradle to use the local Maven repository to resolve
+ id 'org.graalvm.buildtools.native' version '0.10.5-SNAPSHOT'
}

repositories {
+ mavenLocal()
repositories {
+ maven {
+ name = "common"
+ url = "$NATIVE_BUILD_TOOLS_ROOT/build/common-repo"
+ }
...
}

# settings.gradle
pluginManagement {
repositories {
+ mavenLocal()
...
}
}
pluginManagement {
repositories {
+ maven {
+ name = "common"
+ url = "$NATIVE_BUILD_TOOLS_ROOT/build/common-repo"
+ }
# NB: If repositories were not specified before, declaring the common
# repo will overwrite the default repository; you may also need to
# declare that repository explicitly.
mavenCentral()
...
}
}
```
Then, run the Gradle command as usual.
For Maven, simply bump the version and it should try the local repository automatically:
### Maven
Make the following changes to pom.xml:
```bash
# pom.xml
- <native.maven.plugin.version>0.9.25</native.maven.plugin.version>
+ <native.maven.plugin.version>0.10.5-SNAPSHOT</native.maven.plugin.version>
<project ...>
<properties>
- <native.maven.plugin.version>0.9.25</native.maven.plugin.version>
+ <native.maven.plugin.version>0.10.5-SNAPSHOT</native.maven.plugin.version>
</properties>
...
+ <pluginRepositories>
+ <pluginRepository>
+ <id>common</id>
+ <url>file://$NATIVE_BUILD_TOOLS_ROOT/build/common-repo</url>
+ </pluginRepository>
+ </pluginRepositories>
</project>
```
Then, run your build as usual. Gradle/Maven should find the plugin in the local repository and use it for the build.
Then, run the Maven command with the `-U` flag to force Maven to use an updated snapshot (e.g., `mvn -Pnative package -U`).
4 changes: 2 additions & 2 deletions native-gradle-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ End-user documentation about the plugins can be found [here](https://graalvm.git
This plugin can be built with this command (from the root directory):

```bash
./gradlew :native-gradle-plugin:publishToMavenLocal --no-parallel
./gradlew :native-gradle-plugin:publishAllPublicationsToCommonRepository --no-parallel
```

For more details, see the [Developer documentation](../DEVELOPING.md).
A snapshot will be published to `build/common-repo`. For more details, see the [Developer documentation](../DEVELOPING.md).

In order to run testing part of this plugin you need to get (or build) corresponding `junit-platform-native` artifact.

Expand Down
4 changes: 2 additions & 2 deletions native-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ End-user documentation about the plugins can be found [here](https://graalvm.git
This plugin can be built with this command (from the root directory):

```bash
./gradlew :native-maven-plugin:publishToMavenLocal --no-parallel
./gradlew :native-maven-plugin:publishAllPublicationsToCommonRepository --no-parallel
```

For more details, see the [Developer documentation](../DEVELOPING.md).
A snapshot will be published to `build/common-repo`. For more details, see the [Developer documentation](../DEVELOPING.md).

*You can also take a look at CI workflow [here](../.github/workflows/test-native-maven-plugin.yml).*
6 changes: 6 additions & 0 deletions samples/java-application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,11 @@
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>common</id>
<url>file:///Users/matt/code3/native-build-tools/build/common-repo</url>
</pluginRepository>
</pluginRepositories>

</project>
5 changes: 5 additions & 0 deletions samples/java-application/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ pluginManagement {
plugins {
id 'org.graalvm.buildtools.native' version getProperty('native.gradle.plugin.version')
}
repositories {
flatDir {
dirs "/Users/matt/code3/native-build-tools/build/common-repo"
}
}
}

rootProject.name = 'java-application'

0 comments on commit d7102c6

Please sign in to comment.