Skip to content

Commit

Permalink
Adjust build to make the Gradle module variants easier to consume and…
Browse files Browse the repository at this point in the history
… simplify gradle dependency resolution for CoRB and ml-gradle corb task.
  • Loading branch information
hansenmc committed Oct 5, 2023
1 parent 232d419 commit 240b40e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
22 changes: 14 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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'
Expand All @@ -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:.*'))
Expand Down Expand Up @@ -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) {
Expand Down
11 changes: 3 additions & 8 deletions examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 240b40e

Please sign in to comment.