mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 15:10:23 +00:00
Rework dev environment setup
This commit is contained in:
parent
0c06fe99f7
commit
911c85a004
11 changed files with 77 additions and 47 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -18,3 +18,4 @@ bin
|
|||
ComponentsGenerated.wxs
|
||||
!dist/javafx/**/lib
|
||||
!dist/javafx/**/bin
|
||||
dev.properties
|
||||
|
|
|
@ -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.
|
||||
|
||||
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).
|
||||
|
||||
## Building and Running
|
||||
|
|
|
@ -79,13 +79,11 @@ application {
|
|||
run {
|
||||
systemProperty 'io.xpipe.app.useVirtualThreads', 'false'
|
||||
systemProperty 'io.xpipe.app.mode', 'gui'
|
||||
systemProperty 'io.xpipe.app.dataDir', "$projectDir/local_git23/"
|
||||
systemProperty 'io.xpipe.app.writeLogs', "true"
|
||||
systemProperty 'io.xpipe.app.writeSysOut', "true"
|
||||
systemProperty 'io.xpipe.app.developerMode', "true"
|
||||
systemProperty 'io.xpipe.app.logLevel', "trace"
|
||||
systemProperty 'io.xpipe.app.fullVersion', rootProject.fullVersion
|
||||
systemProperty 'io.xpipe.app.showcase', 'true'
|
||||
systemProperty 'io.xpipe.app.staging', isStage
|
||||
// systemProperty "io.xpipe.beacon.port", "21724"
|
||||
// systemProperty "io.xpipe.beacon.printMessages", "true"
|
||||
|
|
|
@ -88,7 +88,7 @@ public class AppExtensionManager {
|
|||
}
|
||||
|
||||
if (!AppProperties.get().isFullVersion()) {
|
||||
var localInstallation = XPipeInstallation.getLocalDefaultInstallationBasePath();
|
||||
var localInstallation = XPipeInstallation.getLocalDefaultInstallationBasePath(AppProperties.get().isStaging() || AppProperties.get().isLocatePtb());
|
||||
Path p = Path.of(localInstallation);
|
||||
if (!Files.exists(p)) {
|
||||
throw new IllegalStateException(
|
||||
|
@ -103,7 +103,7 @@ public class AppExtensionManager {
|
|||
: AppProperties.get().getVersion();
|
||||
var sourceVersion = AppVersion.parse(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: "
|
||||
+ sv + "\n\nPlease try to check out the matching release version in the repository.");
|
||||
}
|
||||
|
|
|
@ -1,23 +1,20 @@
|
|||
package io.xpipe.app.core;
|
||||
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.app.issue.TrackEvent;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.core.util.ModuleHelper;
|
||||
import io.xpipe.core.util.XPipeInstallation;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Value;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
@Value
|
||||
public class AppProperties {
|
||||
|
||||
private static final String EXTENSION_PATHS_PROP = "io.xpipe.app.extensions";
|
||||
private static AppProperties INSTANCE;
|
||||
boolean fullVersion;
|
||||
|
||||
|
@ -41,8 +38,22 @@ public class AppProperties {
|
|||
Path dataDir;
|
||||
boolean showcase;
|
||||
AppVersion canonicalVersion;
|
||||
boolean locatePtb;
|
||||
boolean locatorVersionCheck;
|
||||
|
||||
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();
|
||||
fullVersion = Optional.ofNullable(System.getProperty("io.xpipe.app.fullVersion"))
|
||||
.map(Boolean::parseBoolean)
|
||||
|
@ -58,18 +69,34 @@ public class AppProperties {
|
|||
languages = Arrays.stream(System.getProperty("io.xpipe.app.languages").split(","))
|
||||
.sorted()
|
||||
.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"))
|
||||
.map(Boolean::parseBoolean)
|
||||
.orElse(true);
|
||||
debugThreads = Optional.ofNullable(System.getProperty("io.xpipe.app.debugThreads"))
|
||||
.map(Boolean::parseBoolean)
|
||||
.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"))
|
||||
.map(Boolean::parseBoolean)
|
||||
.orElse(false);
|
||||
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() {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.xpipe.app.update;
|
||||
|
||||
import io.xpipe.app.core.AppLogs;
|
||||
import io.xpipe.app.core.AppProperties;
|
||||
import io.xpipe.app.util.LocalShell;
|
||||
import io.xpipe.app.util.ScriptHelper;
|
||||
|
@ -72,7 +73,7 @@ public class AppInstaller {
|
|||
: XPipeInstallation.getCurrentInstallationBasePath())
|
||||
.resolve(XPipeInstallation.getDaemonExecutablePath(OsType.getLocal()))
|
||||
.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 command = LocalShell.getShell().getShellDialect().equals(ShellDialects.CMD)
|
||||
? getCmdCommand(file, logFile, exec)
|
||||
|
|
|
@ -22,7 +22,7 @@ allprojects { subproject ->
|
|||
extraJavaModuleInfo {
|
||||
failOnMissingModuleInfo.set(false)
|
||||
}
|
||||
apply from: "$rootDir/modules.gradle"
|
||||
apply from: "$rootDir/gradle/gradle_scripts/modules.gradle"
|
||||
}
|
||||
|
||||
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() {
|
||||
var arch = System.getProperty("os.arch").toLowerCase(Locale.ROOT)
|
||||
if (arch == 'amd64' || arch == 'x86_64') {
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
package io.xpipe.core.util;
|
||||
|
||||
import io.xpipe.core.process.*;
|
||||
import io.xpipe.core.process.OsType;
|
||||
import io.xpipe.core.store.FileNames;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.Path;
|
||||
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() {
|
||||
return isStaging() ? "io.xpipe.xpipe-ptb" : "io.xpipe.xpipe";
|
||||
}
|
||||
|
@ -260,14 +247,18 @@ public class XPipeInstallation {
|
|||
}
|
||||
|
||||
public static String getLocalDefaultInstallationBasePath() {
|
||||
return getLocalDefaultInstallationBasePath(staging);
|
||||
}
|
||||
|
||||
public static String getLocalDefaultInstallationBasePath(boolean stage) {
|
||||
String path;
|
||||
if (OsType.getLocal().equals(OsType.WINDOWS)) {
|
||||
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)) {
|
||||
path = isStaging() ? "/opt/xpipe-ptb" : "/opt/xpipe";
|
||||
path = stage ? "/opt/xpipe-ptb" : "/opt/xpipe";
|
||||
} else {
|
||||
path = isStaging() ? "/Applications/XPipe PTB.app" : "/Applications/XPipe.app";
|
||||
path = stage ? "/Applications/XPipe PTB.app" : "/Applications/XPipe.app";
|
||||
}
|
||||
|
||||
return path;
|
||||
|
|
14
gradle/gradle_scripts/dev_default.properties
Normal file
14
gradle/gradle_scripts/dev_default.properties
Normal 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
|
14
setup.sh
14
setup.sh
|
@ -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
|
Loading…
Reference in a new issue