diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 85b9b3db1..5917d751c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,6 +11,7 @@ groovy = '3.0.21' java-baseline = '11' javax-annotation-api = '1.3.2' micronaut = '3.10.4' +mongodb = '4.11.1' slf4j = '1.7.36' spock = '2.3-groovy-3.0' spring = '5.3.33' @@ -37,6 +38,7 @@ groovy-json = { module = 'org.codehaus.groovy:groovy-json', version.ref = 'groov groovy-templates = { module = 'org.codehaus.groovy:groovy-templates', version.ref = 'groovy' } javax-annotation-api = { module = 'javax.annotation:javax.annotation-api', version.ref = 'javax-annotation-api' } micronaut-http-client = { module = 'io.micronaut:micronaut-http-client', version.ref = 'micronaut' } +mongodb-bson = { module = 'org.mongodb:bson', version.ref = 'mongodb' } slf4j-api = { module = 'org.slf4j:slf4j-api', version.ref = 'slf4j' } slf4j-nop = { module = 'org.slf4j:slf4j-nop', version.ref = 'slf4j' } spock-core = { module = 'org.spockframework:spock-core', version.ref = 'spock' } diff --git a/json-templates/build.gradle b/json-templates/build.gradle index 241ffea1c..20ddb046e 100644 --- a/json-templates/build.gradle +++ b/json-templates/build.gradle @@ -12,11 +12,15 @@ dependencies { api project(':views-json') - // Should this be api, implementation, compileOnly or provided? - // The templates expect classes from this library as models - // but I'm not sure in what context these templates are used - // They were previously compileOnly - compileOnly libs.grails.datastore.gorm.mongodb + // The templates in this project use classes from these dependencies so they should be in the implementation configuration. + // + // But, setting them as implementation will make grails apps using this project try to autoconfigure MongoDB beans, + // even without the real MongoDB dependencies on the classpath, which fails with ClassNotFoundExeption. + // + // Therefore, because this project is only supposed to work with MongoDB, setting them as compileOnly/provided is + // probably best, as it will not break apps that erroneously include this project as a dependency but don't use MongoDB. + compileOnly libs.grails.datastore.gorm.mongodb // provided + compileOnly libs.mongodb.bson // provided compileOnly libs.slf4j.nop // Get rid of warning about missing slf4j implementation during compileGsonViews task } @@ -52,4 +56,4 @@ apply from: rootProject.layout.projectDirectory.file('gradle/publishing.gradle') // This is a workaround as a javadoc jar is required for publishing. tasks.named('javadocJar', Jar) { from 'src/templates' -} +} \ No newline at end of file