Restructure gradle scripts

This commit is contained in:
Christopher Schnick 2022-12-18 18:04:51 +01:00
parent c38472e870
commit 6f912798af
22 changed files with 317 additions and 30 deletions

3
.gitmodules vendored
View file

@ -1,3 +0,0 @@
[submodule "deps"]
path = deps
url = https://github.com/xpipe-io/xpipe_java_deps

View file

@ -5,11 +5,11 @@ plugins {
id "org.moditect.gradleplugin" version "1.0.0-rc3"
}
apply from: "$projectDir/../deps/java.gradle"
apply from: "$projectDir/../deps/junit.gradle"
apply from: "$projectDir/../gradle_scripts/java.gradle"
apply from: "$projectDir/../gradle_scripts/junit.gradle"
System.setProperty('excludeExtensionLibrary', 'true')
apply from: "$projectDir/../deps/extension_test.gradle"
apply from: "$projectDir/../gradle_scripts/extension_test.gradle"
version = file('../misc/version').text
group = 'io.xpipe'
@ -35,4 +35,4 @@ configurations {
apply from: 'publish.gradle'
apply from: "$projectDir/../deps/publish-base.gradle"
apply from: "$projectDir/../gradle_scripts/publish-base.gradle"

View file

@ -5,8 +5,8 @@ plugins {
id "org.moditect.gradleplugin" version "1.0.0-rc3"
}
apply from: "$projectDir/../deps/java.gradle"
apply from: "$projectDir/../deps/lombok.gradle"
apply from: "$projectDir/../gradle_scripts/java.gradle"
apply from: "$projectDir/../gradle_scripts/lombok.gradle"
dependencies {
}
@ -24,4 +24,4 @@ dependencies {
}
apply from: 'publish.gradle'
apply from: "$projectDir/../deps/publish-base.gradle"
apply from: "$projectDir/../gradle_scripts/publish-base.gradle"

View file

@ -53,8 +53,8 @@ public class BeaconProxyImpl extends ProxyProvider {
var proxyNode = JacksonMapper.getDefault().valueToTree(proxy);
var inputNode = JacksonMapper.getDefault().valueToTree(object);
var localNode = JacksonMapper.getDefault().valueToTree(ShellStore.local());
replace(inputNode, node -> node.equals(proxyNode) ? Optional.of(localNode) : Optional.empty());
return (T) JacksonMapper.getDefault().treeToValue(inputNode, object.getClass());
var result = replace(inputNode, node -> node.equals(proxyNode) ? Optional.of(localNode) : Optional.empty());
return (T) JacksonMapper.getDefault().treeToValue(result, object.getClass());
}
@Override

View file

@ -6,7 +6,6 @@ import io.xpipe.core.impl.LocalStore;
import io.xpipe.core.process.ShellProcessControl;
import io.xpipe.core.process.ShellTypes;
import io.xpipe.core.util.XPipeInstallation;
import lombok.experimental.UtilityClass;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@ -14,7 +13,6 @@ import java.io.InputStreamReader;
/**
* Contains basic functionality to start, communicate, and stop a remote beacon server.
*/
@UtilityClass
public class BeaconServer {
public static boolean isRunning() {
@ -50,8 +48,7 @@ public class BeaconServer {
getDaemonDebugExecutable(installationBase), BeaconConfig.getDaemonArguments());
}
Process process =
Runtime.getRuntime().exec(ShellTypes.getPlatformDefault().executeCommandWithShell(command));
Process process = new ProcessBuilder(ShellTypes.getPlatformDefault().executeCommandListWithShell(command)).start();
printDaemonOutput(process, command);
return process;
}

View file

@ -5,9 +5,9 @@ plugins {
id "org.moditect.gradleplugin" version "1.0.0-rc3"
}
apply from: "$projectDir/../deps/java.gradle"
apply from: "$projectDir/../deps/lombok.gradle"
apply from: "$projectDir/../deps/junit.gradle"
apply from: "$projectDir/../gradle_scripts/java.gradle"
apply from: "$projectDir/../gradle_scripts/lombok.gradle"
apply from: "$projectDir/../gradle_scripts/junit.gradle"
compileJava {
options.compilerArgs << '-parameters'
@ -29,4 +29,4 @@ repositories {
}
apply from: 'publish.gradle'
apply from: "$projectDir/../deps/publish-base.gradle"
apply from: "$projectDir/../gradle_scripts/publish-base.gradle"

1
deps

@ -1 +0,0 @@
Subproject commit d0578cfb68e7668423988fafa96659eaae219a0e

View file

@ -5,9 +5,9 @@ plugins {
id "org.moditect.gradleplugin" version "1.0.0-rc3"
}
apply from: "$projectDir/../deps/java.gradle"
apply from: "$projectDir/../deps/javafx.gradle"
apply from: "$projectDir/../deps/lombok.gradle"
apply from: "$projectDir/../gradle_scripts/java.gradle"
apply from: "$projectDir/../gradle_scripts/javafx.gradle"
apply from: "$projectDir/../gradle_scripts/lombok.gradle"
configurations {
compileOnly.extendsFrom(dep)
@ -39,4 +39,4 @@ dependencies {
apply from: 'publish.gradle'
apply from: "$projectDir/../deps/publish-base.gradle"
apply from: "$projectDir/../gradle_scripts/publish-base.gradle"

View file

@ -43,14 +43,13 @@ public interface DataStoreProvider {
return true;
}
default void storageInit() throws Exception {
}
String queryInformationString(DataStore store, int length) throws Exception;
public String toSummaryString(DataStore store, int length);
default boolean isHidden() {
return false;
}
default String i18n(String key) {
return I18n.get(getId() + "." + key);
}

View file

@ -71,7 +71,7 @@ public abstract class Comp<S extends CompStructure<?>> {
}
public Comp<S> grow(boolean width, boolean height) {
return apply(GrowAugment.create(false, false));
return apply(GrowAugment.create(width, height));
}
public Comp<S> shortcut(KeyCombination shortcut, Consumer<S> con) {

View file

@ -10,6 +10,7 @@ import javafx.collections.ObservableList;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
@SuppressWarnings("unchecked")
public class PlatformThread {
@ -271,4 +272,20 @@ public class PlatformThread {
Platform.runLater(r);
}
}
public static void runLaterBlocking(Runnable r) {
if (!Platform.isFxApplicationThread()) {
CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(() -> {
r.run();
latch.countDown();
});
try {
latch.await();
} catch (InterruptedException ignored) {
}
} else {
r.run();
}
}
}

View file

@ -1,11 +1,19 @@
package io.xpipe.extension.prefs;
import com.dlsc.formsfx.model.structure.Field;
import javafx.beans.value.ObservableBooleanValue;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.stream.Collectors;
public abstract class PrefsProvider {
protected <T extends Field<?>> T editable(T o, ObservableBooleanValue v) {
o.editableProperty().bind(v);
return o;
}
private static Set<PrefsProvider> ALL;
public static void init(ModuleLayer layer) {

7
gradle_scripts/LICENSE Normal file
View file

@ -0,0 +1,7 @@
Copyright 2022 Christopher Schnick
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

14
gradle_scripts/README.md Normal file
View file

@ -0,0 +1,14 @@
## Gradle Scripts
This directory contains helper scripts and Java module generation rules for dependencies used by various X-Pipe gradle projects.
It also contains various other types of shared build script components that are useful.
As the [jlink](https://docs.oracle.com/en/java/javase/17/docs/specs/man/jlink.html) tool
effectively requires proper modules as inputs but many established java
libraries did not add proper support yet, using an approach like this is required.
The modules are generated with the help of [moditect](https://github.com/moditect/moditect-gradle-plugin).
The generated `module-info.java` file contains the necessary declarations to make a library work.
While gradle already has a [similar system](https://docs.gradle.org/current/userguide/platforms.html)
to better share dependencies, this system is lacking several features.
For one, it can't pass any other customizations to the build that are required by the dependencies,
e.g. compiler parameters or annotation processors.

View file

@ -0,0 +1,64 @@
configurations {
dep
}
dependencies {
dep files("$buildDir/generated-modules/commons-lang3-3.12.0.jar")
dep files("$buildDir/generated-modules/commons-io-2.11.0.jar")
dep files("$buildDir/generated-modules/commons-math3-3.6.1.jar")
dep 'org.apache.commons:commons-compress:1.21'
dep 'commons-codec:commons-codec:1.15'
}
addDependenciesModuleInfo {
overwriteExistingFiles = true
jdepsExtraArgs = ['-q']
outputDirectory = file("$buildDir/generated-modules")
modules {
module {
artifact 'org.apache.commons:commons-lang3:3.12.0'
moduleInfoSource = '''
module org.apache.commons.lang3 {
exports org.apache.commons.lang3;
exports org.apache.commons.lang3.function;
exports org.apache.commons.lang3.arch;
exports org.apache.commons.lang3.reflect;
exports org.apache.commons.lang3.builder;
exports org.apache.commons.lang3.text;
exports org.apache.commons.lang3.tuple;
exports org.apache.commons.lang3.math;
}
'''
}
module {
artifact 'commons-io:commons-io:2.11.0'
moduleInfoSource = '''
module org.apache.commons.io {
exports org.apache.commons.io;
exports org.apache.commons.io.file;
exports org.apache.commons.io.input;
exports org.apache.commons.io.filefilter;
exports org.apache.commons.io.output;
}
'''
}
module {
artifact 'org.apache.commons:commons-collections4:4.4'
moduleInfoSource = '''
module org.apache.commons.collections4 {
exports org.apache.commons.collections4;
exports org.apache.commons.collections4.bidimap;
exports org.apache.commons.collections4.multimap;
}
'''
}
module {
artifact 'org.apache.commons:commons-math3:3.6.1'
moduleInfoSource = '''
module commons.math3 {
exports org.apache.commons.math3;
}
'''
}
}
}

View file

@ -0,0 +1,47 @@
apply from: "$buildscript.sourceFile/../junit.gradle"
def useExtension = System.getProperty('excludeExtensionLibrary') == null
dependencies {
testImplementation project(':api')
testImplementation project(':core')
if (useExtension) {
testImplementation project(':extension')
}
testImplementation "org.openjfx:javafx-base:18:win"
testImplementation "org.openjfx:javafx-controls:18:win"
testImplementation "org.openjfx:javafx-graphics:18:win"
}
def attachDebugger = System.getProperty('idea.debugger.dispatch.addr') != null
def daemonCommand = attachDebugger ? ':app:runAttachedDebugger' : ':app:run'
test {
workingDir = rootDir
jvmArgs += ["--enable-preview", "-Xmx2g"]
// Daemon properties
systemProperty "io.xpipe.beacon.daemonArgs", "-Dio.xpipe.app.mode=tray" +
" -Dio.xpipe.beacon.port=21723" +
" -Dio.xpipe.app.dataDir=$projectDir/local/" +
" -Dio.xpipe.storage.persist=false" +
" -Dio.xpipe.app.writeSysOut=true" +
" -Dio.xpipe.app.writeLogs=false" +
" -Dio.xpipe.beacon.printMessages=false" +
" -Dio.xpipe.app.logLevel=trace"
if (findProject(':app') != null) {
systemProperty "io.xpipe.beacon.customDaemonCommand", "cmd.exe /c start \"\"X-Pipe Debug\"\" /i \"$rootDir\\gradlew.bat\" --console=plain $daemonCommand"
}
// Client properties
// systemProperty 'io.xpipe.beacon.printMessages', "true"
systemProperty 'io.xpipe.beacon.printDaemonOutput', "false"
systemProperty "io.xpipe.beacon.port", "21723"
systemProperty "io.xpipe.beacon.launchDebugDaemon", "true"
systemProperty "io.xpipe.beacon.attachDebuggerToDaemon", "$daemonCommand"
}

View file

@ -0,0 +1,28 @@
tasks.withType(JavaCompile).configureEach {
sourceCompatibility = JavaVersion.VERSION_19
targetCompatibility = JavaVersion.VERSION_19
modularity.inferModulePath = true
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:unchecked"
options.compilerArgs << "--enable-preview"
options.compilerArgs << "-implicit:none"
options.incremental = false
}
tasks.withType(JavaExec).configureEach {
modularity.inferModulePath = true
}
javadoc{
source = sourceSets.main.allJava
options {
addStringOption('-release', '19')
addStringOption('link', 'https://docs.oracle.com/en/java/javase/19/docs/api/')
addBooleanOption('html5', true)
addStringOption('Xdoclint:none', '-quiet')
}
}
repositories {
mavenCentral()
}

View file

@ -0,0 +1,23 @@
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
def currentOS = DefaultNativePlatform.currentOperatingSystem;
def platform
if (currentOS.isWindows()) {
platform = 'win'
} else if (currentOS.isLinux()) {
platform = 'linux'
} else if (currentOS.isMacOsX()) {
platform = 'mac'
}
configurations {
dep
}
dependencies {
dep "org.openjfx:javafx-base:19:${platform}"
dep "org.openjfx:javafx-controls:19:${platform}"
dep "org.openjfx:javafx-graphics:19:${platform}"
dep "org.openjfx:javafx-media:19:${platform}"
dep "org.openjfx:javafx-web:19:${platform}"
}

View file

@ -0,0 +1,26 @@
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
testRuntimeOnly "org.junit.platform:junit-platform-launcher"
}
test {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
showExceptions = true
showStandardStreams = true
}
}
sourceSets {
test {
if (System.getProperty('idea.active') == null) {
java {
srcDirs = []
}
}
output.resourcesDir("$buildDir/classes/java/test")
}
}

Binary file not shown.

View file

@ -0,0 +1,14 @@
repositories {
mavenCentral()
flatDir {
dirs file(buildscript.sourceFile).parent
}
}
dependencies {
// A forked version of Lombok because the official one doesn't support Java 19 yet
compileOnly name: 'lombok-jdk19-20221010'
annotationProcessor name: 'lombok-jdk19-20221010'
testCompileOnly name: 'lombok-jdk19-20221010'
testAnnotationProcessor name: 'lombok-jdk19-20221010'
}

View file

@ -0,0 +1,47 @@
java {
withJavadocJar()
withSourcesJar()
}
def isSnapshot = project.getVersion().endsWith('SNAPSHOT')
def repoUrl = isSnapshot ? 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
: 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
def user = project.hasProperty('sonatypeUsername') ? project.property('sonatypeUsername') : System.getenv('SONATYPE_USERNAME')
def pass = project.hasProperty('sonatypePassword') ? project.property('sonatypePassword') : System.getenv('SONATYPE_PASSWORD')
if (!isSnapshot) {
publish.finalizedBy(rootProject.getTasks().getByName('closeAndReleaseRepository'))
}
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
publishing {
repositories {
maven {
setUrl repoUrl
credentials {
setUsername user
setPassword pass
}
}
}
}
def signingKeyId = project.hasProperty('signingKeyId') ? project.property("signingKeyId") : System.getenv('GPG_KEY_ID')
def signingKey = project.hasProperty('signingKeyFile') ? file(project.property("signingKeyFile")).text : System.getenv('GPG_KEY')
def signingPassword = project.hasProperty('signingPassword') ? project.property("signingPassword") : System.getenv('GPG_KEY_PASSWORD')
signing {
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword != null ? signingPassword : '')
sign publishing.publications.mavenJava
}
nexusStaging {
serverUrl = "https://s01.oss.sonatype.org/service/local/"
packageGroup = "io.xpipe"
username = user
password = pass
}