Quarkus - JGit

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

Configuration

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

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

This will add the following to your pom.xml:

    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-jgit</artifactId>
    </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:

    @GET
    @Path("/clone")
    @Produces(MediaType.TEXT_PLAIN)
    public String cloneRepository(@QueryParam("url") String url) throws Exception {
        File tmpDir = Files.createTempDirectory("tmpgit").toFile();
        try (Git git = Git.cloneRepository().setDirectory(tmpDir).setURI(url).call()) {
            return tmpDir.toString();
        }
    }

When running in native mode, make sure that the SSL access is configured correctly.

quarkus.pro 是基于 quarkus.io 的非官方中文翻译站 ,最后更新 2020/04 。
沪ICP备19006215号-8
QQ交流群:1055930959
微信群: