diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..f9f86c2 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,16 @@ +name: CI +on: + push: + branches: [ master ] +jobs: + build: + runs-on: woryzen + 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 publishMavenPublicationToGiteaRepository diff --git a/Jenkinsfile b/Jenkinsfile index d454325..4f5254b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,13 +6,24 @@ pipeline { stages { stage("Build") { steps { - sh "./gradlew clean assemble build" - junit testResults: "build/test-results/test/*.xml" - 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', - allowEmptyArchive: true, - fingerprint: true, - onlyIfSuccessful: true + sh "./gradlew build" + } + 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 + archiveArtifacts artifacts: '**/build/libs/*.jar,wson-cli/build/libs/wson-cli', + allowEmptyArchive: false, + fingerprint: true, + onlyIfSuccessful: true + } } } stage("Publish") { diff --git a/benchmark/build.gradle b/benchmark/build.gradle index 0d8eef1..6ab56ff 100644 --- a/benchmark/build.gradle +++ b/benchmark/build.gradle @@ -18,7 +18,6 @@ dependencies { implementation catalog.jwo implementation catalog.xz - implementation catalog.jcommander implementation catalog.jackson.databind runtimeOnly project(':test-utils') diff --git a/build.gradle b/build.gradle index 26a2b32..5a61e16 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,7 @@ plugins { + id 'jacoco' id 'maven-publish' + alias catalog.plugins.multi.release.jar alias catalog.plugins.envelope apply false alias catalog.plugins.lombok apply false } @@ -15,7 +17,7 @@ allprojects { java { modularity.inferModulePath = true toolchain { - languageVersion = JavaLanguageVersion.of(17) + languageVersion = JavaLanguageVersion.of(21) vendor = JvmVendorSpec.GRAAL_VM } } @@ -26,9 +28,8 @@ allprojects { repositories { maven { - url = "https://woggioni.net/mvn/" + url = getProperty('gitea.maven.url') content { - includeGroup 'com.beust' includeGroup 'com.lys' includeGroup 'net.woggioni' } @@ -36,6 +37,15 @@ allprojects { mavenCentral() } + pluginManager.withPlugin('jacoco') { + test { + finalizedBy jacocoTestReport + } + jacocoTestReport { + dependsOn test + } + } + dependencies { implementation catalog.xz @@ -59,6 +69,30 @@ allprojects { } } } + + pluginManager.withPlugin('maven-publish') { + publishing { + repositories { + maven { + url = 'https://mvn.woggioni.net/' + } + maven { + name = "Gitea" + url = uri(getProperty('gitea.maven.url')) + + credentials(HttpHeaderCredentials) { + name = "Authorization" + value = "token ${System.getenv()["PUBLISHER_TOKEN"]}" + } + + authentication { + header(HttpHeaderAuthentication) + } + + } + } + } + } } @@ -79,12 +113,11 @@ compileJava { options.compilerArgs << '-parameters' } +ext { + setProperty('jpms.module.name', 'net.woggioni.wson') +} + publishing { - repositories { - maven { - url = "https://mvn.woggioni.net/" - } - } publications { maven(MavenPublication) { from(components["java"]) diff --git a/gradle.properties b/gradle.properties index 1312efa..0297ffb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,5 @@ -wson.version = 2023.11.01 +wson.version = 2024.04.04 +lys.version = 2024.04.04 +gitea.maven.url = https://gitea.woggioni.net/api/packages/woggioni/maven -lys.version = 2023.10.31 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c1962a7..7f93135 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c30b486..a80b22c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index aeb74cb..0adc8e1 100755 --- a/gradlew +++ b/gradlew @@ -83,7 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 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. MAX_FD=maximum @@ -130,10 +131,13 @@ location of your Java installation." fi else 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 location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. diff --git a/settings.gradle b/settings.gradle index 0759d5c..a5f683d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { repositories { maven { - url = 'https://woggioni.net/mvn/' + url = getProperty('gitea.maven.url') content { includeGroup 'net.woggioni.gradle' includeGroup 'net.woggioni.gradle.lombok' @@ -19,7 +19,7 @@ pluginManagement { dependencyResolutionManagement { repositories { maven { - url = 'https://woggioni.net/mvn/' + url = getProperty('gitea.maven.url') content { includeGroup 'com.lys' } diff --git a/src/main/java/module-info.java b/src/main/java9/module-info.java similarity index 100% rename from src/main/java/module-info.java rename to src/main/java9/module-info.java diff --git a/wcfg/build.gradle b/wcfg/build.gradle index f2351fb..ec42508 100644 --- a/wcfg/build.gradle +++ b/wcfg/build.gradle @@ -1,5 +1,7 @@ plugins { id 'antlr' + id 'jacoco' + alias catalog.plugins.multi.release.jar } configurations { @@ -20,3 +22,7 @@ generateGrammarSource { maxHeapSize = "64m" arguments += ['-package', 'net.woggioni.wson.wcfg'] } + +ext { + setProperty('jpms.module.name', 'net.woggioni.wson.wcfg') +} \ No newline at end of file diff --git a/wcfg/src/main/java/net/woggioni/wson/wcfg/CompositeObjectValue.java b/wcfg/src/main/java/net/woggioni/wson/wcfg/CompositeObjectValue.java index d938974..7075db8 100644 --- a/wcfg/src/main/java/net/woggioni/wson/wcfg/CompositeObjectValue.java +++ b/wcfg/src/main/java/net/woggioni/wson/wcfg/CompositeObjectValue.java @@ -25,7 +25,8 @@ public class CompositeObjectValue implements ObjectValue { ObjectValue result = ObjectValue.newInstance(cfg); List identities = new ArrayList<>(); for (Value element : elements) { - if (element instanceof CompositeObjectValue compositeObjectValue) { + if (element instanceof CompositeObjectValue) { + CompositeObjectValue compositeObjectValue = (CompositeObjectValue) element; boolean differenceFound = false; for (int i = 0; i < compositeObjectValue.elements.size(); i++) { ObjectValue objectValue = (ObjectValue) compositeObjectValue.elements.get(i); diff --git a/wcfg/src/main/java/net/woggioni/wson/wcfg/ListenerImpl.java b/wcfg/src/main/java/net/woggioni/wson/wcfg/ListenerImpl.java index 2a17d8e..2112132 100644 --- a/wcfg/src/main/java/net/woggioni/wson/wcfg/ListenerImpl.java +++ b/wcfg/src/main/java/net/woggioni/wson/wcfg/ListenerImpl.java @@ -89,9 +89,11 @@ class ListenerImpl implements WCFGListener { if (value == null) { List objects = elements.stream() .map(it -> { - if (it instanceof ObjectValue ov) + if (it instanceof ObjectValue) { + ObjectValue ov = (ObjectValue) it; return ov; - else if (it instanceof ValueHolder vh) { + } else if (it instanceof ValueHolder) { + ValueHolder vh = (ValueHolder) it; return (ObjectValue) vh.getDelegate(); } else { throw newThrowable(RuntimeException.class, ""); @@ -108,32 +110,39 @@ class ListenerImpl implements WCFGListener { private void add2Last(Value value) { StackLevel last = tail(stack); - if (last instanceof ArrayStackLevel asl) { + if (last instanceof ArrayStackLevel) { + ArrayStackLevel asl = (ArrayStackLevel) last; asl.value.add(value); - if (value instanceof ValueHolder holder) { + if (value instanceof ValueHolder) { + ValueHolder holder = (ValueHolder) value; Value arrayValue = asl.getValue(); int index = arrayValue.size() - 1; 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; Value objectValue = osl.getValue(); objectValue.put(key, value); - if (value instanceof ValueHolder holder) { + if (value instanceof ValueHolder) { + ValueHolder holder = (ValueHolder) value; holder.addDeleter(() -> { objectValue.put(key, holder.getDelegate()); }); } - } else if (last instanceof ExpressionStackLevel esl) { + } else if (last instanceof ExpressionStackLevel) { + ExpressionStackLevel esl = (ExpressionStackLevel) last; List values = esl.elements; int index = values.size(); values.add(value); - if (value instanceof ValueHolder holder) { + if (value instanceof ValueHolder) { + ValueHolder holder = (ValueHolder) value; holder.addDeleter(() -> { values.set(index, holder.getDelegate()); }); } - } else if (last instanceof ExportStackLevel esl) { + } else if (last instanceof ExportStackLevel) { + ExportStackLevel esl = (ExportStackLevel) last; esl.setValue(value); } } @@ -320,7 +329,8 @@ class ListenerImpl implements WCFGListener { @Override public void exitExport(WCFGParser.ExportContext ctx) { result = pop().getValue(); - if (result instanceof ValueHolder holder) { + if (result instanceof ValueHolder) { + ValueHolder holder = (ValueHolder) result; holder.addDeleter(() -> { result = holder.getDelegate(); }); diff --git a/wcfg/src/main/java/module-info.java b/wcfg/src/main/java9/module-info.java similarity index 100% rename from wcfg/src/main/java/module-info.java rename to wcfg/src/main/java9/module-info.java diff --git a/wson-cli/build.gradle b/wson-cli/build.gradle index 2c90938..f9a3a5d 100644 --- a/wson-cli/build.gradle +++ b/wson-cli/build.gradle @@ -1,13 +1,15 @@ plugins { id 'maven-publish' + id 'jacoco' + alias catalog.plugins.multi.release.jar alias catalog.plugins.envelope alias catalog.plugins.graalvm.native.image alias catalog.plugins.sambal } + import net.woggioni.gradle.graalvm.NativeImageTask import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform - dependencies { implementation catalog.jwo implementation catalog.picocli @@ -59,16 +61,15 @@ Provider nativeImageTaskProvider = tasks.named("nativeImage") { buildStaticImage = true } +tasks.named(BasePlugin.ASSEMBLE_TASK_NAME, Task) { + inputs.files(nativeImageTaskProvider) +} + artifacts { archives nativeImageTaskProvider.map(NativeImageTask.&getOutputFile) } publishing { - repositories { - maven { - url = "https://mvn.woggioni.net/" - } - } publications { myDistribution(MavenPublication) { artifact envelopeJar diff --git a/wson-cli/src/main/java/net/woggioni/wson/cli/SerializationFormat.java b/wson-cli/src/main/java/net/woggioni/wson/cli/SerializationFormat.java index b94e47c..974a1d0 100644 --- a/wson-cli/src/main/java/net/woggioni/wson/cli/SerializationFormat.java +++ b/wson-cli/src/main/java/net/woggioni/wson/cli/SerializationFormat.java @@ -21,7 +21,7 @@ enum SerializationFormat { .filter(sf -> Objects.equals(sf.name, value)) .findFirst() .orElseThrow(() -> { - var availableValues = Stream.of( + String availableValues = Stream.of( JSON, JBON ).map(SerializationFormat::name).collect(Collectors.joining(", ")); diff --git a/wson-cli/src/main/java/net/woggioni/wson/cli/WsonCli.java b/wson-cli/src/main/java/net/woggioni/wson/cli/WsonCli.java index 985b901..f21ae62 100644 --- a/wson-cli/src/main/java/net/woggioni/wson/cli/WsonCli.java +++ b/wson-cli/src/main/java/net/woggioni/wson/cli/WsonCli.java @@ -11,7 +11,7 @@ import picocli.CommandLine; subcommands = {WsonCommand.class, WcfgCommand.class}) public class WsonCli implements Runnable { 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) -> { log.error(ex.getMessage(), ex); return CommandLine.ExitCode.SOFTWARE; diff --git a/wson-cli/src/main/java/module-info.java b/wson-cli/src/main/java9/module-info.java similarity index 100% rename from wson-cli/src/main/java/module-info.java rename to wson-cli/src/main/java9/module-info.java