Skip to content

Commit edd762c

Browse files
committed
use JGit 7.2.0 and Jetty 12 versions
1 parent 835eda1 commit edd762c

File tree

9 files changed

+68
-54
lines changed

9 files changed

+68
-54
lines changed

.github/workflows/gradle-build.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,17 @@ jobs:
1919

2020
steps:
2121
- name: Git checkout
22-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
2323

2424
- name: Verify Gradle Wrapper
25-
uses: gradle/wrapper-validation-action@v1
26-
27-
- name: Cache Gradle packages
28-
uses: actions/cache@v3
29-
with:
30-
path: ~/.gradle/caches
31-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
32-
restore-keys: ${{ runner.os }}-gradle-
25+
uses: gradle/actions/wrapper-validation@v3
3326

3427
- name: Set up GraalVM ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }}
3528
uses: graalvm/setup-graalvm@v1
3629
with:
3730
java-version: ${{ matrix.java-version }}
3831
distribution: ${{ matrix.graalvm-distribution }}
32+
cache: 'gradle'
3933

4034
- name: Report Java version
4135
run: |

.github/workflows/maven-build.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ jobs:
1919

2020
steps:
2121
- name: Git checkout
22-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
2323

2424
- name: Set up GraalVM ${{ matrix.graalvm-distribution }} for Java ${{ matrix.java-version }}
2525
uses: graalvm/setup-graalvm@v1
2626
with:
2727
java-version: ${{ matrix.java-version }}
2828
distribution: ${{ matrix.graalvm-distribution }}
29+
cache: 'maven'
2930

3031
- name: Report Java version
3132
run: |
@@ -42,14 +43,14 @@ jobs:
4243

4344
- name: Package Linux artifact
4445
if: runner.os == 'Linux'
45-
uses: actions/upload-artifact@v3
46+
uses: actions/upload-artifact@v4
4647
with:
4748
name: JGitHttpServer ${{ runner.os }} native image with SubstrateVM for Java ${{ matrix.java-version }}
4849
path: target/JGitHttpServer
4950

5051
- name: Package Windows artifacts
5152
if: runner.os == 'Windows'
52-
uses: actions/upload-artifact@v3
53+
uses: actions/upload-artifact@v4
5354
with:
5455
name: JGitHttpServer ${{ runner.os }} native image with SubstrateVM for Java ${{ matrix.java-version }}
5556
path: target/JGitHttpServer.exe

README.md

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# JGit HTTP Server + GraalVM native image
22

3+
[![Github Actions Build Status](https://github.com/chirontt/jgit.http.server.native/actions/workflows/gradle-build.yml/badge.svg)](https://github.com/chirontt/jgit.http.server.native/actions/workflows/gradle-build.yml)
4+
[![Github Actions Build Status](https://github.com/chirontt/jgit.http.server.native/actions/workflows/maven-build.yml/badge.svg)](https://github.com/chirontt/jgit.http.server.native/actions/workflows/maven-build.yml)
5+
36
Sample project to compile JGit HTTP server, with LFS server support, to native executable
47
using GraalVM native-image utility.
58

6-
[JGit](http://www.eclipse.org/jgit/) is a pure Java implementation of the Git version control system,
9+
[JGit](https://projects.eclipse.org/projects/technology.jgit) is a pure Java implementation of the Git version control system,
710
and is available as a library to be integrated into many projects.
811
The JGit [project](https://github.com/eclipse-jgit/jgit) also implements a
912
[git server](https://github.com/eclipse-jgit/jgit/tree/master/org.eclipse.jgit.http.server)
@@ -54,21 +57,21 @@ To generate native executable, run the `nativeCompile` task:
5457
The `nativeCompile` task would take a while to compile the source code and link into an executable file.
5558
The resulting `JGitHttpServer` file is in:
5659

57-
build/native-image/JGitHttpServer
60+
build/native/nativeCompile/JGitHttpServer
5861

5962
(or if building on a Windows machine:
6063

61-
build\native-image\JGitHttpServer.exe
64+
build\native\nativeCompile\JGitHttpServer.exe
6265

6366
)
6467

6568
which can then be run directly (with parameters):
6669

67-
./build/native-image/JGitHttpServer 8080 /path/to/repos /path/to/lfs/storage
70+
./build/native/nativeCompile/JGitHttpServer 8080 /path/to/repos /path/to/lfs/storage
6871

6972
(or if building on a Windows machine:
7073

71-
build\native-image\JGitHttpServer.exe 8080 \path\to\repos \path\to\lfs\storage
74+
build\native\nativeCompile\JGitHttpServer.exe 8080 \path\to\repos \path\to\lfs\storage
7275

7376
)
7477

@@ -88,30 +91,21 @@ To generate native executable, run the `package` task:
8891
The `package` task would take a while to compile the source code and link into an executable file.
8992
The resulting `JGitHttpServer` file is in:
9093

91-
target/native-image/JGitHttpServer
94+
target/JGitHttpServer
9295

9396
(or if building on a Windows machine:
9497

95-
target\native-image\JGitHttpServer.exe
98+
target\JGitHttpServer.exe
9699

97100
)
98101

99102
which can then be run directly (with parameters):
100103

101-
./target/native-image/JGitHttpServer 8080 /path/to/repos /path/to/lfs/storage
104+
./target/JGitHttpServer 8080 /path/to/repos /path/to/lfs/storage
102105

103106
(or if building on a Windows machine:
104107

105-
target\native-image\JGitHttpServer.exe 8080 \path\to\repos \path\to\lfs\storage
108+
target\JGitHttpServer.exe 8080 \path\to\repos \path\to\lfs\storage
106109

107110
)
108111

109-
## Compressed native executable
110-
111-
The resulting `JGitHttpServer` executable file, whether produced by Gradle or Maven build scripts,
112-
can be further reduced in size via compression using the [UPX](https://upx.github.io) utility,
113-
as described [here](https://medium.com/graalvm/compressed-graalvm-native-images-4d233766a214).
114-
115-
As an example, the resulting `JGitHttpServer.exe` native application file produced in Windows
116-
is normally 35MB in size, but is compressed to 10MB with the UPX command: `upx --best JGitHttpServer.exe`
117-

build.gradle

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,41 @@
11
plugins {
22
id 'application'
3-
id 'org.graalvm.buildtools.native' version '0.10.4'
3+
id 'org.graalvm.buildtools.native' version '0.10.6'
44
}
55

66
tasks.wrapper {
7-
gradleVersion = '8.12'
7+
gradleVersion = '8.13'
88
distributionType = Wrapper.DistributionType.ALL
99
}
1010

1111
group = 'com.github.chirontt.jgit'
1212
description = "JGit HTTP server's native executable built by GraalVM"
13-
version = '7.1.0'
13+
version = '7.2.0'
1414

1515
ext {
1616
mainClassName = 'com.github.chirontt.gitserver.JGitHttpServer'
17-
jgitReleaseVersion = '7.1.0.202411261347-r'
18-
jettyVersion = '11.0.24'
19-
slf4jVersion = '2.0.16'
17+
jgitReleaseVersion = '7.2.0.202503040940-r'
18+
jettyVersion = '12.0.18'
19+
slf4jVersion = '2.0.17'
2020
}
2121

2222
repositories {
2323
mavenCentral()
24+
maven {
25+
url = "https://repo.eclipse.org/content/groups/releases/"
26+
}
2427
mavenLocal()
2528
}
2629

2730
compileJava {
28-
options.release = 11 //use JDK11+ for compiling & running
31+
options.release = 17
2932
options.encoding = 'UTF-8'
3033
}
3134

3235
dependencies {
3336
implementation "org.eclipse.jgit:org.eclipse.jgit.http.server:$jgitReleaseVersion"
3437
implementation "org.eclipse.jgit:org.eclipse.jgit.lfs.server:$jgitReleaseVersion"
35-
implementation "org.eclipse.jetty:jetty-servlet:$jettyVersion"
38+
implementation "org.eclipse.jetty.ee10:jetty-ee10-servlet:$jettyVersion"
3639
implementation "org.slf4j:slf4j-simple:$slf4jVersion"
3740
}
3841

@@ -84,7 +87,7 @@ task uberJar(type: Jar) {
8487
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
8588
}
8689
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
87-
duplicatesStrategy 'exclude'
90+
duplicatesStrategy = 'exclude'
8891
}
8992

9093
graalvmNative {

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pom.xml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44

55
<groupId>com.github.chirontt.jgit</groupId>
66
<artifactId>jgit.http.server.native</artifactId>
7-
<version>7.1.0</version>
7+
<version>7.2.0</version>
88
<packaging>jar</packaging>
99

1010
<name>JGitHttpServer</name> <!-- name of the resulting native executable -->
1111
<description>JGit HTTP server's native executable built by GraalVM</description>
1212

1313
<properties>
14-
<maven.compiler.release>11</maven.compiler.release>
14+
<maven.compiler.release>17</maven.compiler.release>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16-
<jgit.release.version>7.1.0.202411261347-r</jgit.release.version>
17-
<jetty.version>11.0.24</jetty.version>
18-
<slf4j.version>2.0.16</slf4j.version>
19-
<native.maven.plugin.version>0.10.4</native.maven.plugin.version>
16+
<jgit.release.version>7.2.0.202503040940-r</jgit.release.version>
17+
<jetty.version>12.0.18</jetty.version>
18+
<slf4j.version>2.0.17</slf4j.version>
19+
<native.maven.plugin.version>0.10.6</native.maven.plugin.version>
2020
<!-- main class name for exec:exec plugin task -->
2121
<exec.mainClass>com.github.chirontt.gitserver.JGitHttpServer</exec.mainClass>
2222
<!-- default values for server port, path to git repos, and path to LFS storage -->
@@ -45,6 +45,13 @@
4545
</run.time.re.init>
4646
</properties>
4747

48+
<repositories>
49+
<repository>
50+
<id>eclipse.releases.repository</id>
51+
<url>https://repo.eclipse.org/content/groups/releases/</url>
52+
</repository>
53+
</repositories>
54+
4855
<dependencies>
4956
<dependency>
5057
<groupId>org.eclipse.jgit</groupId>
@@ -62,8 +69,8 @@
6269
<version>${slf4j.version}</version>
6370
</dependency>
6471
<dependency>
65-
<groupId>org.eclipse.jetty</groupId>
66-
<artifactId>jetty-servlet</artifactId>
72+
<groupId>org.eclipse.jetty.ee10</groupId>
73+
<artifactId>jetty-ee10-servlet</artifactId>
6774
<version>${jetty.version}</version>
6875
</dependency>
6976
</dependencies>

src/main/java/com/github/chirontt/gitserver/JGitHttpServer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
import java.util.stream.Collectors;
2222
import java.util.stream.Stream;
2323

24+
import org.eclipse.jetty.ee10.servlet.ServletContextHandler;
25+
import org.eclipse.jetty.ee10.servlet.ServletHolder;
2426
import org.eclipse.jetty.server.HttpConfiguration;
2527
import org.eclipse.jetty.server.HttpConnectionFactory;
2628
import org.eclipse.jetty.server.Server;
2729
import org.eclipse.jetty.server.ServerConnector;
28-
import org.eclipse.jetty.servlet.ServletContextHandler;
29-
import org.eclipse.jetty.servlet.ServletHolder;
3030
import org.eclipse.jgit.http.server.GitServlet;
3131
import org.eclipse.jgit.lfs.server.fs.FileLfsRepository;
3232
import org.eclipse.jgit.lfs.server.fs.FileLfsServlet;
@@ -93,7 +93,7 @@ public static void main(String[] args) throws Exception {
9393
server.addConnector(gitConnector);
9494

9595
ServletContextHandler gitContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
96-
gitContext.setVirtualHosts(new String[]{"@git-connector"});
96+
gitContext.setVirtualHosts(List.of("@git-connector"));
9797

9898
//set up LFS servlets for each valid git repo under base-path
9999
List<Path> validRepos = getValidGitRepos(basePath);
@@ -129,7 +129,7 @@ private static void printServerInfo() {
129129

130130
private static URI getBaseURI() {
131131
try (BufferedReader br = new BufferedReader(new InputStreamReader(
132-
Runtime.getRuntime().exec("hostname").getInputStream()))) {
132+
Runtime.getRuntime().exec(new String[]{"hostname"}).getInputStream()))) {
133133
String hostname = br.readLine();
134134
return new URI("http://" + hostname + ":" + serverPort);
135135
} catch (IOException e) {

src/main/resources/META-INF/native-image/reflect-config.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@
100100
"name":"org.eclipse.jgit.diff.DiffAlgorithm$SupportedAlgorithm",
101101
"methods":[{"name":"values","parameterTypes":[] }]
102102
},
103+
{
104+
"name":"org.eclipse.jgit.dircache.DirCache$DirCacheVersion",
105+
"methods":[{"name":"values","parameterTypes":[] }]
106+
},
103107
{
104108
"name":"org.eclipse.jgit.gitrepo.internal.RepoText",
105109
"allDeclaredFields":true,
@@ -215,6 +219,18 @@
215219
"name":"org.eclipse.jgit.lib.CoreConfig$TrustPackedRefsStat",
216220
"methods":[{"name":"values","parameterTypes":[] }]
217221
},
222+
{
223+
"name":"org.eclipse.jgit.lib.CoreConfig$TrustStat",
224+
"methods":[{"name":"values","parameterTypes":[] }]
225+
},
226+
{
227+
"name":"org.eclipse.jgit.lib.GpgConfig$GpgFormat",
228+
"methods":[{"name":"values","parameterTypes":[] }]
229+
},
230+
{
231+
"name":"org.eclipse.jgit.transport.HttpConfig$HttpRedirectMode",
232+
"methods":[{"name":"values","parameterTypes":[] }]
233+
},
218234
{
219235
"name":"org.eclipse.jgit.transport.http.apache.internal.HttpApacheText",
220236
"allDeclaredFields":true,

0 commit comments

Comments
 (0)