Quarkus - JGit

Quarkus includes the jgit extension which enables the use of Eclipse JGitin native mode.

Configuration

Once you have your Quarkus project configured you can add the jgit extensionto your project by running the following command in your project base directory.

  1. ./mvnw quarkus:add-extension -Dextensions="jgit"

This will add the following to your pom.xml:

  1. <dependency>
  2. <groupId>io.quarkus</groupId>
  3. <artifactId>quarkus-jgit</artifactId>
  4. </dependency>

Usage

The JGit dependency is resolved transitively when the extension is added to your project.Here is an example using it in a JAX-RS endpoint:

  1. @GET
  2. @Path("/clone")
  3. @Produces(MediaType.TEXT_PLAIN)
  4. public String cloneRepository(@QueryParam("url") String url) throws Exception {
  5. File tmpDir = Files.createTempDirectory("tmpgit").toFile();
  6. try (Git git = Git.cloneRepository().setDirectory(tmpDir).setURI(url).call()) {
  7. return tmpDir.toString();
  8. }
  9. }
When running in native mode, make sure that the SSL access is configured correctly.