From 240b40e6729f7c1c97dd2017b09ede0048e347bc Mon Sep 17 00:00:00 2001 From: Mads Hansen Date: Thu, 5 Oct 2023 16:40:53 -0400 Subject: [PATCH] Adjust build to make the Gradle module variants easier to consume and simplify gradle dependency resolution for CoRB and ml-gradle corb task. --- build.gradle | 22 ++++++++++++++-------- examples/build.gradle | 11 +++-------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/build.gradle b/build.gradle index d47a7944..bf9c6946 100644 --- a/build.gradle +++ b/build.gradle @@ -61,7 +61,10 @@ sourceSets { } configurations { - shadow + shadow { + extendsFrom api //will ensure that XCC is listed as a dependency + } + integrationTestImplementation.extendsFrom testImplementation integrationTestRuntimeOnly.extendsFrom testRuntimeOnly @@ -83,14 +86,10 @@ configurations { dependencies { api 'com.marklogic:marklogic-xcc:11.0.3' // JavaScript libraries are bundled in a fat jar for the UI - shadow "org.webjars:angularjs:$angularVersion" implementation "org.webjars:angularjs:$angularVersion" - shadow "org.webjars:bootstrap:$bootstrapVersion" implementation "org.webjars:bootstrap:$bootstrapVersion" - shadow "org.webjars:jquery:$jqueryVersion" implementation "org.webjars:jquery:$jqueryVersion" // externalsortinginjava classes with the corb distro in a fat jar - shadow "com.google.code.externalsortinginjava:externalsortinginjava:$externalsortinginjavaVersion" implementation "com.google.code.externalsortinginjava:externalsortinginjava:$externalsortinginjavaVersion" testImplementation group: 'junit', name: 'junit', version: '4.13.2' testImplementation 'org.jasypt:jasypt:1.9.3' @@ -117,14 +116,15 @@ processResources { } processTestResources.dependsOn processResources -//disabling, because we want to incorporate externalsortingjava in uber jar and use as the artifact +//disabling, because we want to incorporate externalsortingjava and UI resources in uber jar and use as the artifact jar { enabled = false dependsOn(shadowJar { classifier = null }) } shadowJar { - project.configurations.implementation.canBeResolved = true - configurations = [project.configurations.implementation, project.configurations.shadow] + + //project.configurations.implementation.canBeResolved = true + configurations = [project.configurations.shadow] dependencies { include(dependency("com.google.code.externalsortinginjava:externalsortinginjava:$externalsortinginjavaVersion")) include(dependency('org.webjars:.*')) @@ -257,6 +257,12 @@ tasks.coveralls { dependsOn 'check' } +// Having both runtimeElements and shadowRuntimeElements variants makes it harder to resolve CoRB as a dependency and is confusing. +// We just want the fat jar listed and seen as the only option. +components.java.withVariantsFromConfiguration(configurations.getByName("runtimeElements")) { + skip() +} + publishing { publications { mavenJava(MavenPublication) { diff --git a/examples/build.gradle b/examples/build.gradle index d010b383..3a6c320f 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -31,13 +31,8 @@ configurations { } dependencies { - // required to run CoRB2 - corb "com.marklogic:marklogic-xcc:${xccVersion}" - corb("com.marklogic:marklogic-corb:${corbVersion}") { - attributes { - attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME)) - } - } + // required to run CoRB + corb("com.marklogic:marklogic-corb:${corbVersion}") // optional corb 'org.jasypt:jasypt:1.9.2' // necessary to leverage JasyptDecrypter } @@ -72,7 +67,7 @@ ext { * gradle corb -DURIS-MODULE="src/main/ml-modules/ext/corb2-project/uris.xqy|ADHOC" -DPROCESS-MODULE="src/main/ml-modules/ext/corb2-project/corb/transform.xqy|ADHOC" */ task corb(type: com.marklogic.gradle.task.CorbTask) { - /* Either uncomment and set the xccConnectionUri below and set an appropriate XCC connection string, + /* Either uncomment and set the xccConnectionUri below and set an appropriate connection string, * or specify on the commandline as a project property: -PcorbXccConnectionUri=xcc://user:pass@host:port/content-database * or specify as a System property: -DXCC-CONNECTION-URI=xcc://user:pass@host:port/content-database * or instead of setting the XCC-CONNECTION-URI, set the individual XCC options