Skip to content

Commit

Permalink
feat: Componentize and support java 8, Add named configurations (#6221)
Browse files Browse the repository at this point in the history
Componentize packages and support java 8 for the Enterprise product
#6219 and support named Configurations #6220
  • Loading branch information
abaranec authored Oct 31, 2024
1 parent 56e3cdf commit 7c999c3
Show file tree
Hide file tree
Showing 68 changed files with 645 additions and 277 deletions.
1 change: 1 addition & 0 deletions Base/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
io.deephaven.project.ProjectType=JAVA_PUBLIC
languageLevel=8
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.stats.util;
package io.deephaven.base;

import org.jetbrains.annotations.NotNull;

Expand Down
1 change: 0 additions & 1 deletion Configuration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dependencies {
api libs.trove

implementation project(':Base')
implementation project(':DataStructures')
implementation project(':IO')
implementation project(':log-factory')
implementation libs.commons.lang3
Expand Down
1 change: 1 addition & 0 deletions Configuration/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
io.deephaven.project.ProjectType=JAVA_PUBLIC
languageLevel=8
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package io.deephaven.configuration;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;

/**
Expand All @@ -30,9 +31,8 @@ public final class CacheDir {
* @return the cache dir
*/
public static Path get() {
return viaProperty()
.or(CacheDir::viaEnvVar)
.map(Path::of)
return getOptional()
.map(Paths::get)
.orElseGet(CacheDir::viaTmpDir);
}

Expand All @@ -45,12 +45,20 @@ public static Path get() {
* @return the cache directory
*/
public static Path getOrSet(String defaultValue) {
final String existing = viaProperty().or(CacheDir::viaEnvVar).orElse(null);
final String existing = getOptional().orElse(null);
if (existing != null) {
return Path.of(existing);
return Paths.get(existing);
}
System.setProperty(PROPERTY, defaultValue);
return Path.of(defaultValue);
return Paths.get(defaultValue);
}

private static Optional<String> getOptional() {
Optional<String> optional = viaProperty();
if (!optional.isPresent()) {
optional = viaEnvVar();
}
return optional;
}

private static Optional<String> viaProperty() {
Expand All @@ -62,6 +70,6 @@ private static Optional<String> viaEnvVar() {
}

private static Path viaTmpDir() {
return Path.of(System.getProperty(JAVA_IO_TMPDIR), "deephaven", "cache");
return Paths.get(System.getProperty(JAVA_IO_TMPDIR), "deephaven", "cache");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;

public final class ConfigDir {
Expand All @@ -21,9 +22,7 @@ public final class ConfigDir {
* @return the config directory
*/
public static Optional<Path> get() {
return viaProperty()
.or(ConfigDir::viaEnvVar)
.map(Path::of);
return getOptional().map(Paths::get);
}

/**
Expand All @@ -35,14 +34,12 @@ public static Optional<Path> get() {
* @return the config directory
*/
public static Path getOrSet(String defaultValue) {
final String existing = viaProperty()
.or(ConfigDir::viaEnvVar)
.orElse(null);
final String existing = getOptional().orElse(null);
if (existing != null) {
return Path.of(existing);
return Paths.get(existing);
}
System.setProperty(PROPERTY, defaultValue);
return Path.of(defaultValue);
return Paths.get(defaultValue);
}

/**
Expand All @@ -53,10 +50,11 @@ public static Path getOrSet(String defaultValue) {
* @return the configuration file
*/
public static String configurationFile() {
return Optional
.ofNullable(System.getProperty(ROOT_FILE_PROP))
.or(ConfigDir::configDirectoryFileIfExists)
.orElse(DEFAULT_CONFIGURATION_FILE);
Optional<String> optional = Optional.ofNullable(System.getProperty(ROOT_FILE_PROP));
if (!optional.isPresent()) {
optional = configDirectoryFileIfExists();
}
return optional.orElse(DEFAULT_CONFIGURATION_FILE);
}

private static Optional<String> configDirectoryFileIfExists() {
Expand All @@ -66,6 +64,14 @@ private static Optional<String> configDirectoryFileIfExists() {
.map(Path::toString);
}

private static Optional<String> getOptional() {
Optional<String> optional = viaProperty();
if (!optional.isPresent()) {
optional = viaEnvVar();
}
return optional;
}

private static Path defaultFileName(Path p) {
return p.resolve(DEFAULT_CONFIG_FILE_NAME);
}
Expand Down
Loading

0 comments on commit 7c999c3

Please sign in to comment.