Rework dev environment setup

This commit is contained in:
crschnick 2024-05-10 12:22:15 +00:00
parent 0c06fe99f7
commit 911c85a004
11 changed files with 77 additions and 47 deletions

1
.gitignore vendored
View file

@ -18,3 +18,4 @@ bin
ComponentsGenerated.wxs ComponentsGenerated.wxs
!dist/javafx/**/lib !dist/javafx/**/lib
!dist/javafx/**/bin !dist/javafx/**/bin
dev.properties

View file

@ -28,7 +28,14 @@ You can find the available version tags at https://github.com/xpipe-io/xpipe/tag
So for example if you currently have XPipe `9.0` installed, you should run `git reset --hard 9.0` first to properly compile against it. So for example if you currently have XPipe `9.0` installed, you should run `git reset --hard 9.0` first to properly compile against it.
You need to have JDK for Java 21 installed to compile the project. You need to have JDK for Java 21 installed to compile the project.
If you are on Linux or macOS, you can easily accomplish that by running the `setup.sh` script. If you are on Linux or macOS, you can easily accomplish that by running
```bash
curl -s "https://get.sdkman.io" | bash
. "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java 21.0.1-graalce
sdk default java 21.0.1-graalce
```
.
On Windows, you have to manually install a JDK, e.g. from [Adoptium](https://adoptium.net/temurin/releases/?version=21). On Windows, you have to manually install a JDK, e.g. from [Adoptium](https://adoptium.net/temurin/releases/?version=21).
## Building and Running ## Building and Running

View file

@ -79,13 +79,11 @@ application {
run { run {
systemProperty 'io.xpipe.app.useVirtualThreads', 'false' systemProperty 'io.xpipe.app.useVirtualThreads', 'false'
systemProperty 'io.xpipe.app.mode', 'gui' systemProperty 'io.xpipe.app.mode', 'gui'
systemProperty 'io.xpipe.app.dataDir', "$projectDir/local_git23/"
systemProperty 'io.xpipe.app.writeLogs', "true" systemProperty 'io.xpipe.app.writeLogs', "true"
systemProperty 'io.xpipe.app.writeSysOut', "true" systemProperty 'io.xpipe.app.writeSysOut', "true"
systemProperty 'io.xpipe.app.developerMode', "true" systemProperty 'io.xpipe.app.developerMode', "true"
systemProperty 'io.xpipe.app.logLevel', "trace" systemProperty 'io.xpipe.app.logLevel', "trace"
systemProperty 'io.xpipe.app.fullVersion', rootProject.fullVersion systemProperty 'io.xpipe.app.fullVersion', rootProject.fullVersion
systemProperty 'io.xpipe.app.showcase', 'true'
systemProperty 'io.xpipe.app.staging', isStage systemProperty 'io.xpipe.app.staging', isStage
// systemProperty "io.xpipe.beacon.port", "21724" // systemProperty "io.xpipe.beacon.port", "21724"
// systemProperty "io.xpipe.beacon.printMessages", "true" // systemProperty "io.xpipe.beacon.printMessages", "true"

View file

@ -88,7 +88,7 @@ public class AppExtensionManager {
} }
if (!AppProperties.get().isFullVersion()) { if (!AppProperties.get().isFullVersion()) {
var localInstallation = XPipeInstallation.getLocalDefaultInstallationBasePath(); var localInstallation = XPipeInstallation.getLocalDefaultInstallationBasePath(AppProperties.get().isStaging() || AppProperties.get().isLocatePtb());
Path p = Path.of(localInstallation); Path p = Path.of(localInstallation);
if (!Files.exists(p)) { if (!Files.exists(p)) {
throw new IllegalStateException( throw new IllegalStateException(
@ -103,7 +103,7 @@ public class AppExtensionManager {
: AppProperties.get().getVersion(); : AppProperties.get().getVersion();
var sourceVersion = AppVersion.parse(sv) var sourceVersion = AppVersion.parse(sv)
.orElseThrow(() -> new IllegalArgumentException("Invalid source version: " + sv)); .orElseThrow(() -> new IllegalArgumentException("Invalid source version: " + sv));
if (!installVersion.equals(sourceVersion)) { if (AppProperties.get().isLocatorVersionCheck() && !installVersion.equals(sourceVersion)) {
throw new IllegalStateException("Incompatible development version. Source: " + iv + ", Installation: " throw new IllegalStateException("Incompatible development version. Source: " + iv + ", Installation: "
+ sv + "\n\nPlease try to check out the matching release version in the repository."); + sv + "\n\nPlease try to check out the matching release version in the repository.");
} }

View file

@ -1,23 +1,20 @@
package io.xpipe.app.core; package io.xpipe.app.core;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent; import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs; import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.util.ModuleHelper; import io.xpipe.core.util.ModuleHelper;
import io.xpipe.core.util.XPipeInstallation;
import lombok.Getter; import lombok.Getter;
import lombok.Value; import lombok.Value;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Arrays; import java.util.*;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@Value @Value
public class AppProperties { public class AppProperties {
private static final String EXTENSION_PATHS_PROP = "io.xpipe.app.extensions";
private static AppProperties INSTANCE; private static AppProperties INSTANCE;
boolean fullVersion; boolean fullVersion;
@ -41,8 +38,22 @@ public class AppProperties {
Path dataDir; Path dataDir;
boolean showcase; boolean showcase;
AppVersion canonicalVersion; AppVersion canonicalVersion;
boolean locatePtb;
boolean locatorVersionCheck;
public AppProperties() { public AppProperties() {
var appDir = Path.of(System.getProperty("user.dir")).resolve("app");
Path propsFile = appDir.resolve("dev.properties");
if (Files.exists(propsFile)) {
try {
Properties props = new Properties();
props.load(Files.newInputStream(propsFile));
props.forEach((key, value) -> System.setProperty(key.toString(), value.toString()));
} catch (IOException e) {
ErrorEvent.fromThrowable(e).handle();
}
}
image = ModuleHelper.isImage(); image = ModuleHelper.isImage();
fullVersion = Optional.ofNullable(System.getProperty("io.xpipe.app.fullVersion")) fullVersion = Optional.ofNullable(System.getProperty("io.xpipe.app.fullVersion"))
.map(Boolean::parseBoolean) .map(Boolean::parseBoolean)
@ -58,18 +69,34 @@ public class AppProperties {
languages = Arrays.stream(System.getProperty("io.xpipe.app.languages").split(",")) languages = Arrays.stream(System.getProperty("io.xpipe.app.languages").split(","))
.sorted() .sorted()
.toList(); .toList();
staging = XPipeInstallation.isStaging(); staging = Optional.ofNullable(System.getProperty("io.xpipe.app.staging"))
.map(Boolean::parseBoolean)
.orElse(false);
useVirtualThreads = Optional.ofNullable(System.getProperty("io.xpipe.app.useVirtualThreads")) useVirtualThreads = Optional.ofNullable(System.getProperty("io.xpipe.app.useVirtualThreads"))
.map(Boolean::parseBoolean) .map(Boolean::parseBoolean)
.orElse(true); .orElse(true);
debugThreads = Optional.ofNullable(System.getProperty("io.xpipe.app.debugThreads")) debugThreads = Optional.ofNullable(System.getProperty("io.xpipe.app.debugThreads"))
.map(Boolean::parseBoolean) .map(Boolean::parseBoolean)
.orElse(false); .orElse(false);
dataDir = XPipeInstallation.getDataDir(); dataDir = Optional.ofNullable(System.getProperty("io.xpipe.app.dataDir"))
.map(s -> {
var p = Path.of(s);
if (!p.isAbsolute()) {
p = appDir.resolve(p);
}
return p;
})
.orElse(Path.of(System.getProperty("user.home"), isStaging() ? ".xpipe-ptb" : ".xpipe"));
showcase = Optional.ofNullable(System.getProperty("io.xpipe.app.showcase")) showcase = Optional.ofNullable(System.getProperty("io.xpipe.app.showcase"))
.map(Boolean::parseBoolean) .map(Boolean::parseBoolean)
.orElse(false); .orElse(false);
canonicalVersion = AppVersion.parse(version).orElse(null); canonicalVersion = AppVersion.parse(version).orElse(null);
locatePtb = Optional.ofNullable(System.getProperty("io.xpipe.app.locator.usePtbInstallation"))
.map(Boolean::parseBoolean)
.orElse(false);
locatorVersionCheck = Optional.ofNullable(System.getProperty("io.xpipe.app.locator.disableInstallationVersionCheck"))
.map(Boolean::parseBoolean)
.orElse(false);
} }
public static void logSystemProperties() { public static void logSystemProperties() {

View file

@ -1,5 +1,6 @@
package io.xpipe.app.update; package io.xpipe.app.update;
import io.xpipe.app.core.AppLogs;
import io.xpipe.app.core.AppProperties; import io.xpipe.app.core.AppProperties;
import io.xpipe.app.util.LocalShell; import io.xpipe.app.util.LocalShell;
import io.xpipe.app.util.ScriptHelper; import io.xpipe.app.util.ScriptHelper;
@ -72,7 +73,7 @@ public class AppInstaller {
: XPipeInstallation.getCurrentInstallationBasePath()) : XPipeInstallation.getCurrentInstallationBasePath())
.resolve(XPipeInstallation.getDaemonExecutablePath(OsType.getLocal())) .resolve(XPipeInstallation.getDaemonExecutablePath(OsType.getLocal()))
.toString(); .toString();
var logsDir = FileNames.join(XPipeInstallation.getDataDir().toString(), "logs"); var logsDir = AppLogs.get().getSessionLogsDirectory().getParent().toString();
var logFile = FileNames.join(logsDir, "installer_" + FileNames.getFileName(file) + ".log"); var logFile = FileNames.join(logsDir, "installer_" + FileNames.getFileName(file) + ".log");
var command = LocalShell.getShell().getShellDialect().equals(ShellDialects.CMD) var command = LocalShell.getShell().getShellDialect().equals(ShellDialects.CMD)
? getCmdCommand(file, logFile, exec) ? getCmdCommand(file, logFile, exec)

View file

@ -22,7 +22,7 @@ allprojects { subproject ->
extraJavaModuleInfo { extraJavaModuleInfo {
failOnMissingModuleInfo.set(false) failOnMissingModuleInfo.set(false)
} }
apply from: "$rootDir/modules.gradle" apply from: "$rootDir/gradle/gradle_scripts/modules.gradle"
} }
subprojects {subproject -> subprojects {subproject ->
@ -41,6 +41,11 @@ subprojects {subproject ->
} }
} }
var devProps = file("$rootDir/app/dev.properties")
if (!devProps.exists()) {
devProps.text = file("$rootDir/gradle/gradle_scripts/dev_default.properties").text
}
def getArchName() { def getArchName() {
var arch = System.getProperty("os.arch").toLowerCase(Locale.ROOT) var arch = System.getProperty("os.arch").toLowerCase(Locale.ROOT)
if (arch == 'amd64' || arch == 'x86_64') { if (arch == 'amd64' || arch == 'x86_64') {

View file

@ -1,15 +1,13 @@
package io.xpipe.core.util; package io.xpipe.core.util;
import io.xpipe.core.process.*; import io.xpipe.core.process.OsType;
import io.xpipe.core.store.FileNames; import io.xpipe.core.store.FileNames;
import lombok.Getter; import lombok.Getter;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Optional; import java.util.Optional;
@ -32,17 +30,6 @@ public class XPipeInstallation {
} }
} }
public static Path getDataDir() {
if (System.getProperty(DATA_DIR_PROP) != null) {
try {
return Path.of(System.getProperty(DATA_DIR_PROP));
} catch (InvalidPathException ignored) {
}
}
return Path.of(System.getProperty("user.home"), isStaging() ? ".xpipe-ptb" : ".xpipe");
}
private static String getPkgId() { private static String getPkgId() {
return isStaging() ? "io.xpipe.xpipe-ptb" : "io.xpipe.xpipe"; return isStaging() ? "io.xpipe.xpipe-ptb" : "io.xpipe.xpipe";
} }
@ -260,14 +247,18 @@ public class XPipeInstallation {
} }
public static String getLocalDefaultInstallationBasePath() { public static String getLocalDefaultInstallationBasePath() {
return getLocalDefaultInstallationBasePath(staging);
}
public static String getLocalDefaultInstallationBasePath(boolean stage) {
String path; String path;
if (OsType.getLocal().equals(OsType.WINDOWS)) { if (OsType.getLocal().equals(OsType.WINDOWS)) {
var base = System.getenv("LOCALAPPDATA"); var base = System.getenv("LOCALAPPDATA");
path = FileNames.join(base, isStaging() ? "XPipe PTB" : "XPipe"); path = FileNames.join(base, stage ? "XPipe PTB" : "XPipe");
} else if (OsType.getLocal().equals(OsType.LINUX)) { } else if (OsType.getLocal().equals(OsType.LINUX)) {
path = isStaging() ? "/opt/xpipe-ptb" : "/opt/xpipe"; path = stage ? "/opt/xpipe-ptb" : "/opt/xpipe";
} else { } else {
path = isStaging() ? "/Applications/XPipe PTB.app" : "/Applications/XPipe.app"; path = stage ? "/Applications/XPipe PTB.app" : "/Applications/XPipe.app";
} }
return path; return path;

View file

@ -0,0 +1,14 @@
# XPipe will attempt to locate a local XPipe installation with the matching version to fetch production resources from it.
# If your installation version and development version do not match up, there is the possibility of errors occurring.
# If you know what you are doing, you can disable this version check.
io.xpipe.app.locator.disableInstallationVersionCheck=false
# By default, XPipe will try to locate a normal local installation.
# If you also have a PTB version installed, you can also choose to use it if the version matches the development version more closely.
io.xpipe.app.locator.usePtbInstallation=false
# Start up in fixed 16/9 window size, useful for demos and showcases
io.xpipe.app.showcase=false
# Location in which your local development connection should be stored. If left empty, it will use your global XPipe storage in ~/.xpipe.
io.xpipe.app.dataDir=local

View file

@ -1,14 +0,0 @@
#!/bin/bash
which sdk
if [ $? -ne 0 ]; then
curl -s "https://get.sdkman.io" | bash
if [ $? -ne 0 ]; then
echo "sdkman failed"
exit 1
fi;
. "$HOME/.sdkman/bin/sdkman-init.sh"
fi;
sdk install java 21.0.1-graalce
sdk default java 21.0.1-graalce