From 5b59a2a65b0fb753d1d93ba99acc5b6812bf7505 Mon Sep 17 00:00:00 2001 From: Anton Vasetenkov Date: Thu, 15 Aug 2024 09:58:30 +1200 Subject: [PATCH 1/2] Merge Message operator tests --- .../CqlErrorsAndMessagingOperatorsTest.xml | 68 ++++++++++ .../CqlErrorsAndMessagingOperatorsTest.java | 124 +++++------------- .../CqlErrorsAndMessagingOperatorsTest.cql | 42 ------ 3 files changed, 99 insertions(+), 135 deletions(-) diff --git a/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlErrorsAndMessagingOperatorsTest.xml b/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlErrorsAndMessagingOperatorsTest.xml index 6c6cc03b4..ccb470906 100644 --- a/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlErrorsAndMessagingOperatorsTest.xml +++ b/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlErrorsAndMessagingOperatorsTest.xml @@ -18,5 +18,73 @@ Message(3 + 1, true, '400', 'Error', 'This is an error!') + + Message(1, true, '1', null, 'This is a message') + 1 + + + Message(null, true, '1', 'Message', 'This is a message') + null + + + Message(1, null, '1', 'Message', 'This is a message') + 1 + + + Message(1, true, null, 'Message', 'This is a message') + 1 + + + Message(1, true, '1', 'Message', null) + 1 + + + Message(null, true, '1', 'Warning', 'This is a message') + null + + + Message(1, null, '1', 'Warning', 'This is a message') + 1 + + + Message(1, true, null, 'Warning', 'This is a message') + 1 + + + Message(1, true, '1', 'Warning', null) + 1 + + + Message(null, true, '1', 'Trace', 'This is a message') + null + + + Message(1, null, '1', 'Trace', 'This is a message') + 1 + + + Message(1, true, null, 'Trace', 'This is a message') + 1 + + + Message(1, true, '1', 'Trace', null) + 1 + + + Message(null, true, '1', 'Error', 'This is a message') + + + + Message(1, null, '1', 'Error', 'This is a message') + 1 + + + Message(1, true, null, 'Error', 'This is a message') + + + + Message(1, true, '1', 'Error', null) + + diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlErrorsAndMessagingOperatorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlErrorsAndMessagingOperatorsTest.java index ace07ebb6..a812d30a3 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlErrorsAndMessagingOperatorsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlErrorsAndMessagingOperatorsTest.java @@ -1,14 +1,11 @@ package org.opencds.cqf.cql.engine.execution; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; -import java.util.*; import java.util.function.Supplier; import org.hl7.elm.r1.VersionedIdentifier; import org.junit.jupiter.api.Test; -import org.opencds.cqf.cql.engine.data.DataProvider; import org.opencds.cqf.cql.engine.data.SystemDataProvider; import org.opencds.cqf.cql.engine.elm.executing.obfuscate.PHIObfuscator; import org.opencds.cqf.cql.engine.elm.executing.obfuscate.RedactingPHIObfuscator; @@ -21,106 +18,36 @@ class CqlErrorsAndMessagingOperatorsTest extends CqlTestBase { @Test void message() { - var value = engine.expression(library, "TestMessageInfo").value(); - assertThat(value, is(1)); - // Assertions.assertEquals(result.toString(), "100: Test Message"); + engine.expression(library, "TestMessageInfo"); + assertEquals(getLastMessageFromEngine(), "100: Test Message"); - value = engine.expression(library, "TestMessageWarn").value(); - assertThat(value, is(2)); - // Assertions.assertEquals(result.toString(), "200: You have been warned!"); + engine.expression(library, "TestMessageWarn"); + assertEquals(getLastMessageFromEngine(), "200: You have been warned!"); - value = engine.expression(library, "TestMessageTrace").value(); - assertThat(value, is(new ArrayList(Arrays.asList(3, 4, 5)))); - // Assertions.assertEquals(result.toString(), "300: This is a trace\n[3, 4, 5]"); + engine.expression(library, "TestMessageTrace"); + assertEquals(getLastMessageFromEngine(), String.format("300: This is a trace%n")); - try { - value = engine.expression(library, "TestMessageError").value(); - } catch (RuntimeException re) { - assertEquals(re.getMessage(), String.format("400: This is an error!%n")); - } - - value = engine.expression(library, "TestMessageWithNullSeverity").value(); - assertThat(value, is(1)); - - value = engine.expression(library, "TestMessageWithNullSource").value(); - assertThat(value == null, is(true)); - - value = engine.expression(library, "TestMessageWithNullCondition").value(); - assertThat(value, is(1)); - - value = engine.expression(library, "TestMessageWithNullCode").value(); - assertThat(value, is(1)); - - value = engine.expression(library, "TestMessageWithNullMessage").value(); - assertThat(value, is(1)); - - value = engine.expression(library, "TestWarningWithNullSource").value(); - assertThat(value == null, is(true)); - - value = engine.expression(library, "TestWarningWithNullCondition").value(); - assertThat(value, is(1)); - - value = engine.expression(library, "TestWarningWithNullCode").value(); - assertThat(value, is(1)); - - value = engine.expression(library, "TestWarningWithNullMessage").value(); - assertThat(value, is(1)); - - value = engine.expression(library, "TestTraceWithNullSource").value(); - assertThat(value == null, is(true)); - - value = engine.expression(library, "TestTraceWithNullCondition").value(); - assertThat(value, is(1)); + var re = assertThrows(RuntimeException.class, () -> engine.expression(library, "TestMessageError")); + assertEquals(re.getMessage(), String.format("400: This is an error!%n")); - value = engine.expression(library, "TestTraceWithNullCode").value(); - assertThat(value, is(1)); + re = assertThrows(RuntimeException.class, () -> engine.expression(library, "TestErrorWithNullSource")); + assertEquals(re.getMessage(), String.format("1: This is a message%nnull")); - value = engine.expression(library, "TestTraceWithNullMessage").value(); - assertThat(value, is(1)); + re = assertThrows(RuntimeException.class, () -> engine.expression(library, "TestErrorWithNullCode")); + assertEquals(re.getMessage(), String.format("This is a message%n")); - try { - value = engine.expression(library, "TestErrorWithNullSource").value(); - assertThat(value == null, is(true)); - } catch (RuntimeException re) { - assertEquals(re.getMessage(), String.format("1: This is a message%nnull")); - } - - try { - value = engine.expression(library, "TestErrorWithNullCondition").value(); - assertThat(value, is(1)); - } catch (RuntimeException re) { - assertEquals(re.getMessage(), String.format("1: This is a message%n")); - } - - try { - value = engine.expression(library, "TestErrorWithNullCode").value(); - assertThat(value, is(1)); - } catch (RuntimeException re) { - assertEquals(re.getMessage(), String.format("This is a message%n")); - } - - try { - value = engine.expression(library, "TestErrorWithNullMessage").value(); - assertThat(value, is(1)); - } catch (RuntimeException re) { - assertEquals(re.getMessage(), String.format("1: null%n")); - } + re = assertThrows(RuntimeException.class, () -> engine.expression(library, "TestErrorWithNullMessage")); + assertEquals(re.getMessage(), String.format("1: null%n")); } @Test void obfuscation() { - Map dataProviders = new HashMap<>(); - dataProviders.put("urn:hl7-org:elm-types:r1", new CustomSystemDataProvider()); - Environment environment = new Environment(getLibraryManager(), dataProviders, null); + environment.registerDataProvider("urn:hl7-org:elm-types:r1", new CustomSystemDataProvider()); - CqlEngine e = new CqlEngine(environment); - try { - e.expression(library, "TestMessageObfuscation").value(); - } catch (RuntimeException result) { - assertEquals( - result.getMessage(), - String.format("400: This source should be redacted%n%s", RedactingPHIObfuscator.REDACTED_MESSAGE)); - } + var re = assertThrows(RuntimeException.class, () -> engine.expression(library, "TestMessageObfuscation")); + assertEquals( + re.getMessage(), + String.format("400: This source should be redacted%n%s", RedactingPHIObfuscator.REDACTED_MESSAGE)); } private static class CustomSystemDataProvider extends SystemDataProvider { @@ -129,4 +56,15 @@ public Supplier phiObfuscationSupplier() { return RedactingPHIObfuscator::new; } } + + /** + * @return The last message from the engine state. + */ + String getLastMessageFromEngine() { + var messages = engine.getState().getDebugResult().getMessages(); + if (messages.isEmpty()) { + return null; + } + return messages.get(messages.size() - 1).getMessage(); + } } diff --git a/Src/java/engine/src/test/resources/org/opencds/cqf/cql/engine/execution/CqlErrorsAndMessagingOperatorsTest.cql b/Src/java/engine/src/test/resources/org/opencds/cqf/cql/engine/execution/CqlErrorsAndMessagingOperatorsTest.cql index 376149864..389d3bd8c 100644 --- a/Src/java/engine/src/test/resources/org/opencds/cqf/cql/engine/execution/CqlErrorsAndMessagingOperatorsTest.cql +++ b/Src/java/engine/src/test/resources/org/opencds/cqf/cql/engine/execution/CqlErrorsAndMessagingOperatorsTest.cql @@ -6,51 +6,9 @@ define TestMessageTrace: Message({3, 4, 5}, true, '300', 'Trace', 'This is a tra define TestMessageError: Message(3 + 1, true, '400', 'Error', 'This is an error!') define TestMessageObfuscation: Message(Tuple { a: 1, b: Tuple { c: 2 } }, true, '400', 'Error', 'This source should be redacted') -define TestMessageWithNullSeverity: - Message(1, true, '1', null as String, 'This is a message') - -define TestMessageWithNullSource: - Message(null, true, '1', 'Message', 'This is a message') - -define TestMessageWithNullCondition: - Message(1, null, '1', 'Message', 'This is a message') - -define TestMessageWithNullCode: - Message(1, true, null, 'Message', 'This is a message') - -define TestMessageWithNullMessage: - Message(1, true, '1', 'Message', null) - -define TestWarningWithNullSource: - Message(null, true, '1', 'Warning', 'This is a message') - -define TestWarningWithNullCondition: - Message(1, null, '1', 'Warning', 'This is a message') - -define TestWarningWithNullCode: - Message(1, true, null, 'Warning', 'This is a message') - -define TestWarningWithNullMessage: - Message(1, true, '1', 'Warning', null) - -define TestTraceWithNullSource: - Message(null, true, '1', 'Trace', 'This is a message') - -define TestTraceWithNullCondition: - Message(1, null, '1', 'Trace', 'This is a message') - -define TestTraceWithNullCode: - Message(1, true, null, 'Trace', 'This is a message') - -define TestTraceWithNullMessage: - Message(1, true, '1', 'Trace', null) - define TestErrorWithNullSource: Message(null, true, '1', 'Error', 'This is a message') -define TestErrorWithNullCondition: - Message(1, null, '1', 'Error', 'This is a message') - define TestErrorWithNullCode: Message(1, true, null, 'Error', 'This is a message') From 6af4b689bf18bbe35abf82193e16fc3ba3745456 Mon Sep 17 00:00:00 2001 From: JP Date: Wed, 6 Nov 2024 08:55:37 -0700 Subject: [PATCH 2/2] Swap Gradle language from Groovy to Kotlin (#1413) * WIP * WIP * WIP * Working? * Fix usage of Java 17 API * Update checkstyle rules * Fix static analysis * Updates to src dirs * Fixing up missing test sourceSet * Try another way to specify the antlr directory * Third different way * Add some logging * merge master * Change toolchain resolution * Fix tests * More tweaks to animalsniffer * Fix formatting * Trying random stuff * More random stuff * Small improvements for Gradle build (#1418) * Removing references to idea * Fix duplicative generation * Remove references to idea project generation --------- Co-authored-by: Anton Vasetenkov --- Src/java-quickstart/README.md | 12 -- Src/java/README.md | 9 - Src/java/build.gradle | 55 ------ Src/java/build.gradle.kts | 24 +++ Src/java/buildSrc/build.gradle | 15 -- Src/java/buildSrc/build.gradle.kts | 19 ++ .../main/groovy/cql.fhir-conventions.gradle | 31 --- .../main/groovy/cql.java-conventions.gradle | 181 ----------------- .../groovy/cql.library-conventions.gradle | 19 -- .../main/groovy/cql.sca-conventions.gradle | 34 ---- .../main/groovy/cql.xjc-conventions.gradle | 69 ------- Src/java/buildSrc/src/main/kotlin/XjcTask.kt | 34 ++++ .../kotlin/cql.fhir-conventions.gradle.kts | 41 ++++ .../kotlin/cql.java-conventions.gradle.kts | 185 ++++++++++++++++++ .../kotlin/cql.library-conventions.gradle.kts | 16 ++ .../kotlin/cql.sca-conventions.gradle.kts | 29 +++ .../kotlin/cql.xjc-conventions.gradle.kts | 50 +++++ Src/java/cqf-fhir-npm/build.gradle | 10 - Src/java/cqf-fhir-npm/build.gradle.kts | 10 + Src/java/cqf-fhir/build.gradle | 3 - Src/java/cqf-fhir/build.gradle.kts | 3 + Src/java/cql-to-elm-cli/build.gradle | 24 --- Src/java/cql-to-elm-cli/build.gradle.kts | 24 +++ Src/java/cql-to-elm/build.gradle | 29 --- Src/java/cql-to-elm/build.gradle.kts | 25 +++ Src/java/cql/build.gradle | 34 ---- Src/java/cql/build.gradle.kts | 36 ++++ Src/java/elm-fhir/build.gradle | 25 --- Src/java/elm-fhir/build.gradle.kts | 14 ++ Src/java/elm-jackson/build.gradle | 14 -- Src/java/elm-jackson/build.gradle.kts | 11 ++ Src/java/elm-jaxb/build.gradle | 7 - Src/java/elm-jaxb/build.gradle.kts | 7 + Src/java/elm-test/build.gradle | 11 -- Src/java/elm-test/build.gradle.kts | 11 ++ Src/java/elm/build.gradle | 24 --- Src/java/elm/build.gradle.kts | 20 ++ Src/java/engine-fhir/build.gradle | 42 ---- Src/java/engine-fhir/build.gradle.kts | 36 ++++ .../engine/{build.gradle => build.gradle.kts} | 14 +- Src/java/gradle.properties | 2 +- Src/java/model-jackson/build.gradle | 16 -- Src/java/model-jackson/build.gradle.kts | 13 ++ Src/java/model-jaxb/build.gradle | 7 - Src/java/model-jaxb/build.gradle.kts | 7 + Src/java/model/build.gradle | 18 -- Src/java/model/build.gradle.kts | 13 ++ Src/java/qdm/build.gradle | 22 --- Src/java/qdm/build.gradle.kts | 17 ++ Src/java/quick/build.gradle | 19 -- Src/java/quick/build.gradle.kts | 14 ++ Src/java/settings.gradle | 26 --- Src/java/settings.gradle.kts | 26 +++ Src/java/tools/cql-formatter/build.gradle | 21 -- Src/java/tools/cql-formatter/build.gradle.kts | 21 ++ Src/java/tools/cql-parsetree/build.gradle | 16 -- Src/java/tools/cql-parsetree/build.gradle.kts | 16 ++ Src/java/tools/xsd-to-modelinfo/build.gradle | 16 -- .../tools/xsd-to-modelinfo/build.gradle.kts | 16 ++ 59 files changed, 746 insertions(+), 817 deletions(-) delete mode 100644 Src/java/build.gradle create mode 100644 Src/java/build.gradle.kts delete mode 100644 Src/java/buildSrc/build.gradle create mode 100644 Src/java/buildSrc/build.gradle.kts delete mode 100644 Src/java/buildSrc/src/main/groovy/cql.fhir-conventions.gradle delete mode 100644 Src/java/buildSrc/src/main/groovy/cql.java-conventions.gradle delete mode 100644 Src/java/buildSrc/src/main/groovy/cql.library-conventions.gradle delete mode 100644 Src/java/buildSrc/src/main/groovy/cql.sca-conventions.gradle delete mode 100644 Src/java/buildSrc/src/main/groovy/cql.xjc-conventions.gradle create mode 100644 Src/java/buildSrc/src/main/kotlin/XjcTask.kt create mode 100644 Src/java/buildSrc/src/main/kotlin/cql.fhir-conventions.gradle.kts create mode 100644 Src/java/buildSrc/src/main/kotlin/cql.java-conventions.gradle.kts create mode 100644 Src/java/buildSrc/src/main/kotlin/cql.library-conventions.gradle.kts create mode 100644 Src/java/buildSrc/src/main/kotlin/cql.sca-conventions.gradle.kts create mode 100644 Src/java/buildSrc/src/main/kotlin/cql.xjc-conventions.gradle.kts delete mode 100644 Src/java/cqf-fhir-npm/build.gradle create mode 100644 Src/java/cqf-fhir-npm/build.gradle.kts delete mode 100644 Src/java/cqf-fhir/build.gradle create mode 100644 Src/java/cqf-fhir/build.gradle.kts delete mode 100644 Src/java/cql-to-elm-cli/build.gradle create mode 100644 Src/java/cql-to-elm-cli/build.gradle.kts delete mode 100644 Src/java/cql-to-elm/build.gradle create mode 100644 Src/java/cql-to-elm/build.gradle.kts delete mode 100644 Src/java/cql/build.gradle create mode 100644 Src/java/cql/build.gradle.kts delete mode 100644 Src/java/elm-fhir/build.gradle create mode 100644 Src/java/elm-fhir/build.gradle.kts delete mode 100644 Src/java/elm-jackson/build.gradle create mode 100644 Src/java/elm-jackson/build.gradle.kts delete mode 100644 Src/java/elm-jaxb/build.gradle create mode 100644 Src/java/elm-jaxb/build.gradle.kts delete mode 100644 Src/java/elm-test/build.gradle create mode 100644 Src/java/elm-test/build.gradle.kts delete mode 100644 Src/java/elm/build.gradle create mode 100644 Src/java/elm/build.gradle.kts delete mode 100644 Src/java/engine-fhir/build.gradle create mode 100644 Src/java/engine-fhir/build.gradle.kts rename Src/java/engine/{build.gradle => build.gradle.kts} (63%) delete mode 100644 Src/java/model-jackson/build.gradle create mode 100644 Src/java/model-jackson/build.gradle.kts delete mode 100644 Src/java/model-jaxb/build.gradle create mode 100644 Src/java/model-jaxb/build.gradle.kts delete mode 100644 Src/java/model/build.gradle create mode 100644 Src/java/model/build.gradle.kts delete mode 100644 Src/java/qdm/build.gradle create mode 100644 Src/java/qdm/build.gradle.kts delete mode 100644 Src/java/quick/build.gradle create mode 100644 Src/java/quick/build.gradle.kts delete mode 100644 Src/java/settings.gradle create mode 100644 Src/java/settings.gradle.kts delete mode 100644 Src/java/tools/cql-formatter/build.gradle create mode 100644 Src/java/tools/cql-formatter/build.gradle.kts delete mode 100644 Src/java/tools/cql-parsetree/build.gradle create mode 100644 Src/java/tools/cql-parsetree/build.gradle.kts delete mode 100644 Src/java/tools/xsd-to-modelinfo/build.gradle create mode 100644 Src/java/tools/xsd-to-modelinfo/build.gradle.kts diff --git a/Src/java-quickstart/README.md b/Src/java-quickstart/README.md index 94b8ecf21..ff3f9792d 100644 --- a/Src/java-quickstart/README.md +++ b/Src/java-quickstart/README.md @@ -20,18 +20,6 @@ To clean up the artifacts: ./gradlew clean -# Generating IDE Projects - -You can generate an IDE project for IntelliJ IDEA: - - ./gradlew idea - -This is preferred over having IDEA load the gradle file directly, because it (a) generates the CQL -libraries, and (b) generates the configuration for the IDEA ANTLR plugin. To open the project in -IntelliJ IDEA, launch IDEA and open the `java-quickstart.ipr` file. - -See further below for installing and using the ANTLR plugin for IDEA. - # Executing the Sample Code You can execute the sample code using the `gradlew` command or a script generated by gradle. diff --git a/Src/java/README.md b/Src/java/README.md index 83caae007..c4fa54940 100644 --- a/Src/java/README.md +++ b/Src/java/README.md @@ -31,15 +31,6 @@ To clean up the build artifacts: ./gradlew clean -# Generating IDE Projects - -You can generate an IDE project for IntelliJ IDEa: - - ./gradlew idea - -In addition to creating project modules for cql, model, quick, elm, cql-to-elm, and the tools projects, this will also import project -modules for the CQL grammar and examples. - # Executing the Sample Code You can execute the sample code using the `gradlew` command or a script generated by gradle. diff --git a/Src/java/build.gradle b/Src/java/build.gradle deleted file mode 100644 index 938708ac2..000000000 --- a/Src/java/build.gradle +++ /dev/null @@ -1,55 +0,0 @@ -plugins { - id 'idea' - id 'eclipse' - id "org.sonarqube" version "4.4.1.3373" -} - -sonar { - properties { - property "sonar.projectKey", "cqframework_clinical_quality_language" - property "sonar.organization", "cqframework" - property "sonar.host.url", "https://sonarcloud.io" - } -} - -idea { - project { - languageLevel = JavaVersion.VERSION_11 - ipr { - withXml { provider -> - provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@vcs = 'Git' - } - - whenMerged { project -> - def examples = new org.gradle.plugins.ide.idea.model.Path('file://$PROJECT_DIR$/examples.iml', 'file://$PROJECT_DIR$/examples.iml', '$PROJECT_DIR$/examples.iml') - if ((project.modulePaths.findAll { p -> p.url == examples.url }).empty) project.modulePaths.add(examples) - - def grammar = new org.gradle.plugins.ide.idea.model.Path('file://$PROJECT_DIR$/grammar.iml', 'file://$PROJECT_DIR$/grammar.iml', '$PROJECT_DIR$/grammar.iml') - if ((project.modulePaths.findAll { p -> p.url == grammar.url }).empty) project.modulePaths.add(grammar) - - def cqllm = new org.gradle.plugins.ide.idea.model.Path('file://$PROJECT_DIR$/cql-lm.iml', 'file://$PROJECT_DIR$/cql-lm.iml', '$PROJECT_DIR$/cql-lm.iml') - if ((project.modulePaths.findAll { p -> p.url == cqllm.url }).empty) project.modulePaths.add(cqllm) - } - } - } - workspace { - iws { - withXml { provider -> - def props = provider.node.component.find { it.@name == 'PropertiesComponent' } - - def propMap = [ - '$PROJECT_DIR$/../grammar/cql.g4::/output-dir' : '$PROJECT_DIR$/cql/src/generated/java', - '$PROJECT_DIR$/../grammar/cql.g4::/lib-dir' : '$PROJECT_DIR$/../grammar', - '$PROJECT_DIR$/../grammar/cql.g4::/package' : 'org.cqframework.cql.gen', - '$PROJECT_DIR$/../grammar/cql.g4::/gen-listener' : 'true', - '$PROJECT_DIR$/../grammar/cql.g4::/gen-visitor' : 'true' - ] - - propMap.each() { key, value -> - if (! props.property.find { it.@name == key }) - props.appendNode('property', ['name' : key, 'value' : value]) - } - } - } - } -} \ No newline at end of file diff --git a/Src/java/build.gradle.kts b/Src/java/build.gradle.kts new file mode 100644 index 000000000..8986259f2 --- /dev/null +++ b/Src/java/build.gradle.kts @@ -0,0 +1,24 @@ +plugins { + kotlin("jvm") version "2.0.20" + id("org.sonarqube") version "4.4.1.3373" +} + +sonar { + properties { + property("sonar.projectKey", "cqframework_clinical_quality_language") + property("sonar.organization", "cqframework") + property("sonar.host.url", "https://sonarcloud.io") + } +} + +repositories { + mavenCentral() +} + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") +} + +kotlin { + jvmToolchain(11) +} \ No newline at end of file diff --git a/Src/java/buildSrc/build.gradle b/Src/java/buildSrc/build.gradle deleted file mode 100644 index b7ecf8ca3..000000000 --- a/Src/java/buildSrc/build.gradle +++ /dev/null @@ -1,15 +0,0 @@ -plugins { - id 'groovy-gradle-plugin' -} - -repositories { - mavenCentral() - gradlePluginPortal() -} - -dependencies { - implementation 'net.ltgt.gradle:gradle-errorprone-plugin:3.1.0' - implementation 'ru.vyarus:gradle-animalsniffer-plugin:1.7.0' - implementation 'com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.14' - implementation 'com.diffplug.spotless:spotless-plugin-gradle:6.23.3' -} \ No newline at end of file diff --git a/Src/java/buildSrc/build.gradle.kts b/Src/java/buildSrc/build.gradle.kts new file mode 100644 index 000000000..a4ee2ec71 --- /dev/null +++ b/Src/java/buildSrc/build.gradle.kts @@ -0,0 +1,19 @@ +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() + gradlePluginPortal() +} + +dependencies { + implementation("net.ltgt.gradle:gradle-errorprone-plugin:3.1.0") + implementation("ru.vyarus:gradle-animalsniffer-plugin:1.7.0") + implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.14") + implementation("com.diffplug.spotless:spotless-plugin-gradle:6.23.3") +} + +kotlin { + jvmToolchain(11) +} \ No newline at end of file diff --git a/Src/java/buildSrc/src/main/groovy/cql.fhir-conventions.gradle b/Src/java/buildSrc/src/main/groovy/cql.fhir-conventions.gradle deleted file mode 100644 index 80622c10c..000000000 --- a/Src/java/buildSrc/src/main/groovy/cql.fhir-conventions.gradle +++ /dev/null @@ -1,31 +0,0 @@ -plugins { - id 'cql.library-conventions' -} - -ext { - hapiVersion = project['hapi.version'] -} - -dependencies { - api platform("ca.uhn.hapi.fhir:hapi-fhir-bom:${hapiVersion}") { - exclude group: 'org.eclipse.jetty' - exclude group: 'xpp3' - exclude group: 'org.junit' - } - - implementation "ca.uhn.hapi.fhir:hapi-fhir-base" - implementation "ca.uhn.hapi.fhir:hapi-fhir-converter" - implementation "ca.uhn.hapi.fhir:hapi-fhir-structures-hl7org-dstu2" - implementation "ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2" - implementation "ca.uhn.hapi.fhir:hapi-fhir-structures-dstu3" - implementation "ca.uhn.hapi.fhir:hapi-fhir-structures-r4" - implementation "ca.uhn.hapi.fhir:hapi-fhir-structures-r5" - - // This is to align with the FHIR core dependencies - // Note that this dependency hasn't been updated since 2013 - // we probably need to standardize on a fork up the dependency chain - implementation ('org.ogce:xpp3:1.1.6') { - exclude group: 'org.junit' - exclude group: 'org.hamcrest' - } -} \ No newline at end of file diff --git a/Src/java/buildSrc/src/main/groovy/cql.java-conventions.gradle b/Src/java/buildSrc/src/main/groovy/cql.java-conventions.gradle deleted file mode 100644 index 42614d30b..000000000 --- a/Src/java/buildSrc/src/main/groovy/cql.java-conventions.gradle +++ /dev/null @@ -1,181 +0,0 @@ -plugins { - id 'java' - id 'maven-publish' - id 'jacoco' - id 'signing' - id 'cql.sca-conventions' - id 'com.diffplug.spotless' -} - -java { - withJavadocJar() - withSourcesJar() -} - -compileJava { - options.release = 11 -} - -repositories { - mavenLocal() - mavenCentral() - maven { - url "https://oss.sonatype.org/content/repositories/snapshots" - } -} - -dependencies { - implementation 'org.slf4j:slf4j-api:1.7.36' - testImplementation 'org.hamcrest:hamcrest-all:1.3' - testImplementation 'uk.co.datumedge:hamcrest-json:0.2' - testImplementation(platform('org.junit:junit-bom:5.10.2')) - testImplementation('org.junit.jupiter:junit-jupiter') - testImplementation 'org.slf4j:slf4j-simple:1.7.36' - - // These are JAXB dependencies excluded because the libraries need to work - // on Android. But for test purposes we use them pretty much everywhere. - testRuntimeOnly 'org.eclipse.persistence:org.eclipse.persistence.moxy:4.0.2' - testRuntimeOnly 'org.eclipse.parsson:parsson:1.1.5' - testRuntimeOnly('org.junit.platform:junit-platform-launcher') -} - -jar { - manifest { - attributes('Implementation-Title': project.name, - 'Implementation-Version': project.version, - 'Specification-Title': 'HL7 Clinical Quality Language (CQL)', - 'Specification-Version': project['specification.version']) - } -} - -jacoco { - toolVersion = "0.8.11" -} - -test { - useJUnitPlatform() - testLogging { - events "skipped", "failed" - } - finalizedBy jacocoTestReport // report is always generated after tests run -} - -jacocoTestReport { - reports { - xml.required = true - } - dependsOn test // tests are required to run before generating the report -} - -tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') -} - -tasks.withType(JavaCompile) { - options.compilerArgs << '-Xlint:unchecked' - options.deprecation = true -} - -spotless { - java { - targetExclude '**/generated/**' - palantirJavaFormat() - } -} - -/* -A few things: - - You must have an OSSRH Jira account (https://issues.sonatype.org/secure/Signup!default.jspa) - - Your account must have privileges to upload info.cqframework artifacts (https://issues.sonatype.org/browse/OSSRH-15514) - - You must have a gpg key (http://central.sonatype.org/pages/working-with-pgp-signatures.html) - - You must set your account info and GPG key in your user's gradle.properties file. For example: - ossrhUsername=foo - ossrhPassword=b@r - signing.keyId=24875D73 - signing.password=secret - signing.secretKeyRingFile=/Users/me/.gnupg/secring.gpg - - If the library version ends with '-SNAPSHOT', it will be deployed to the snapshot repository, else it will be - deployed to the staging repository (which you then must manually release http://central.sonatype.org/pages/releasing-the-deployment.html). - - Repo for snapshots and releases for the translator modules: https://oss.sonatype.org/content/groups/public/info/cqframework/ - - Repo for snpashots, releases, and staged releases for the translator modules: https://oss.sonatype.org/content/groups/staging/info/cqframework/ - - Repo for snapshots and releases for the engine modules: https://oss.sonatype.org/content/groups/public/org/opencds/cqf/cql/ - - Repo for snapshots, releases, and staged releases for the engine modules: https://oss.sonatype.org/content/groups/staging/org/opencds/cqf/cql/ - */ -publishing { - publications { - mavenDeployer(MavenPublication) { - from components.java - - pom { - name = project.name - packaging = 'jar' - description = "The ${project.name} library for the Clinical Quality Language Java reference implementation" - url = 'http://cqframework.info' - - scm { - connection = 'scm:git:git@github.com:cqframework/clinical_quality_language.git' - developerConnection = 'scm:git:git@github.com:cqframework/clinical_quality_language.git' - url = 'git@github.com:cqframework/clinical_quality_language.git' - } - - licenses { - license { - name ='The Apache License, Version 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - - developers { - developer { - name = 'Bryn Rhodes' - } - developer { - name = 'Chris Moesel' - } - developer { - name = 'Rob Dingwell' - } - developer { - name = 'Jason Walonoski' - } - developer { - name = 'Marc Hadley' - } - developer { - name = 'Jonathan Percival' - } - } - } - } - } - repositories { - maven { - credentials { - username project.hasProperty("ossrhUsername") ? ossrhUsername : System.getenv("OSSRH_USERNAME") != null ? System.getenv("OSSRH_USERNAME") : "" - password project.hasProperty("ossrhPassword") ? ossrhPassword : System.getenv("OSSRH_TOKEN") != null ? System.getenv("OSSRH_TOKEN") : "" - } - - /* Use these to test locally (but don't forget to comment out others!) - def releasesRepoUrl = "file://${buildDir}/repo" - def snapshotsRepoUrl = "file://${buildDir}/ssRepo" - */ - - // change URLs to point to your repos, e.g. http://my.org/repo - def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" - def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/" - url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl - } - } -} - -signing { - if (!version.endsWith('SNAPSHOT')){ - sign publishing.publications.mavenDeployer - } -} - -javadoc { - if(JavaVersion.current().isJava9Compatible()) { - options.addBooleanOption('html5', true) - } -} \ No newline at end of file diff --git a/Src/java/buildSrc/src/main/groovy/cql.library-conventions.gradle b/Src/java/buildSrc/src/main/groovy/cql.library-conventions.gradle deleted file mode 100644 index 52f3ea967..000000000 --- a/Src/java/buildSrc/src/main/groovy/cql.library-conventions.gradle +++ /dev/null @@ -1,19 +0,0 @@ -plugins { - id 'java-library' - id 'ru.vyarus.animalsniffer' - id 'cql.java-conventions' -} - -ext { - androidApiLevel = project['android.api.level'] -} - - -dependencies { - // Various libraries for Android signatures are available, Jackson uses this one - signature "com.toasttab.android:gummy-bears-api-${androidApiLevel}:0.5.0@signature" -} - -animalsniffer { - sourceSets = [sourceSets.main] -} \ No newline at end of file diff --git a/Src/java/buildSrc/src/main/groovy/cql.sca-conventions.gradle b/Src/java/buildSrc/src/main/groovy/cql.sca-conventions.gradle deleted file mode 100644 index d23a15b6b..000000000 --- a/Src/java/buildSrc/src/main/groovy/cql.sca-conventions.gradle +++ /dev/null @@ -1,34 +0,0 @@ -plugins { - id 'java' - id 'net.ltgt.errorprone' - id 'checkstyle' -} - -ext { - errorproneVersion = '2.24.1' -} - -dependencies { - errorprone "com.google.errorprone:error_prone_core:${errorproneVersion}" -} - -checkstyleMain.source = "src/main/java" -// TODO: Have a conversation with the team about enforcing checkstyle in tests -checkstyleTest.enabled = false - -tasks.withType(JavaCompile).configureEach { - // TODO: Change this once we fix all the errors - options.errorprone.disableAllWarnings = true - options.errorprone.disableWarningsInGeneratedCode = true - options.errorprone.disable("DoubleBraceInitialization") - // This applies recommended fixes to the source code in place - // options.errorprone.errorproneArgs = ["-XepPatchLocation:IN_PLACE"] -} - -tasks { - compileTestJava { - // TODO: Talk to the team about warnings in tests - options.errorprone.disableAllWarnings = true - options.errorprone.disableWarningsInGeneratedCode = true - } -} \ No newline at end of file diff --git a/Src/java/buildSrc/src/main/groovy/cql.xjc-conventions.gradle b/Src/java/buildSrc/src/main/groovy/cql.xjc-conventions.gradle deleted file mode 100644 index 8f9e15407..000000000 --- a/Src/java/buildSrc/src/main/groovy/cql.xjc-conventions.gradle +++ /dev/null @@ -1,69 +0,0 @@ -plugins { - id 'java' -} - -configurations { - xjc -} - -dependencies { - xjc 'codes.rafael.jaxb2_commons:jaxb2-basics-ant:3.0.0' - xjc 'codes.rafael.jaxb2_commons:jaxb2-basics:3.0.0' - xjc 'codes.rafael.jaxb2_commons:jaxb2-fluent-api:3.0.0' - // Eclipse has taken over all Java EE reference components - // https://www.infoworld.com/article/3310042/eclipse-takes-over-all-java-ee-reference-components.html - // https://wiki.eclipse.org/Jakarta_EE_Maven_Coordinates - xjc 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.1' - xjc 'org.glassfish.jaxb:jaxb-xjc:3.0.2' - xjc 'org.glassfish.jaxb:jaxb-runtime:4.0.3' - xjc 'org.eclipse.persistence:org.eclipse.persistence.moxy:4.0.2' - xjc 'org.slf4j:slf4j-simple:1.7.36' - api 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.1' - api 'codes.rafael.jaxb2_commons:jaxb2-basics-runtime:3.0.0' -} - -ext.xjc = [ - destDir: "${buildDir}/generated/sources/$name/main/java", - args: '-disableXmlSecurity -Xfluent-api -Xequals -XhashCode -XtoString -Xsetters -Xsetters-mode=direct' -] - - -task generateSources { - - outputs.dir xjc.destDir - - doLast { - file(xjc.destDir).mkdirs() - - ant.taskdef(name: 'xjc', classname: 'org.jvnet.jaxb2_commons.xjc.XJC2Task', classpath: configurations.xjc.asPath) - - /* The above sets up the task, but the real work of the task should be specified in the subproject using - generateSources.doLast. For example: - generateSources.doLast { - ant.xjc(destdir: xjc.destDir, schema: "${projectDir}/path/to/file.xsd") { - arg(line: xjc.args) - } - } - */ - } -} - -compileJava { - dependsOn generateSources -} - -sourcesJar { - dependsOn generateSources -} - -sourceSets { - main { - java { - srcDir(xjc.destDir) - } - } -} - -clean { - delete xjc.destDir -} diff --git a/Src/java/buildSrc/src/main/kotlin/XjcTask.kt b/Src/java/buildSrc/src/main/kotlin/XjcTask.kt new file mode 100644 index 000000000..c3d12b321 --- /dev/null +++ b/Src/java/buildSrc/src/main/kotlin/XjcTask.kt @@ -0,0 +1,34 @@ +import org.gradle.api.DefaultTask +import org.gradle.api.tasks.* + +open class XjcTask : DefaultTask() { + @Input + lateinit var schema: String + + @Input + var extraArgs : List = emptyList() + + @Input + var binding: String = "" + + @OutputDirectory + lateinit var outputDir: String + + + @TaskAction + fun generate() { + var bindingArgs : List = emptyList(); + if (binding.isNotBlank()) { + bindingArgs = listOf("-b", binding) + } + + val defaultArgs = listOf("-quiet", "-disableXmlSecurity", "-Xfluent-api", "-Xequals" ,"-XhashCode", "-XtoString" , "-Xsetters", "-Xsetters-mode=direct") + val options = listOf("-d", outputDir, schema) + bindingArgs + defaultArgs + extraArgs + + project.javaexec { + mainClass.set("com.sun.tools.xjc.XJCFacade") + classpath = project.configurations.getByName("xjc") + args = options + } + } +} \ No newline at end of file diff --git a/Src/java/buildSrc/src/main/kotlin/cql.fhir-conventions.gradle.kts b/Src/java/buildSrc/src/main/kotlin/cql.fhir-conventions.gradle.kts new file mode 100644 index 000000000..236198ee0 --- /dev/null +++ b/Src/java/buildSrc/src/main/kotlin/cql.fhir-conventions.gradle.kts @@ -0,0 +1,41 @@ +plugins { + id("cql.library-conventions") +} + +// bug fix for the hapi-bom +configurations.all { + resolutionStrategy { + eachDependency { + if (requested.group == "org.eclipse.jetty") { + useVersion("11.0.20") + because("jetty 12 is java 17") + } + } + } +} + +dependencies { + + api(platform("ca.uhn.hapi.fhir:hapi-fhir-bom:${project.findProperty("hapi.version")}")) + + implementation("ca.uhn.hapi.fhir:hapi-fhir-base") { + exclude(group = "org.eclipse.jetty") + exclude(group = "xpp3") + exclude(group = "org.junit") + } + + implementation("ca.uhn.hapi.fhir:hapi-fhir-converter") + implementation("ca.uhn.hapi.fhir:hapi-fhir-structures-hl7org-dstu2") + implementation("ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2") + implementation("ca.uhn.hapi.fhir:hapi-fhir-structures-dstu3") + implementation("ca.uhn.hapi.fhir:hapi-fhir-structures-r4") + implementation("ca.uhn.hapi.fhir:hapi-fhir-structures-r5") + + // This is to align with the FHIR core dependencies + // Note that this dependency hasn"t been updated since 2013 + // we probably need to standardize on a fork up the dependency chain + implementation("org.ogce:xpp3:1.1.6") { + exclude(group = "org.junit") + exclude(group = "org.hamcrest") + } +} \ No newline at end of file diff --git a/Src/java/buildSrc/src/main/kotlin/cql.java-conventions.gradle.kts b/Src/java/buildSrc/src/main/kotlin/cql.java-conventions.gradle.kts new file mode 100644 index 000000000..f75f566cb --- /dev/null +++ b/Src/java/buildSrc/src/main/kotlin/cql.java-conventions.gradle.kts @@ -0,0 +1,185 @@ +plugins { + id("java") + id("maven-publish") + id("jacoco") + id("signing") + id("cql.sca-conventions") + id("com.diffplug.spotless") +} + +java { + withJavadocJar() + withSourcesJar() + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } +} + +repositories { + mavenLocal() + mavenCentral() + maven { + url = uri("https://oss.sonatype.org/content/repositories/snapshots") + mavenContent { + snapshotsOnly() + } + } +} + +dependencies { + implementation("org.slf4j:slf4j-api:1.7.36") + testImplementation("org.hamcrest:hamcrest-all:1.3") + testImplementation("uk.co.datumedge:hamcrest-json:0.2") + testImplementation(platform("org.junit:junit-bom:5.10.2")) + testImplementation("org.junit.jupiter:junit-jupiter") + testImplementation("org.slf4j:slf4j-simple:1.7.36") + + // These are JAXB dependencies excluded because the libraries need to work + // on Android. But for test purposes we use them pretty much everywhere. + testRuntimeOnly("org.eclipse.persistence:org.eclipse.persistence.moxy:4.0.2") + testRuntimeOnly("org.eclipse.parsson:parsson:1.1.5") + testRuntimeOnly("org.junit.platform:junit-platform-launcher") +} + +tasks.jar { + manifest { + attributes["Implementation-Title"] = project.name + attributes["Implementation-Version"] = project.version + attributes["Specification-Title"] = "HL7 Clinical Quality Language (CQL)" + attributes["Specification-Version"] = project.findProperty("specification.version") ?: "" + } +} + +jacoco { + toolVersion = "0.8.11" +} + +tasks.withType { + useJUnitPlatform() + testLogging { + events("skipped", "failed") + } + finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run +} + +tasks.jacocoTestReport { + reports { + xml.required = true + } + dependsOn(tasks.test)// tests are required to run before generating the report +} + +tasks.javadoc { + options { + val standardOptions = this as StandardJavadocDocletOptions + standardOptions.addStringOption("Xdoclint:none", "-quiet") + } +} + +tasks.withType { + options.compilerArgs.add("-Xlint:unchecked") + options.isDeprecation = true +} + +spotless { + java { + targetExclude("**/generated/**") + palantirJavaFormat() + } +} + +/* +A few things: + - You must have an OSSRH Jira account (https://issues.sonatype.org/secure/Signup!valault.jspa) + - Your account must have privileges to upload info.cqframework artifacts (https://issues.sonatype.org/browse/OSSRH-15514) + - You must have a gpg key (http://central.sonatype.org/pages/working-with-pgp-signatures.html) + - You must set your account info and GPG key in your user"s gradle.properties file. For example: + ossrhUsername=foo + ossrhPassword=b@r + signing.keyId=24875D73 + signing.password=secret + signing.secretKeyRingFile=/Users/me/.gnupg/secring.gpg + - If the library version ends with "-SNAPSHOT", it will be deployed to the snapshot repository, else it will be + deployed to the staging repository (which you then must manually release http://central.sonatype.org/pages/releasing-the-deployment.html). + - Repo for snapshots and releases for the translator modules: https://oss.sonatype.org/content/groups/public/info/cqframework/ + - Repo for snpashots, releases, and staged releases for the translator modules: https://oss.sonatype.org/content/groups/staging/info/cqframework/ + - Repo for snapshots and releases for the engine modules: https://oss.sonatype.org/content/groups/public/org/opencds/cqf/cql/ + - Repo for snapshots, releases, and staged releases for the engine modules: https://oss.sonatype.org/content/groups/staging/org/opencds/cqf/cql/ + */ +publishing { + publications { + create("mavenJava") { + from(components["java"]) + + pom { + name = project.name + packaging = "jar" + description = + "The ${project.name} library for the Clinical Quality Language Java reference implementation" + url = "http://cqframework.info" + + scm { + connection = "scm:git:git@github.com:cqframework/clinical_quality_language.git" + developerConnection = "scm:git:git@github.com:cqframework/clinical_quality_language.git" + url = "git@github.com:cqframework/clinical_quality_language.git" + } + + licenses { + license { + name = "The Apache License, Version 2.0" + url = "http://www.apache.org/licenses/LICENSE-2.0.txt" + } + } + + developers { + developer { + name = "Bryn Rhodes" + } + developer { + name = "Chris Moesel" + } + developer { + name = "Rob Dingwell" + } + developer { + name = "Jason Walonoski" + } + developer { + name = "Marc Hadley" + } + developer { + name = "Jonathan Percival" + } + } + } + } + } + repositories { + maven { + credentials { + username = project.findProperty("ossrhUsername") as String? ?: System.getenv("OSSRH_USERNAME") ?: "" + password = project.findProperty("ossrhPassword") as String? ?: System.getenv("OSSRH_TOKEN") ?: "" + } + + /* Use these to test locally (but don"t forget to comment out others!) + val releasesRepoUrl = "file://${buildDir}/repo" + val snapshotsRepoUrl = "file://${buildDir}/ssRepo" + */ + + // change URLs to point to your repos, e.g. http://my.org/repo + val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/" + if ((project.version as String).endsWith("SNAPSHOT")) { + url = uri(snapshotsRepoUrl) + } else { + url = uri(releasesRepoUrl) + } + } + } +} + +signing { + if (!(version as String).endsWith("SNAPSHOT")) { + sign(publishing.publications["mavenJava"]) + } +} \ No newline at end of file diff --git a/Src/java/buildSrc/src/main/kotlin/cql.library-conventions.gradle.kts b/Src/java/buildSrc/src/main/kotlin/cql.library-conventions.gradle.kts new file mode 100644 index 000000000..0d17e8b3b --- /dev/null +++ b/Src/java/buildSrc/src/main/kotlin/cql.library-conventions.gradle.kts @@ -0,0 +1,16 @@ +import ru.vyarus.gradle.plugin.animalsniffer.AnimalSniffer + +plugins { + id("java-library") + id("ru.vyarus.animalsniffer") + id("cql.java-conventions") +} + +dependencies { + // Various libraries for Android signatures are available, Jackson uses this one + signature("com.toasttab.android:gummy-bears-api-${project.findProperty("android.api.level")}:0.5.0@signature") +} + +tasks.animalsnifferTest { + enabled = false +} \ No newline at end of file diff --git a/Src/java/buildSrc/src/main/kotlin/cql.sca-conventions.gradle.kts b/Src/java/buildSrc/src/main/kotlin/cql.sca-conventions.gradle.kts new file mode 100644 index 000000000..c9a6a4be4 --- /dev/null +++ b/Src/java/buildSrc/src/main/kotlin/cql.sca-conventions.gradle.kts @@ -0,0 +1,29 @@ +import net.ltgt.gradle.errorprone.errorprone + +plugins { + id("java") + id("net.ltgt.errorprone") + id("checkstyle") +} + +repositories { + mavenCentral() +} +dependencies { + errorprone("com.google.errorprone:error_prone_core:2.29.2") +} + +tasks.named("checkstyleMain") { + exclude { it.file.path.contains("generated")} +} + +tasks.named("checkstyleTest") { + enabled = false +} + +tasks.withType().configureEach { + options.errorprone.disableAllWarnings = true + options.errorprone.disableWarningsInGeneratedCode = true + options.errorprone.disable("DoubleBraceInitialization") + // errorproneArgs = ["-XepPatchLocation:IN_PLACE"] +} \ No newline at end of file diff --git a/Src/java/buildSrc/src/main/kotlin/cql.xjc-conventions.gradle.kts b/Src/java/buildSrc/src/main/kotlin/cql.xjc-conventions.gradle.kts new file mode 100644 index 000000000..9ab5ad518 --- /dev/null +++ b/Src/java/buildSrc/src/main/kotlin/cql.xjc-conventions.gradle.kts @@ -0,0 +1,50 @@ +plugins { + id("java-library") +} + +val xjc by configurations.creating + +dependencies { + xjc("codes.rafael.jaxb2_commons:jaxb2-basics-ant:3.0.0") + xjc("codes.rafael.jaxb2_commons:jaxb2-basics:3.0.0") + xjc("codes.rafael.jaxb2_commons:jaxb2-fluent-api:3.0.0") + // Eclipse has taken over all Java EE reference components + // https://www.infoworld.com/article/3310042/eclipse-takes-over-all-java-ee-reference-components.html + // https://wiki.eclipse.org/Jakarta_EE_Maven_Coordinates + xjc("jakarta.xml.bind:jakarta.xml.bind-api:4.0.1") + xjc("org.glassfish.jaxb:jaxb-xjc:3.0.2") + xjc("org.glassfish.jaxb:jaxb-runtime:4.0.3") + xjc("org.eclipse.persistence:org.eclipse.persistence.moxy:4.0.2") + xjc("org.slf4j:slf4j-simple:1.7.36") + xjc("org.apache.ant:ant:1.10.14") + + api("jakarta.xml.bind:jakarta.xml.bind-api:4.0.1") + api("codes.rafael.jaxb2_commons:jaxb2-basics-runtime:3.0.0") +} + +var buildDir = project.layout.buildDirectory.get().toString() +val destDir = "${buildDir}/generated/sources/$name/main/java" + +tasks.compileJava { + dependsOn(tasks.withType()) +} + +tasks.withType().configureEach { + outputDir = destDir +} + +tasks.named("sourcesJar") { + dependsOn(tasks.withType()) +} + +sourceSets { + main { + java { + srcDir(destDir) + } + } +} + +tasks.named("clean") { + delete(destDir) +} diff --git a/Src/java/cqf-fhir-npm/build.gradle b/Src/java/cqf-fhir-npm/build.gradle deleted file mode 100644 index 89422d105..000000000 --- a/Src/java/cqf-fhir-npm/build.gradle +++ /dev/null @@ -1,10 +0,0 @@ -plugins { - id "cql.fhir-conventions" -} - -dependencies { - implementation project(':cql-to-elm') - implementation project(':cqf-fhir') - implementation 'com.google.code.gson:gson:2.9.1' - implementation 'org.apache.commons:commons-compress:1.24.0' -} diff --git a/Src/java/cqf-fhir-npm/build.gradle.kts b/Src/java/cqf-fhir-npm/build.gradle.kts new file mode 100644 index 000000000..86efb4dc2 --- /dev/null +++ b/Src/java/cqf-fhir-npm/build.gradle.kts @@ -0,0 +1,10 @@ +plugins { + id("cql.fhir-conventions") +} + +dependencies { + implementation(project(":cql-to-elm")) + implementation(project(":cqf-fhir")) + implementation("com.google.code.gson:gson:2.9.1") + implementation("org.apache.commons:commons-compress:1.24.0") +} \ No newline at end of file diff --git a/Src/java/cqf-fhir/build.gradle b/Src/java/cqf-fhir/build.gradle deleted file mode 100644 index ece5a847e..000000000 --- a/Src/java/cqf-fhir/build.gradle +++ /dev/null @@ -1,3 +0,0 @@ -plugins { - id 'cql.fhir-conventions' -} \ No newline at end of file diff --git a/Src/java/cqf-fhir/build.gradle.kts b/Src/java/cqf-fhir/build.gradle.kts new file mode 100644 index 000000000..d5c16b25c --- /dev/null +++ b/Src/java/cqf-fhir/build.gradle.kts @@ -0,0 +1,3 @@ +plugins { + id("cql.fhir-conventions") +} \ No newline at end of file diff --git a/Src/java/cql-to-elm-cli/build.gradle b/Src/java/cql-to-elm-cli/build.gradle deleted file mode 100644 index 332ac9c93..000000000 --- a/Src/java/cql-to-elm-cli/build.gradle +++ /dev/null @@ -1,24 +0,0 @@ -plugins { - id 'cql.java-conventions' - id "application" -} - -application { - mainClass = 'org.cqframework.cql.cql2elm.cli.Main' -} - -dependencies { - implementation project(':cql-to-elm') - implementation project(':quick') - implementation project(':qdm') - implementation project(':model-jaxb') - implementation project(':elm-jaxb') - implementation 'net.sf.jopt-simple:jopt-simple:4.7' - implementation 'org.slf4j:slf4j-simple:1.7.36' - implementation 'org.glassfish.jaxb:jaxb-runtime:4.0.5' - implementation 'org.eclipse.persistence:org.eclipse.persistence.moxy:4.0.2' - testImplementation project(':model-jaxb') - testImplementation project(':model-jackson') - testImplementation project(':elm-jaxb') - testImplementation project(':elm-jackson') -} \ No newline at end of file diff --git a/Src/java/cql-to-elm-cli/build.gradle.kts b/Src/java/cql-to-elm-cli/build.gradle.kts new file mode 100644 index 000000000..ca47368a8 --- /dev/null +++ b/Src/java/cql-to-elm-cli/build.gradle.kts @@ -0,0 +1,24 @@ +plugins { + id("cql.java-conventions") + id("application") +} + +application { + mainClass = "org.cqframework.cql.cql2elm.cli.Main" +} + +dependencies { + implementation(project(":cql-to-elm")) + implementation(project(":quick")) + implementation(project(":qdm")) + implementation(project(":model-jaxb")) + implementation(project(":elm-jaxb")) + implementation("net.sf.jopt-simple:jopt-simple:4.7") + implementation("org.slf4j:slf4j-simple:1.7.36") + implementation("org.glassfish.jaxb:jaxb-runtime:4.0.5") + implementation("org.eclipse.persistence:org.eclipse.persistence.moxy:4.0.2") + testImplementation(project(":model-jaxb")) + testImplementation(project(":model-jackson")) + testImplementation(project(":elm-jaxb")) + testImplementation(project(":elm-jackson")) +} \ No newline at end of file diff --git a/Src/java/cql-to-elm/build.gradle b/Src/java/cql-to-elm/build.gradle deleted file mode 100644 index 5b782b882..000000000 --- a/Src/java/cql-to-elm/build.gradle +++ /dev/null @@ -1,29 +0,0 @@ -plugins { - id 'cql.library-conventions' - id 'cql.xjc-conventions' -} - -ext { - jacksonVersion = project['jackson.version'] -} - -dependencies { - api project(':cql') - api project(':model') - api project(':elm') - api 'org.fhir:ucum:1.0.8' - api 'org.apache.commons:commons-text:1.10.0' - - // TODO: This dependencies are required due the the fact that the CqlTranslatorOptionsMapper lives - // in the cql-to-elm project. Ideally, we'd factor out all serialization depedencies into common - // libraries such that we could swap out jackson for something else. In the meantime, these are - // "implementation" dependencies so that they are not exported downstream. - implementation "com.fasterxml.jackson.module:jackson-module-jakarta-xmlbind-annotations:${jacksonVersion}" - testImplementation project(':elm-jackson') - testImplementation project(':model-jackson') - testImplementation project(':quick') - testImplementation project(':qdm') - testImplementation 'com.github.reinert:jjschema:1.16' - testImplementation 'com.tngtech.archunit:archunit:1.2.1' - testImplementation 'org.skyscreamer:jsonassert:1.5.1' -} \ No newline at end of file diff --git a/Src/java/cql-to-elm/build.gradle.kts b/Src/java/cql-to-elm/build.gradle.kts new file mode 100644 index 000000000..e22e3fa60 --- /dev/null +++ b/Src/java/cql-to-elm/build.gradle.kts @@ -0,0 +1,25 @@ +plugins { + id("cql.library-conventions") + id("cql.xjc-conventions") +} + +dependencies { + api(project(":cql")) + api(project(":model")) + api(project(":elm")) + api("org.fhir:ucum:1.0.8") + api("org.apache.commons:commons-text:1.10.0") + + // TODO: This dependencies are required due the the fact that the CqlTranslatorOptionsMapper lives + // in the cql-to-elm project. Ideally, we"d factor out all serialization depedencies into common + // libraries such that we could swap out jackson for something else. In the meantime, these are + // "implementation" dependencies so that they are not exported downstream. + implementation("com.fasterxml.jackson.module:jackson-module-jakarta-xmlbind-annotations:${project.findProperty("jackson.version")}") + testImplementation(project(":elm-jackson")) + testImplementation(project(":model-jackson")) + testImplementation(project(":quick")) + testImplementation(project(":qdm")) + testImplementation("com.github.reinert:jjschema:1.16") + testImplementation("com.tngtech.archunit:archunit:1.2.1") + testImplementation("org.skyscreamer:jsonassert:1.5.1") +} \ No newline at end of file diff --git a/Src/java/cql/build.gradle b/Src/java/cql/build.gradle deleted file mode 100644 index 1c2f641d2..000000000 --- a/Src/java/cql/build.gradle +++ /dev/null @@ -1,34 +0,0 @@ -plugins { - id 'cql.java-conventions' - id 'application' - id 'antlr' -} - -dependencies { - antlr "org.antlr:antlr4:${project['antlr.version']}" - api "org.antlr:antlr4-runtime:${project['antlr.version']}" -} - -application { - mainClass = 'org.cqframework.cql.Main' -} - -sourceSets { - main { - antlr { - srcDirs = ["../../grammar"] - } - java { - srcDir 'build/generated/sources/antlr/main/java' - } - } -} - -sourcesJar { - from generateGrammarSource -} - -generateGrammarSource { - outputDirectory = file("${project.buildDir}/generated/sources/antlr/main/java/org/cqframework/cql/gen") - arguments = ['-visitor', '-package', 'org.cqframework.cql.gen'] -} \ No newline at end of file diff --git a/Src/java/cql/build.gradle.kts b/Src/java/cql/build.gradle.kts new file mode 100644 index 000000000..0df27595c --- /dev/null +++ b/Src/java/cql/build.gradle.kts @@ -0,0 +1,36 @@ +plugins { + id("cql.java-conventions") + id("application") + id("antlr") +} + +dependencies { + val version = project.findProperty("antlr.version") + antlr("org.antlr:antlr4:${version}") + api("org.antlr:antlr4-runtime:${version}") +} + +application { + mainClass = "org.cqframework.cql.Main" +} + +sourceSets { + main { + antlr { + setSrcDirs(listOf("../../grammar")) + } + java { + srcDir("build/generated/sources/antlr/main/java") + } + } +} + +tasks.generateGrammarSource { + val buildDir = layout.buildDirectory.get().toString() + outputDirectory = file("${buildDir}/generated/sources/antlr/main/java/org/cqframework/cql/gen") + arguments = listOf("-visitor", "-package", "org.cqframework.cql.gen") +} + +tasks.sourcesJar { + from(tasks.generateGrammarSource) +} \ No newline at end of file diff --git a/Src/java/elm-fhir/build.gradle b/Src/java/elm-fhir/build.gradle deleted file mode 100644 index 3f4b66ba5..000000000 --- a/Src/java/elm-fhir/build.gradle +++ /dev/null @@ -1,25 +0,0 @@ -plugins { - id "cql.library-conventions" - id "cql.fhir-conventions" -} - -ext { - mapstructVersion = "1.4.2.Final" -} - -dependencies { - api project(':cql-to-elm') - api project(':engine') - api project(":engine-fhir") - - testImplementation project(':quick') - testImplementation "org.reflections:reflections:0.10.2" - testRuntimeOnly project(':model-jackson') - -} - -tasks.withType(JavaCompile) { - options.compilerArgs = [ - "-Amapstruct.suppressGeneratorTimestamp=true" - ] -} diff --git a/Src/java/elm-fhir/build.gradle.kts b/Src/java/elm-fhir/build.gradle.kts new file mode 100644 index 000000000..4e3eaf320 --- /dev/null +++ b/Src/java/elm-fhir/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + id("cql.library-conventions") + id("cql.fhir-conventions") +} + +dependencies { + api(project(":cql-to-elm")) + api(project(":engine")) + api(project(":engine-fhir")) + + testImplementation(project(":quick")) + testImplementation("org.reflections:reflections:0.10.2") + testRuntimeOnly(project(":model-jackson")) +} \ No newline at end of file diff --git a/Src/java/elm-jackson/build.gradle b/Src/java/elm-jackson/build.gradle deleted file mode 100644 index 73bb1a2d8..000000000 --- a/Src/java/elm-jackson/build.gradle +++ /dev/null @@ -1,14 +0,0 @@ -plugins { - id 'cql.library-conventions' -} - -ext { - jacksonVersion = properties['jackson.version'] -} - -dependencies { - api project(':model') - api project(':elm') - api "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${jacksonVersion}" - api "com.fasterxml.jackson.module:jackson-module-jakarta-xmlbind-annotations:${jacksonVersion}" -} diff --git a/Src/java/elm-jackson/build.gradle.kts b/Src/java/elm-jackson/build.gradle.kts new file mode 100644 index 000000000..e3394c46c --- /dev/null +++ b/Src/java/elm-jackson/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + id("cql.library-conventions") +} + +dependencies { + val jacksonVersion = project.findProperty("jackson.version") + api(project(":model")) + api(project(":elm")) + api("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${jacksonVersion}") + api("com.fasterxml.jackson.module:jackson-module-jakarta-xmlbind-annotations:${jacksonVersion}") +} diff --git a/Src/java/elm-jaxb/build.gradle b/Src/java/elm-jaxb/build.gradle deleted file mode 100644 index e3f90a2ab..000000000 --- a/Src/java/elm-jaxb/build.gradle +++ /dev/null @@ -1,7 +0,0 @@ -plugins { - id 'cql.library-conventions' -} - -dependencies { - api project(':elm') -} diff --git a/Src/java/elm-jaxb/build.gradle.kts b/Src/java/elm-jaxb/build.gradle.kts new file mode 100644 index 000000000..6ad735088 --- /dev/null +++ b/Src/java/elm-jaxb/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + id("cql.library-conventions") +} + +dependencies { + api(project(":elm")) +} diff --git a/Src/java/elm-test/build.gradle b/Src/java/elm-test/build.gradle deleted file mode 100644 index 0e9c83526..000000000 --- a/Src/java/elm-test/build.gradle +++ /dev/null @@ -1,11 +0,0 @@ -plugins { - id 'cql.library-conventions' -} - -dependencies { - implementation project(':cql-to-elm') - // implementation project(':model-jaxb') - implementation project(':elm-jaxb') - implementation project(':model-jackson') - implementation project(':elm-jackson') -} diff --git a/Src/java/elm-test/build.gradle.kts b/Src/java/elm-test/build.gradle.kts new file mode 100644 index 000000000..eca6618a4 --- /dev/null +++ b/Src/java/elm-test/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + id("cql.library-conventions") +} + +dependencies { + implementation(project(":cql-to-elm")) + // implementation project(":model-jaxb") + implementation(project(":elm-jaxb")) + implementation(project(":model-jackson")) + implementation(project(":elm-jackson")) +} diff --git a/Src/java/elm/build.gradle b/Src/java/elm/build.gradle deleted file mode 100644 index 9791c0612..000000000 --- a/Src/java/elm/build.gradle +++ /dev/null @@ -1,24 +0,0 @@ -plugins { - id 'cql.library-conventions' - id 'cql.xjc-conventions' -} - -dependencies { - api project(':model') - testImplementation 'org.jeasy:easy-random-core:5.0.0' - testImplementation 'com.tngtech.archunit:archunit:1.2.1' -} - -generateSources { - inputs.dir "${projectDir}/../../cql-lm/schema" - - doLast { - ant.xjc(destdir: xjc.destDir, schema: "${projectDir}/../../cql-lm/schema/elm/library.xsd") { - arg(line: "${xjc.args} -npa -XautoInheritance -XautoInheritance-xmlTypesExtend=org.cqframework.cql.elm.tracking.Trackable") - } - - ant.xjc(destdir: xjc.destDir, schema: "${projectDir}/../../cql-lm/schema/elm/cqlannotations.xsd") { - arg(line: "${xjc.args} -npa") - } - } -} \ No newline at end of file diff --git a/Src/java/elm/build.gradle.kts b/Src/java/elm/build.gradle.kts new file mode 100644 index 000000000..8a7521a74 --- /dev/null +++ b/Src/java/elm/build.gradle.kts @@ -0,0 +1,20 @@ +plugins { + id("cql.library-conventions") + id("cql.xjc-conventions") +} + +dependencies { + api(project(":model")) + testImplementation("org.jeasy:easy-random-core:5.0.0") + testImplementation("com.tngtech.archunit:archunit:1.2.1") +} + +tasks.register("generateAnnotation") { + schema = "${projectDir}/../../cql-lm/schema/elm/cqlannotations.xsd" + extraArgs = listOf("-npa") +} + +tasks.register("generateElm") { + schema = "${projectDir}/../../cql-lm/schema/elm/library.xsd" + extraArgs = listOf("-npa", "-XautoInheritance", "-XautoInheritance-xmlTypesExtend=org.cqframework.cql.elm.tracking.Trackable") +} \ No newline at end of file diff --git a/Src/java/engine-fhir/build.gradle b/Src/java/engine-fhir/build.gradle deleted file mode 100644 index 3072caf70..000000000 --- a/Src/java/engine-fhir/build.gradle +++ /dev/null @@ -1,42 +0,0 @@ -plugins { - id 'cql.library-conventions' - id 'cql.xjc-conventions' - id 'cql.fhir-conventions' -} - -dependencies { - api project(':engine') - testImplementation 'com.github.tomakehurst:wiremock-jre8:2.35.2' - testImplementation project(':cql-to-elm') - testImplementation project(':model-jackson') - testImplementation project(':elm-jackson') - testImplementation project(':quick') - testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-client' -} - -generateSources { - inputs.dir "${projectDir}/src/test/resources/org/hl7/fhirpath/testSchema" - - doLast { - ant.xjc(destdir: xjc.destDir, schema: "${projectDir}/src/test/resources/org/hl7/fhirpath/testSchema/testSchema.xsd") { - arg(line: "${xjc.args} -npa " + - "-p org.hl7.fhirpath.tests") - } - } -} - -jacocoTestReport { - sourceDirectories.setFrom(files( - "${projectDir}/../elm/src/main/java", - "${projectDir}/../cql-to-elm/src/main/java", - "${projectDir}/../engine/src/main/java", - "${projectDir}/../engine-fhir/src/main/java", - )) - - classDirectories.setFrom(files( - "${projectDir}/../elm/build/classes/java/main", - "${projectDir}/../cql-to-elm/build/classes/java/main", - "${projectDir}/../engine/build/classes/java/main", - "${projectDir}/../engine-fhir/build/classes/java/main", - )) -} \ No newline at end of file diff --git a/Src/java/engine-fhir/build.gradle.kts b/Src/java/engine-fhir/build.gradle.kts new file mode 100644 index 000000000..9139bf9b7 --- /dev/null +++ b/Src/java/engine-fhir/build.gradle.kts @@ -0,0 +1,36 @@ +plugins { + id("cql.library-conventions") + id("cql.xjc-conventions") + id("cql.fhir-conventions") +} + +dependencies { + api(project(":engine")) + testImplementation("org.wiremock:wiremock:3.9.1") + testImplementation(project(":cql-to-elm")) + testImplementation(project(":model-jackson")) + testImplementation(project(":elm-jackson")) + testImplementation(project(":quick")) + testImplementation("ca.uhn.hapi.fhir:hapi-fhir-client") +} + +tasks.register("generateFhirPathTests") { + schema = "${projectDir}/src/test/resources/org/hl7/fhirpath/testSchema" + extraArgs = listOf("-npa", "-p", "org.hl7.fhirpath.tests") +} + +tasks.jacocoTestReport { + sourceDirectories.setFrom(files( + "${projectDir}/../elm/src/main/java", + "${projectDir}/../cql-to-elm/src/main/java", + "${projectDir}/../engine/src/main/java", + "${projectDir}/../engine-fhir/src/main/java", + )) + + classDirectories.setFrom(files( + "${projectDir}/../elm/build/classes/java/main", + "${projectDir}/../cql-to-elm/build/classes/java/main", + "${projectDir}/../engine/build/classes/java/main", + "${projectDir}/../engine-fhir/build/classes/java/main", + )) +} \ No newline at end of file diff --git a/Src/java/engine/build.gradle b/Src/java/engine/build.gradle.kts similarity index 63% rename from Src/java/engine/build.gradle rename to Src/java/engine/build.gradle.kts index 03212da9a..1e68e05e0 100644 --- a/Src/java/engine/build.gradle +++ b/Src/java/engine/build.gradle.kts @@ -1,17 +1,17 @@ plugins { - id 'cql.library-conventions' + id("cql.library-conventions") } dependencies { - api project(':elm') - api project(':cql-to-elm') + api(project(":elm")) + api(project(":cql-to-elm")) - testImplementation project(':model-jackson') - testImplementation project(':elm-jackson') - testImplementation 'org.mockito:mockito-core:5.4.0' + testImplementation(project(":model-jackson")) + testImplementation(project(":elm-jackson")) + testImplementation("org.mockito:mockito-core:5.4.0") } -jacocoTestReport { +tasks.jacocoTestReport { sourceDirectories.setFrom(files( "${projectDir}/../elm/src/main/java", "${projectDir}/../cql-to-elm/src/main/java", diff --git a/Src/java/gradle.properties b/Src/java/gradle.properties index 91b5a44d8..a25cef364 100644 --- a/Src/java/gradle.properties +++ b/Src/java/gradle.properties @@ -10,4 +10,4 @@ specification.version=1.5.2 hapi.version=7.4.5 jackson.version=2.17.1 antlr.version=4.13.1 -android.api.level=28 +android.api.level=28 \ No newline at end of file diff --git a/Src/java/model-jackson/build.gradle b/Src/java/model-jackson/build.gradle deleted file mode 100644 index 9f0fe1621..000000000 --- a/Src/java/model-jackson/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - id 'cql.library-conventions' -} - -ext { - jacksonVersion = project['jackson.version'] -} - -dependencies { - api project(':model') - api "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${jacksonVersion}" - api "com.fasterxml.jackson.module:jackson-module-jakarta-xmlbind-annotations:${jacksonVersion}" - - testImplementation project(":quick") - testImplementation project(":qdm") -} diff --git a/Src/java/model-jackson/build.gradle.kts b/Src/java/model-jackson/build.gradle.kts new file mode 100644 index 000000000..f004e6b4c --- /dev/null +++ b/Src/java/model-jackson/build.gradle.kts @@ -0,0 +1,13 @@ +plugins { + id("cql.library-conventions") +} + +dependencies { + val jacksonVersion = project.findProperty("jackson.version") + api(project(":model")) + api("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${jacksonVersion}") + api("com.fasterxml.jackson.module:jackson-module-jakarta-xmlbind-annotations:${jacksonVersion}") + + testImplementation(project(":quick")) + testImplementation(project(":qdm")) +} diff --git a/Src/java/model-jaxb/build.gradle b/Src/java/model-jaxb/build.gradle deleted file mode 100644 index 990a7efaf..000000000 --- a/Src/java/model-jaxb/build.gradle +++ /dev/null @@ -1,7 +0,0 @@ -plugins { - id 'cql.library-conventions' -} - -dependencies { - api project(':model') -} diff --git a/Src/java/model-jaxb/build.gradle.kts b/Src/java/model-jaxb/build.gradle.kts new file mode 100644 index 000000000..bc8870e71 --- /dev/null +++ b/Src/java/model-jaxb/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + id("cql.library-conventions") +} + +dependencies { + api(project(":model")) +} diff --git a/Src/java/model/build.gradle b/Src/java/model/build.gradle deleted file mode 100644 index 1bb18cc98..000000000 --- a/Src/java/model/build.gradle +++ /dev/null @@ -1,18 +0,0 @@ -plugins { - id 'cql.library-conventions' - id 'cql.xjc-conventions' -} - -dependencies { - implementation 'org.apache.commons:commons-text:1.10.0' -} - -generateSources { - inputs.dir "${projectDir}/../../cql-lm/schema" - - doLast { - ant.xjc(destdir: xjc.destDir, schema: "${projectDir}/../../cql-lm/schema/model/modelinfo.xsd") { - arg(line: "${xjc.args} -npa") - } - } -} diff --git a/Src/java/model/build.gradle.kts b/Src/java/model/build.gradle.kts new file mode 100644 index 000000000..e0ef4e153 --- /dev/null +++ b/Src/java/model/build.gradle.kts @@ -0,0 +1,13 @@ +plugins { + id("cql.library-conventions") + id("cql.xjc-conventions") +} + +dependencies { + implementation("org.apache.commons:commons-text:1.10.0") +} + +tasks.register("generateModel") { + schema = "${projectDir}/../../cql-lm/schema/model/modelinfo.xsd" + extraArgs = listOf("-npa") +} \ No newline at end of file diff --git a/Src/java/qdm/build.gradle b/Src/java/qdm/build.gradle deleted file mode 100644 index 2047aec7c..000000000 --- a/Src/java/qdm/build.gradle +++ /dev/null @@ -1,22 +0,0 @@ -plugins { - id 'cql.library-conventions' - id 'cql.xjc-conventions' -} - -dependencies { - api project(':elm') - api project(':model') -} - -generateSources{ - inputs.dir "${projectDir}/schema" - - doLast { - ant.xjc(destdir: xjc.destDir, schema: "${projectDir}/schema/qdm.xsd") { - arg(line: xjc.args) - } - ant.xjc(destdir: xjc.destDir, schema: "${projectDir}/schema/qdm.4.2.xsd") { - arg(line: xjc.args) - } - } -} \ No newline at end of file diff --git a/Src/java/qdm/build.gradle.kts b/Src/java/qdm/build.gradle.kts new file mode 100644 index 000000000..16fa5038d --- /dev/null +++ b/Src/java/qdm/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + id("cql.library-conventions") + id("cql.xjc-conventions") +} + +dependencies { + api(project(":elm")) + api(project(":model")) +} + +tasks.register("generateQdm") { + schema = "${projectDir}/schema/qdm.xsd" +} + +tasks.register("generateQdm42") { + schema = "${projectDir}/schema/qdm.4.2.xsd" +} diff --git a/Src/java/quick/build.gradle b/Src/java/quick/build.gradle deleted file mode 100644 index 97275a85d..000000000 --- a/Src/java/quick/build.gradle +++ /dev/null @@ -1,19 +0,0 @@ -plugins { - id 'cql.library-conventions' - id 'cql.xjc-conventions' -} - -dependencies { - api project(':elm') - api project(':model') -} - -generateSources{ - inputs.dir "${projectDir}/schema" - - doLast { - ant.xjc(destdir: xjc.destDir, schema: "${projectDir}/schema/v1.4/quick.xsd", binding: "${projectDir}/schema/v1.4/quick-binding.xjb") { - arg(line: xjc.args) - } - } -} diff --git a/Src/java/quick/build.gradle.kts b/Src/java/quick/build.gradle.kts new file mode 100644 index 000000000..32e82ad6a --- /dev/null +++ b/Src/java/quick/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + id("cql.library-conventions") + id("cql.xjc-conventions") +} + +dependencies { + api(project(":elm")) + api(project(":model")) +} + +tasks.register("generateQuick") { + schema = "${projectDir}/schema/v1.4/quick.xsd" + binding = "${projectDir}/schema/v1.4/quick-binding.xjb" +} \ No newline at end of file diff --git a/Src/java/settings.gradle b/Src/java/settings.gradle deleted file mode 100644 index 497fe4274..000000000 --- a/Src/java/settings.gradle +++ /dev/null @@ -1,26 +0,0 @@ -rootProject.name = 'cql-all' - -include ( - 'cqf-fhir', - 'cqf-fhir-npm', - 'cql', - 'model', - 'model-jackson', - 'model-jaxb', - 'elm', - 'elm-jackson', - 'elm-jaxb', - 'elm-test', - 'engine', - 'engine-fhir', - 'qdm', - 'quick', - 'cql-to-elm', - 'cql-to-elm-cli', - 'elm-fhir', - 'tools:cql-formatter', - 'tools:cql-parsetree', - 'tools:xsd-to-modelinfo' -) - - diff --git a/Src/java/settings.gradle.kts b/Src/java/settings.gradle.kts new file mode 100644 index 000000000..4e6f7bdf1 --- /dev/null +++ b/Src/java/settings.gradle.kts @@ -0,0 +1,26 @@ +rootProject.name = "cql-all" + +include( + "cqf-fhir", + "cqf-fhir-npm", + "cql", + "model", + "model-jackson", + "model-jaxb", + "elm", + "elm-jackson", + "elm-jaxb", + "elm-test", + "engine", + "engine-fhir", + "qdm", + "quick", + "cql-to-elm", + "cql-to-elm-cli", + "elm-fhir", + "tools:cql-formatter", + "tools:cql-parsetree", + "tools:xsd-to-modelinfo" +) + + diff --git a/Src/java/tools/cql-formatter/build.gradle b/Src/java/tools/cql-formatter/build.gradle deleted file mode 100644 index 03ade1839..000000000 --- a/Src/java/tools/cql-formatter/build.gradle +++ /dev/null @@ -1,21 +0,0 @@ -plugins { - id 'cql.java-conventions' - id 'application' -} - -application { - mainClass = 'org.cqframework.cql.tools.formatter.Main' -} - -dependencies { - testImplementation project(":cql-to-elm") - implementation project(":cql") -} - -sourceSets { - test { - resources { - srcDir "../../cql-to-elm/src/test/resources" - } - } -} \ No newline at end of file diff --git a/Src/java/tools/cql-formatter/build.gradle.kts b/Src/java/tools/cql-formatter/build.gradle.kts new file mode 100644 index 000000000..3531f740c --- /dev/null +++ b/Src/java/tools/cql-formatter/build.gradle.kts @@ -0,0 +1,21 @@ +plugins { + id("cql.java-conventions") + id("application") +} + +application { + mainClass = "org.cqframework.cql.tools.formatter.Main" +} + +dependencies { + testImplementation(project(":cql-to-elm")) + implementation(project(":cql")) +} + +sourceSets { + test { + resources { + srcDir("../../cql-to-elm/src/test/resources") + } + } +} \ No newline at end of file diff --git a/Src/java/tools/cql-parsetree/build.gradle b/Src/java/tools/cql-parsetree/build.gradle deleted file mode 100644 index 476878ea2..000000000 --- a/Src/java/tools/cql-parsetree/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - id 'cql.java-conventions' - id 'application' -} - -application { - mainClass = 'org.cqframework.cql.tools.parsetree.Main' -} - -dependencies { - implementation project(':cql') - implementation (group: "org.antlr", name: "antlr4", version: "4.10.1") { - // antlr 4.5 includes these classes directly - exclude(group: "org.abego.treelayout", module: "org.abego.treelayout.core") - } -} \ No newline at end of file diff --git a/Src/java/tools/cql-parsetree/build.gradle.kts b/Src/java/tools/cql-parsetree/build.gradle.kts new file mode 100644 index 000000000..8475d5f02 --- /dev/null +++ b/Src/java/tools/cql-parsetree/build.gradle.kts @@ -0,0 +1,16 @@ +plugins { + id("cql.java-conventions") + id("application") +} + +application { + mainClass = "org.cqframework.cql.tools.parsetree.Main" +} + +dependencies { + implementation(project(":cql")) + implementation("org.antlr:antlr4:4.10.1") { + // antlr 4.5 includes these classes directly + exclude(group= "org.abego.treelayout", module= "org.abego.treelayout.core") + } +} \ No newline at end of file diff --git a/Src/java/tools/xsd-to-modelinfo/build.gradle b/Src/java/tools/xsd-to-modelinfo/build.gradle deleted file mode 100644 index de960982e..000000000 --- a/Src/java/tools/xsd-to-modelinfo/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - id 'cql.java-conventions' - id 'cql.library-conventions' - id 'application' -} - -application { - mainClass = 'org.cqframework.cql.tools.xsd2modelinfo.Main' -} - -dependencies { - api project(':model') - implementation 'net.sf.jopt-simple:jopt-simple:4.7' - implementation 'org.apache.ws.xmlschema:xmlschema-core:2.2.5' - implementation 'org.apache.ws.xmlschema:xmlschema-walker:2.2.5' -} \ No newline at end of file diff --git a/Src/java/tools/xsd-to-modelinfo/build.gradle.kts b/Src/java/tools/xsd-to-modelinfo/build.gradle.kts new file mode 100644 index 000000000..e4613dc38 --- /dev/null +++ b/Src/java/tools/xsd-to-modelinfo/build.gradle.kts @@ -0,0 +1,16 @@ +plugins { + id("cql.java-conventions") + id("cql.library-conventions") + id("application") +} + +application { + mainClass = "org.cqframework.cql.tools.xsd2modelinfo.Main" +} + +dependencies { + api(project(":model")) + implementation("net.sf.jopt-simple:jopt-simple:4.7") + implementation("org.apache.ws.xmlschema:xmlschema-core:2.2.5") + implementation("org.apache.ws.xmlschema:xmlschema-walker:2.2.5") +} \ No newline at end of file