Compare commits

...

4 Commits

Author SHA1 Message Date
bd1bc9c997 enabled Gradle build cache
Some checks failed
CI / build (push) Failing after 3m1s
2025-01-21 12:50:34 +08:00
29b5454459 bump Gradle and lys-catalog versions
All checks were successful
CI / build (push) Successful in 3m30s
2025-01-20 23:00:02 +08:00
069e55aeb0 added publications
All checks were successful
CI / build (push) Successful in 42s
2024-04-04 09:28:42 +08:00
19162b5b97 migrated to gitea
All checks were successful
CI / build (push) Successful in 48s
2024-04-04 08:39:31 +08:00
19 changed files with 148 additions and 62 deletions

View File

@@ -0,0 +1,16 @@
name: CI
on:
push:
branches: [ master ]
jobs:
build:
runs-on: hostinger
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Execute Gradle build
env:
PUBLISHER_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
run: ./gradlew build publish

19
Jenkinsfile vendored
View File

@@ -6,15 +6,26 @@ pipeline {
stages { stages {
stage("Build") { stage("Build") {
steps { steps {
sh "./gradlew clean assemble build" sh "./gradlew build"
junit testResults: "build/test-results/test/*.xml" }
post {
always {
junit '**/build/test-results/test/*.xml'
}
success {
jacoco(
execPattern: '**/build/jacoco/*.exec',
classPattern: '**/build/classes/java/main',
sourcePattern: '**/src/main'
)
javadoc javadocDir: "build/docs/javadoc", keepAll: true javadoc javadocDir: "build/docs/javadoc", keepAll: true
archiveArtifacts artifacts: 'build/libs/*.jar,benchmark/build/libs/*.jar,wson-cli/build/libs/wson-cli-envelope-*.jar,wson-cli/build/libs/wson-cli', archiveArtifacts artifacts: '**/build/libs/*.jar,wson-cli/build/libs/wson-cli',
allowEmptyArchive: true, allowEmptyArchive: false,
fingerprint: true, fingerprint: true,
onlyIfSuccessful: true onlyIfSuccessful: true
} }
} }
}
stage("Publish") { stage("Publish") {
steps { steps {
sh "./gradlew publish" sh "./gradlew publish"

View File

@@ -18,7 +18,6 @@ dependencies {
implementation catalog.jwo implementation catalog.jwo
implementation catalog.xz implementation catalog.xz
implementation catalog.jcommander
implementation catalog.jackson.databind implementation catalog.jackson.databind
runtimeOnly project(':test-utils') runtimeOnly project(':test-utils')

View File

@@ -1,5 +1,7 @@
plugins { plugins {
id 'jacoco'
id 'maven-publish' id 'maven-publish'
alias catalog.plugins.multi.release.jar
alias catalog.plugins.envelope apply false alias catalog.plugins.envelope apply false
alias catalog.plugins.lombok apply false alias catalog.plugins.lombok apply false
} }
@@ -15,8 +17,8 @@ allprojects {
java { java {
modularity.inferModulePath = true modularity.inferModulePath = true
toolchain { toolchain {
languageVersion = JavaLanguageVersion.of(17) languageVersion = JavaLanguageVersion.of(21)
vendor = JvmVendorSpec.GRAAL_VM vendor = JvmVendorSpec.ORACLE
} }
} }
@@ -26,9 +28,8 @@ allprojects {
repositories { repositories {
maven { maven {
url = "https://woggioni.net/mvn/" url = getProperty('gitea.maven.url')
content { content {
includeGroup 'com.beust'
includeGroup 'com.lys' includeGroup 'com.lys'
includeGroup 'net.woggioni' includeGroup 'net.woggioni'
} }
@@ -36,6 +37,15 @@ allprojects {
mavenCentral() mavenCentral()
} }
pluginManager.withPlugin('jacoco') {
test {
finalizedBy jacocoTestReport
}
jacocoTestReport {
dependsOn test
}
}
dependencies { dependencies {
implementation catalog.xz implementation catalog.xz
@@ -59,6 +69,27 @@ allprojects {
} }
} }
} }
pluginManager.withPlugin('maven-publish') {
publishing {
repositories {
maven {
name = "Gitea"
url = uri(getProperty('gitea.maven.url'))
credentials(HttpHeaderCredentials) {
name = "Authorization"
value = "token ${System.getenv()["PUBLISHER_TOKEN"]}"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}
}
} }
@@ -79,12 +110,11 @@ compileJava {
options.compilerArgs << '-parameters' options.compilerArgs << '-parameters'
} }
ext {
setProperty('jpms.module.name', 'net.woggioni.wson')
}
publishing { publishing {
repositories {
maven {
url = "https://mvn.woggioni.net/"
}
}
publications { publications {
maven(MavenPublication) { maven(MavenPublication) {
from(components["java"]) from(components["java"])

View File

@@ -1,4 +1,7 @@
wson.version = 2023.11.01 org.gradle.caching=true
wson.version = 2025.01.21
lys.version = 2025.01.17
gitea.maven.url = https://gitea.woggioni.net/api/packages/woggioni/maven
lys.version = 2023.10.31

Binary file not shown.

View File

@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

22
gradlew vendored
View File

@@ -83,7 +83,8 @@ done
# This is normally unused # This is normally unused
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -130,10 +131,13 @@ location of your Java installation."
fi fi
else else
JAVACMD=java JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
@@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045 # shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
@@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045 # shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@@ -198,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command; # Collect all arguments for the java command:
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# shell script including quotes and variable substitutions, so put them in # and any embedded shellness will be escaped.
# double quotes to make sure that they get re-expanded; and # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# * put everything else in single quotes, so that it's not re-expanded. # treated as '${Hostname}' itself on the command line.
set -- \ set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \ "-Dorg.gradle.appname=$APP_BASE_NAME" \

20
gradlew.bat vendored
View File

@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute if %ERRORLEVEL% equ 0 goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute if exist "%JAVA_EXE%" goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail

View File

@@ -1,7 +1,7 @@
pluginManagement { pluginManagement {
repositories { repositories {
maven { maven {
url = 'https://woggioni.net/mvn/' url = getProperty('gitea.maven.url')
content { content {
includeGroup 'net.woggioni.gradle' includeGroup 'net.woggioni.gradle'
includeGroup 'net.woggioni.gradle.lombok' includeGroup 'net.woggioni.gradle.lombok'
@@ -19,7 +19,7 @@ pluginManagement {
dependencyResolutionManagement { dependencyResolutionManagement {
repositories { repositories {
maven { maven {
url = 'https://woggioni.net/mvn/' url = getProperty('gitea.maven.url')
content { content {
includeGroup 'com.lys' includeGroup 'com.lys'
} }

View File

@@ -1,5 +1,7 @@
plugins { plugins {
id 'antlr' id 'antlr'
id 'jacoco'
alias catalog.plugins.multi.release.jar
} }
configurations { configurations {
@@ -20,3 +22,7 @@ generateGrammarSource {
maxHeapSize = "64m" maxHeapSize = "64m"
arguments += ['-package', 'net.woggioni.wson.wcfg'] arguments += ['-package', 'net.woggioni.wson.wcfg']
} }
ext {
setProperty('jpms.module.name', 'net.woggioni.wson.wcfg')
}

View File

@@ -25,7 +25,8 @@ public class CompositeObjectValue implements ObjectValue {
ObjectValue result = ObjectValue.newInstance(cfg); ObjectValue result = ObjectValue.newInstance(cfg);
List<ValueIdentity> identities = new ArrayList<>(); List<ValueIdentity> identities = new ArrayList<>();
for (Value element : elements) { for (Value element : elements) {
if (element instanceof CompositeObjectValue compositeObjectValue) { if (element instanceof CompositeObjectValue) {
CompositeObjectValue compositeObjectValue = (CompositeObjectValue) element;
boolean differenceFound = false; boolean differenceFound = false;
for (int i = 0; i < compositeObjectValue.elements.size(); i++) { for (int i = 0; i < compositeObjectValue.elements.size(); i++) {
ObjectValue objectValue = (ObjectValue) compositeObjectValue.elements.get(i); ObjectValue objectValue = (ObjectValue) compositeObjectValue.elements.get(i);

View File

@@ -89,9 +89,11 @@ class ListenerImpl implements WCFGListener {
if (value == null) { if (value == null) {
List<ObjectValue> objects = elements.stream() List<ObjectValue> objects = elements.stream()
.map(it -> { .map(it -> {
if (it instanceof ObjectValue ov) if (it instanceof ObjectValue) {
ObjectValue ov = (ObjectValue) it;
return ov; return ov;
else if (it instanceof ValueHolder vh) { } else if (it instanceof ValueHolder) {
ValueHolder vh = (ValueHolder) it;
return (ObjectValue) vh.getDelegate(); return (ObjectValue) vh.getDelegate();
} else { } else {
throw newThrowable(RuntimeException.class, ""); throw newThrowable(RuntimeException.class, "");
@@ -108,32 +110,39 @@ class ListenerImpl implements WCFGListener {
private void add2Last(Value value) { private void add2Last(Value value) {
StackLevel last = tail(stack); StackLevel last = tail(stack);
if (last instanceof ArrayStackLevel asl) { if (last instanceof ArrayStackLevel) {
ArrayStackLevel asl = (ArrayStackLevel) last;
asl.value.add(value); asl.value.add(value);
if (value instanceof ValueHolder holder) { if (value instanceof ValueHolder) {
ValueHolder holder = (ValueHolder) value;
Value arrayValue = asl.getValue(); Value arrayValue = asl.getValue();
int index = arrayValue.size() - 1; int index = arrayValue.size() - 1;
holder.addDeleter(() -> arrayValue.set(index, holder.getDelegate())); holder.addDeleter(() -> arrayValue.set(index, holder.getDelegate()));
} }
} else if (last instanceof ObjectStackLevel osl) { } else if (last instanceof ObjectStackLevel) {
ObjectStackLevel osl = (ObjectStackLevel) last;
String key = osl.currentKey; String key = osl.currentKey;
Value objectValue = osl.getValue(); Value objectValue = osl.getValue();
objectValue.put(key, value); objectValue.put(key, value);
if (value instanceof ValueHolder holder) { if (value instanceof ValueHolder) {
ValueHolder holder = (ValueHolder) value;
holder.addDeleter(() -> { holder.addDeleter(() -> {
objectValue.put(key, holder.getDelegate()); objectValue.put(key, holder.getDelegate());
}); });
} }
} else if (last instanceof ExpressionStackLevel esl) { } else if (last instanceof ExpressionStackLevel) {
ExpressionStackLevel esl = (ExpressionStackLevel) last;
List<Value> values = esl.elements; List<Value> values = esl.elements;
int index = values.size(); int index = values.size();
values.add(value); values.add(value);
if (value instanceof ValueHolder holder) { if (value instanceof ValueHolder) {
ValueHolder holder = (ValueHolder) value;
holder.addDeleter(() -> { holder.addDeleter(() -> {
values.set(index, holder.getDelegate()); values.set(index, holder.getDelegate());
}); });
} }
} else if (last instanceof ExportStackLevel esl) { } else if (last instanceof ExportStackLevel) {
ExportStackLevel esl = (ExportStackLevel) last;
esl.setValue(value); esl.setValue(value);
} }
} }
@@ -320,7 +329,8 @@ class ListenerImpl implements WCFGListener {
@Override @Override
public void exitExport(WCFGParser.ExportContext ctx) { public void exitExport(WCFGParser.ExportContext ctx) {
result = pop().getValue(); result = pop().getValue();
if (result instanceof ValueHolder holder) { if (result instanceof ValueHolder) {
ValueHolder holder = (ValueHolder) result;
holder.addDeleter(() -> { holder.addDeleter(() -> {
result = holder.getDelegate(); result = holder.getDelegate();
}); });

View File

@@ -1,12 +1,15 @@
plugins { plugins {
id 'maven-publish' id 'maven-publish'
id 'jacoco'
alias catalog.plugins.multi.release.jar
alias catalog.plugins.envelope alias catalog.plugins.envelope
alias catalog.plugins.graalvm.native.image alias catalog.plugins.graalvm.native.image
alias catalog.plugins.sambal alias catalog.plugins.sambal
} }
import net.woggioni.gradle.graalvm.NativeImageTask
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import net.woggioni.gradle.graalvm.NativeImageTask
import net.woggioni.gradle.envelope.EnvelopeJarTask
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
dependencies { dependencies {
implementation catalog.jwo implementation catalog.jwo
@@ -54,23 +57,25 @@ configureNativeImage {
mergeConfiguration = true mergeConfiguration = true
} }
Provider<EnvelopeJarTask> envelopeJarTaskProvider = tasks.named('envelopeJar')
Provider<NativeImageTask> nativeImageTaskProvider = tasks.named("nativeImage") { Provider<NativeImageTask> nativeImageTaskProvider = tasks.named("nativeImage") {
useMusl = true useMusl = true
buildStaticImage = true buildStaticImage = true
} }
tasks.named(BasePlugin.ASSEMBLE_TASK_NAME, Task) {
inputs.files(nativeImageTaskProvider)
}
artifacts { artifacts {
archives nativeImageTaskProvider.map(NativeImageTask.&getOutputFile) archives nativeImageTaskProvider.map(NativeImageTask.&getOutputFile)
archives envelopeJarTaskProvider.map(EnvelopeJarTask.&getArchiveFile)
} }
publishing { publishing {
repositories {
maven {
url = "https://mvn.woggioni.net/"
}
}
publications { publications {
myDistribution(MavenPublication) { maven(MavenPublication) {
artifact envelopeJar artifact envelopeJar
def host = DefaultNativePlatform.host() def host = DefaultNativePlatform.host()
artifact( artifact(

View File

@@ -21,7 +21,7 @@ enum SerializationFormat {
.filter(sf -> Objects.equals(sf.name, value)) .filter(sf -> Objects.equals(sf.name, value))
.findFirst() .findFirst()
.orElseThrow(() -> { .orElseThrow(() -> {
var availableValues = Stream.of( String availableValues = Stream.of(
JSON, JSON,
JBON JBON
).map(SerializationFormat::name).collect(Collectors.joining(", ")); ).map(SerializationFormat::name).collect(Collectors.joining(", "));

View File

@@ -11,7 +11,7 @@ import picocli.CommandLine;
subcommands = {WsonCommand.class, WcfgCommand.class}) subcommands = {WsonCommand.class, WcfgCommand.class})
public class WsonCli implements Runnable { public class WsonCli implements Runnable {
public static void main(String[] args) { public static void main(String[] args) {
final var commandLine = new CommandLine(new WsonCli()); final CommandLine commandLine = new CommandLine(new WsonCli());
commandLine.setExecutionExceptionHandler((ex, cl, parseResult) -> { commandLine.setExecutionExceptionHandler((ex, cl, parseResult) -> {
log.error(ex.getMessage(), ex); log.error(ex.getMessage(), ex);
return CommandLine.ExitCode.SOFTWARE; return CommandLine.ExitCode.SOFTWARE;