diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index b81ca5721..31cf8e37f 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -6,14 +6,7 @@ repositories { mavenCentral() maven { url = 'https://repo.grails.org/grails/core' } - def gradleGrailsVersion = project.rootProject - .extensions - .getByType(VersionCatalogsExtension.class) - .named("buildsrcLibs") - .findVersion("grails-gradle-plugin") - .get() - .displayName - if (System.getenv("GITHUB_MAVEN_PASSWORD") && !gradleGrailsVersion.endsWith('-SNAPSHOT')) { + if (System.getenv("GITHUB_MAVEN_PASSWORD")) { System.out.println("Adding Grails Core Repo") maven { url = 'https://maven.pkg.github.com/grails/grails-core' diff --git a/docs/src/docs/asciidoc/json/installation.adoc b/docs/src/docs/asciidoc/json/installation.adoc index 5a9b7c54a..a50097602 100644 --- a/docs/src/docs/asciidoc/json/installation.adoc +++ b/docs/src/docs/asciidoc/json/installation.adoc @@ -5,11 +5,6 @@ To activate JSON views, add the following dependency to the `dependencies` block [source,groovy,subs="attributes"] compile "org.grails.plugins:views-json:{version}" -If you are also using MongoDB you may want to add the `views-json-templates` dependency too which includes support for GeoJSON: - -[source,groovy,subs="attributes"] -compile "org.grails.plugins:views-json-templates:{version}" - To enable Gradle compilation of JSON views for production environment add the following to the `buildscript` `dependencies` block: [source,groovy,subs="attributes"] diff --git a/docs/src/docs/asciidoc/json/pluginSupport.adoc b/docs/src/docs/asciidoc/json/pluginSupport.adoc index 67f79f64e..d5f5c8c65 100644 --- a/docs/src/docs/asciidoc/json/pluginSupport.adoc +++ b/docs/src/docs/asciidoc/json/pluginSupport.adoc @@ -52,8 +52,6 @@ Once this is in place any applications that includes this library will have acce For example if you want to render all instances of type `foo.bar.Birthday` create a template called `src/main/gson/foo/bar/_birthday.gson` then compile the template and place the JAR on the classpath of your application. -NOTE: See the https://github.com/grails/grails-views/tree/master/json-templates/src/templates/grails/mongodb/geo[GeoJSON templates] for MongoDB for example of how it provides global templates for Mongo specific classes. - == Customizing the Compile Task Unless otherwise configured, the project name of the plugin (the gradle `project.name`) is used as the `packageName` when compiling JSON views. diff --git a/examples/functional-tests/build.gradle b/examples/functional-tests/build.gradle index 7b508058c..ca4161f87 100644 --- a/examples/functional-tests/build.gradle +++ b/examples/functional-tests/build.gradle @@ -27,7 +27,6 @@ dependencies { implementation 'org.grails.plugins:gsp' implementation 'org.grails.plugins:hibernate5' - implementation libs.grails.datastore.gorm.mongodb // Only used for access to grails.mongodb.geo.Point class implementation 'org.springframework.boot:spring-boot-autoconfigure' implementation 'org.springframework.boot:spring-boot-starter-logging' @@ -35,7 +34,6 @@ dependencies { compileOnly libs.jakarta.servlet.api // Provided by Tomcat - runtimeOnly project(':views-json-templates') runtimeOnly 'com.h2database:h2' runtimeOnly 'org.apache.tomcat:tomcat-jdbc' runtimeOnly libs.assetpipeline diff --git a/examples/functional-tests/grails-app/conf/application.yml b/examples/functional-tests/grails-app/conf/application.yml index 8212747b7..ebd46cf6f 100644 --- a/examples/functional-tests/grails-app/conf/application.yml +++ b/examples/functional-tests/grails-app/conf/application.yml @@ -12,10 +12,6 @@ spring: groovy: template: check-template-location: false - autoconfigure: - exclude: - # No need to start MongoDB, we only need access to the Point class from gorm-mongodb - - org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration --- grails: mime: diff --git a/examples/functional-tests/grails-app/controllers/functional/tests/PlaceController.groovy b/examples/functional-tests/grails-app/controllers/functional/tests/PlaceController.groovy index d178f3e95..a8b8b7226 100644 --- a/examples/functional-tests/grails-app/controllers/functional/tests/PlaceController.groovy +++ b/examples/functional-tests/grails-app/controllers/functional/tests/PlaceController.groovy @@ -1,7 +1,5 @@ package functional.tests -import grails.mongodb.geo.Point - /** * Created by graemerocher on 19/05/16. */ @@ -9,16 +7,12 @@ class PlaceController { static responseFormats = ['json'] - def show() { - respond new Place(name: "London", location: Point.valueOf(10,10)) - } - def test() { - respond new Place(name: "London", location: Point.valueOf(10,10)) + respond new Place(name: "London", location: "UK") } } class Place { String name - Point location + String location } \ No newline at end of file diff --git a/examples/functional-tests/grails-app/views/place/show.gson b/examples/functional-tests/grails-app/views/place/show.gson deleted file mode 100644 index 63c7114bf..000000000 --- a/examples/functional-tests/grails-app/views/place/show.gson +++ /dev/null @@ -1,8 +0,0 @@ - -import functional.tests.Place - -model { - Place place -} - -json g.render(place) diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/GlobalTemplatesSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/GlobalTemplatesSpec.groovy deleted file mode 100644 index d084815db..000000000 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/GlobalTemplatesSpec.groovy +++ /dev/null @@ -1,31 +0,0 @@ -package functional.tests - -import grails.testing.mixin.integration.Integration -import grails.testing.spock.RunOnce -import io.micronaut.http.HttpRequest -import io.micronaut.http.HttpResponse -import io.micronaut.http.HttpStatus -import org.junit.jupiter.api.BeforeEach - -/** - * Created by graemerocher on 19/05/16. - */ -@Integration(applicationClass = Application) -class GlobalTemplatesSpec extends HttpClientSpec { - - @RunOnce - @BeforeEach - void init() { - super.init() - } - - void "Test errors view rendering"() { - when: - HttpRequest request = HttpRequest.GET('/place/show') - HttpResponse rsp = client.toBlocking().exchange(request, String) - - then:"The REST resource is created and the correct JSON is returned" - rsp.status() == HttpStatus.OK - rsp.body() == '{"location":{"type":"Point","coordinates":[10.0,10.0]},"name":"London"}' - } -} diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/ObjectTemplateSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/ObjectTemplateSpec.groovy index 206e3ea78..4dc24ba4c 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/ObjectTemplateSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/ObjectTemplateSpec.groovy @@ -23,6 +23,6 @@ class ObjectTemplateSpec extends HttpClientSpec { then:"The correct response is returned" rsp.status() == HttpStatus.OK - rsp.body() == '{"location":{"type":"Point","coordinates":[10.0,10.0]},"name":"London"}' + rsp.body() == '{"location":"UK","name":"London"}' } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e25cf4367..cb40a2451 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,6 @@ grails-bootstrap = { module = 'org.grails:grails-bootstrap' } grails-core = { module = 'org.grails:grails-core' } grails-datastore-core = { module = 'org.grails:grails-datastore-core' } grails-datastore-gorm-hibernate5 = { module = 'org.grails:grails-datastore-gorm-hibernate5' } -grails-datastore-gorm-mongodb = { module = 'org.grails:grails-datastore-gorm-mongodb' } grails-datastore-gorm-support = { module = 'org.grails:grails-datastore-gorm-support' } grails-encoder = { module = 'org.grails:grails-encoder' } grails-gradle-plugin = { module = 'org.grails:grails-gradle-plugin', version.ref = 'grails-gradle-plugin' } @@ -32,7 +31,6 @@ jakarta-servlet-api = { module = 'jakarta.servlet:jakarta.servlet-api' } jakarta-validation-api = { module = 'jakarta.validation:jakarta.validation-api' } micronaut-jackson-databind = { module = 'io.micronaut:micronaut-jackson-databind', version.ref = 'micronaut' } micronaut-http-client = { module = 'io.micronaut:micronaut-http-client', version.ref = 'micronaut' } -mongodb-bson = { module = 'org.mongodb:bson' } slf4j-api = { module = 'org.slf4j:slf4j-api' } slf4j-nop = { module = 'org.slf4j:slf4j-nop' } spock-core = { module = 'org.spockframework:spock-core' } diff --git a/json-templates/build.gradle b/json-templates/build.gradle deleted file mode 100644 index 20ddb046e..000000000 --- a/json-templates/build.gradle +++ /dev/null @@ -1,59 +0,0 @@ -plugins { - id 'groovy' - id 'java-library' - id 'maven-publish' - id 'signing' -} - -group = 'org.grails.plugins' -ext.set('projectDesc', 'JSON Views Templates') - -dependencies { - - api project(':views-json') - - // 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 -} - -def templateSourceDir = layout.projectDirectory.dir('src/templates') -def compilationOutputDir = layout.buildDirectory.dir('classes/groovy/main') -sourceSets { - main { - groovy { - // Add templates as source dir - srcDirs = [templateSourceDir] - } - } -} - -tasks.register('compileViews', JavaExec) { - inputs.dir templateSourceDir - outputs.dir compilationOutputDir - mainClass = 'grails.plugin.json.view.JsonViewCompiler' - classpath configurations.compileClasspath - args(templateSourceDir.asFile, compilationOutputDir.get().asFile, libs.versions.java.baseline.get(), ' ', ' ', 'none', 'UTF-8') -} - -// This is needed to trigger compilation of the views -tasks.named('classes') { - dependsOn 'compileViews' -} - -apply from: rootProject.layout.projectDirectory.file('gradle/java-config.gradle') -apply from: rootProject.layout.projectDirectory.file('gradle/publishing.gradle') - -// There are no javadocs for this project. -// 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 diff --git a/json-templates/src/templates/grails/mongodb/geo/_geometryCollection.gson b/json-templates/src/templates/grails/mongodb/geo/_geometryCollection.gson deleted file mode 100644 index 8e040c8de..000000000 --- a/json-templates/src/templates/grails/mongodb/geo/_geometryCollection.gson +++ /dev/null @@ -1,15 +0,0 @@ -/** - * A template for rendering a GeoJSON GeometryCollection in MongoDB - */ -import grails.mongodb.geo.* -import groovy.transform.Field - -@Field GeometryCollection geometryCollection - -json { - type "GeometryCollection" - geometries( geometryCollection ) { GeoJSON current -> - type current.getClass().simpleName - coordinates current.asList() - } -} \ No newline at end of file diff --git a/json-templates/src/templates/grails/mongodb/geo/_lineString.gson b/json-templates/src/templates/grails/mongodb/geo/_lineString.gson deleted file mode 100644 index 5c36f64db..000000000 --- a/json-templates/src/templates/grails/mongodb/geo/_lineString.gson +++ /dev/null @@ -1,12 +0,0 @@ -/** - * A template for rendering a GeoJSON LineString in MongoDB - */ -import grails.mongodb.geo.* -import groovy.transform.Field - -@Field LineString lineString - -json { - type "LineString" - coordinates lineString.asList() -} \ No newline at end of file diff --git a/json-templates/src/templates/grails/mongodb/geo/_multiLineString.gson b/json-templates/src/templates/grails/mongodb/geo/_multiLineString.gson deleted file mode 100644 index a4124edcd..000000000 --- a/json-templates/src/templates/grails/mongodb/geo/_multiLineString.gson +++ /dev/null @@ -1,12 +0,0 @@ -/** - * A template for rendering a GeoJSON MultiLineString in MongoDB - */ -import grails.mongodb.geo.* -import groovy.transform.Field - -@Field MultiLineString multiLineString - -json { - type "MultiLineString" - coordinates multiLineString.asList() -} \ No newline at end of file diff --git a/json-templates/src/templates/grails/mongodb/geo/_multiPoint.gson b/json-templates/src/templates/grails/mongodb/geo/_multiPoint.gson deleted file mode 100644 index 5ff1bd5dd..000000000 --- a/json-templates/src/templates/grails/mongodb/geo/_multiPoint.gson +++ /dev/null @@ -1,12 +0,0 @@ -/** - * A template for rendering a GeoJSON MultiPoint in MongoDB - */ -import grails.mongodb.geo.* -import groovy.transform.Field - -@Field MultiPoint multiPoint - -json { - type "MultiPoint" - coordinates multiPoint.asList() -} \ No newline at end of file diff --git a/json-templates/src/templates/grails/mongodb/geo/_multiPolygon.gson b/json-templates/src/templates/grails/mongodb/geo/_multiPolygon.gson deleted file mode 100644 index 6ccdc0d2d..000000000 --- a/json-templates/src/templates/grails/mongodb/geo/_multiPolygon.gson +++ /dev/null @@ -1,12 +0,0 @@ -/** - * A template for rendering a GeoJSON MultiPoint in MongoDB - */ -import grails.mongodb.geo.* -import groovy.transform.Field - -@Field MultiPoint multiPolygon - -json { - type "MultiPolygon" - coordinates multiPolygon.asList() -} \ No newline at end of file diff --git a/json-templates/src/templates/grails/mongodb/geo/_point.gson b/json-templates/src/templates/grails/mongodb/geo/_point.gson deleted file mode 100644 index e776fa126..000000000 --- a/json-templates/src/templates/grails/mongodb/geo/_point.gson +++ /dev/null @@ -1,12 +0,0 @@ -/** - * A template for rendering a GeoJSON Point in MongoDB - */ -import grails.mongodb.geo.* -import groovy.transform.Field - -@Field Point point - -json { - type "Point" - coordinates point.asArray() -} \ No newline at end of file diff --git a/json-templates/src/templates/grails/mongodb/geo/_polygon.gson b/json-templates/src/templates/grails/mongodb/geo/_polygon.gson deleted file mode 100644 index eeb782154..000000000 --- a/json-templates/src/templates/grails/mongodb/geo/_polygon.gson +++ /dev/null @@ -1,12 +0,0 @@ -/** - * A template for rendering a GeoJSON Polygon in MongoDB - */ -import grails.mongodb.geo.* -import groovy.transform.Field - -@Field Polygon polygon - -json { - type "Polygon" - coordinates polygon.asList() -} \ No newline at end of file diff --git a/json-templates/src/templates/org/bson/types/_objectId.gson b/json-templates/src/templates/org/bson/types/_objectId.gson deleted file mode 100644 index 2983e3dbd..000000000 --- a/json-templates/src/templates/org/bson/types/_objectId.gson +++ /dev/null @@ -1,8 +0,0 @@ - -import org.bson.types.* -import groovy.transform.* -import grails.plugin.json.builder.* - -@Field ObjectId objectId = null - -json(JsonOutput.unescaped("\"${objectId?.toString()}\"")) \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 9cd288510..a736802ff 100644 --- a/settings.gradle +++ b/settings.gradle @@ -46,7 +46,7 @@ dependencyResolutionManagement { } } -['core', 'json', 'docs', 'json-templates', 'json-testing-support', 'markup'].each {dirName -> +['core', 'json', 'docs', 'json-testing-support', 'markup'].each {dirName -> include("views-$dirName") project(":views-$dirName").projectDir = file(dirName) }