[releng] Fix maven builds on JVM 21 and with newer git on MacOS IndexDiffWithSymlinkTest runs only on MacOS, but fails there with newer git or when run on a JVM 21. Newer git creates a default branch "main" by default. The test uses native git to run "git fast-import" to be sure the symlink to be tested is created not through Java but natively. But the so imported repo assumes "master" as default branch, and thus the final checkout fails. Fix this by running "git -c init.defaultBranch=master init" instead of just "git init". (With older git that doesn't know this config, this -c option simply won't have any effect, but such old git will use "master" anyway as default branch name.) Next, that test tries to reflectively access a package-private method in sun.nio.fs.UnixPath to get at the raw bytes of that symlink. That fails with an InaccessibleObjectException on JVM 21. Fix this by adding "--add-opens java.base/sun.nio.fs=ALL-UNNAMED" to the surefire command line options. Change-Id: I6316be2e5cc5d58e7c4e30fcdca274dfa8abc78d
diff --git a/org.eclipse.jgit.test/pom.xml b/org.eclipse.jgit.test/pom.xml index 39d317a..b67a2ab 100644 --- a/org.eclipse.jgit.test/pom.xml +++ b/org.eclipse.jgit.test/pom.xml
@@ -165,7 +165,7 @@ <plugin> <artifactId>maven-surefire-plugin</artifactId> <configuration> - <argLine>@{argLine} -Xmx768m -Dfile.encoding=UTF-8 -Djava.io.tmpdir=${project.build.directory}</argLine> + <argLine>@{argLine} -Xmx768m -Dfile.encoding=UTF-8 -Djava.io.tmpdir=${project.build.directory} --add-opens java.base/sun.nio.fs=ALL-UNNAMED</argLine> <includes> <include>**/*Test.java</include> <include>**/*Tests.java</include>
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/indexdiff/IndexDiffWithSymlinkTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/indexdiff/IndexDiffWithSymlinkTest.java index d02bfcd..1119db3 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/indexdiff/IndexDiffWithSymlinkTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/indexdiff/IndexDiffWithSymlinkTest.java
@@ -132,7 +132,8 @@ private File restoreGitRepo(InputStream in, File testDir, String name) Writer writer = new OutputStreamWriter(out, UTF_8)) { writer.write("echo `which git` 1>&2\n"); writer.write("echo `git --version` 1>&2\n"); - writer.write("git init " + name + " && \\\n"); + writer.write("git -c init.defaultBranch=master init " + name + + " && \\\n"); writer.write("cd ./" + name + " && \\\n"); writer.write("git fast-import < ../" + name + ".txt && \\\n"); writer.write("git checkout -f\n");