enable directory listings in jar files

This commit is contained in:
Armin Schrenk
2023-05-08 21:21:43 +02:00
parent 0f9d572677
commit 8691eec42b
8 changed files with 30 additions and 12 deletions

View File

@@ -54,7 +54,7 @@ jobs:
--verbose
--output runtime
--module-path "${JAVA_HOME}/jmods"
--add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,javafx.base,javafx.graphics,javafx.controls,javafx.fxml,jdk.unsupported,jdk.crypto.ec,jdk.security.auth,jdk.accessibility,jdk.management.jfr
--add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,javafx.base,javafx.graphics,javafx.controls,javafx.fxml,jdk.unsupported,jdk.crypto.ec,jdk.security.auth,jdk.accessibility,jdk.management.jfr,jdk.zipfs
--strip-native-commands
--no-header-files
--no-man-pages

View File

@@ -70,7 +70,7 @@ jobs:
--verbose
--output runtime
--module-path "${JAVA_HOME}/jmods"
--add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,javafx.base,javafx.graphics,javafx.controls,javafx.fxml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr
--add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,javafx.base,javafx.graphics,javafx.controls,javafx.fxml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr,jdk.zipfs
--strip-native-commands
--no-header-files
--no-man-pages

View File

@@ -83,7 +83,7 @@ jobs:
--verbose
--output runtime
--module-path "jfxjmods;${JAVA_HOME}/jmods"
--add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,javafx.base,javafx.graphics,javafx.controls,javafx.fxml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr
--add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,javafx.base,javafx.graphics,javafx.controls,javafx.fxml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr,jdk.zipfs
--strip-native-commands
--no-header-files
--no-man-pages

View File

@@ -24,7 +24,7 @@ ${JAVA_HOME}/bin/jlink \
--verbose \
--output runtime \
--module-path "${JAVA_HOME}/jmods" \
--add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,javafx.base,javafx.graphics,javafx.controls,javafx.fxml,jdk.unsupported,jdk.crypto.ec,jdk.security.auth,jdk.accessibility,jdk.management.jfr \
--add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,javafx.base,javafx.graphics,javafx.controls,javafx.fxml,jdk.unsupported,jdk.crypto.ec,jdk.security.auth,jdk.accessibility,jdk.management.jfr,jdk.zipfs \
--strip-native-commands \
--no-header-files \
--no-man-pages \

View File

@@ -27,7 +27,7 @@ override_dh_auto_build:
$(JAVA_HOME)/bin/jlink \
--output runtime \
--module-path "${JMODS_PATH}" \
--add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,javafx.base,javafx.graphics,javafx.controls,javafx.fxml,jdk.unsupported,jdk.crypto.ec,jdk.security.auth,jdk.accessibility,jdk.management.jfr \
--add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,javafx.base,javafx.graphics,javafx.controls,javafx.fxml,jdk.unsupported,jdk.crypto.ec,jdk.security.auth,jdk.accessibility,jdk.management.jfr,jdk.zipfs \
--strip-native-commands \
--no-header-files \
--no-man-pages \

View File

@@ -46,7 +46,7 @@ cp ../../../target/${MAIN_JAR_GLOB} ../../../target/mods
${JAVA_HOME}/bin/jlink \
--output runtime \
--module-path "${JAVA_HOME}/jmods" \
--add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr \
--add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr,jdk.zipfs \
--strip-native-commands \
--no-header-files \
--no-man-pages \

3
dist/win/build.ps1 vendored
View File

@@ -51,7 +51,7 @@ if ($clean -and (Test-Path -Path $runtimeImagePath)) {
--verbose `
--output runtime `
--module-path "$Env:JAVA_HOME/jmods" `
--add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr `
--add-modules java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr,jdk.zipfs `
--strip-native-commands `
--no-header-files `
--no-man-pages `
@@ -93,6 +93,7 @@ if ($clean -and (Test-Path -Path $appPath)) {
--java-options "-Dcryptomator.integrationsWin.keychainPaths=`"~/AppData/Roaming/$AppName/keychain.json`"" `
--java-options "-Dcryptomator.showTrayIcon=true" `
--java-options "-Dcryptomator.buildNumber=`"msi-$revisionNo`"" `
--win-console `
--resource-dir resources `
--icon resources/$AppName.ico

View File

@@ -7,7 +7,9 @@ import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.Collator;
@@ -15,6 +17,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.stream.StreamSupport;
@Singleton
@@ -60,11 +63,17 @@ public class SupportedLanguages {
*/
private static List<String> getSupportedLanguageTags() {
try {
var i18Dir = Path.of(SupportedLanguages.class.getResource("/i18n").toURI());
try (var dirStream = Files.newDirectoryStream(i18Dir, "strings_*.properties")) {
return StreamSupport.stream(dirStream.spliterator(), false) //
.map(SupportedLanguages::getBCP47CodeFromFileName) //
.toList();
var i18DirURI = SupportedLanguages.class.getResource("/i18n").toURI();
var uriScheme = i18DirURI.getScheme();
if (uriScheme.equals("jar")) {
final String[] array = i18DirURI.toString().split("!");
try (var jarFs = FileSystems.newFileSystem(URI.create(array[0]), Map.<String, String>of())) {
return streamDirectory(jarFs.getPath(array[1]));
}
} else if (uriScheme.equals("file")) {
return streamDirectory(Path.of(i18DirURI));
} else {
throw new IOException("Unsupported uri scheme: " + uriScheme);
}
} catch (URISyntaxException | IOException e) {
LOG.warn("Unable to determine additional supported languages.", e);
@@ -72,6 +81,14 @@ public class SupportedLanguages {
}
}
private static List<String> streamDirectory(Path i18Dir) throws IOException {
try (var dirStream = Files.newDirectoryStream(i18Dir, "strings_*.properties")) {
return StreamSupport.stream(dirStream.spliterator(), false) //
.map(SupportedLanguages::getBCP47CodeFromFileName) //
.toList();
}
}
private static String getBCP47CodeFromFileName(Path p) {
var fileName = p.getFileName().toString();
return fileName.substring("strings_".length(), fileName.indexOf(".properties")).replace('_', '-');