diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 24f7b4c8b..7edf67f01 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -9,70 +9,80 @@ on: - master - '[2-9]+.[0-9]+.x' jobs: + build: runs-on: ubuntu-latest + strategy: + fail-fast: false matrix: - java: ['11', '14'] + java: [11, 17] + env: WORKSPACE: ${{ github.workspace }} GRADLE_OPTS: -Xmx1500m -Dfile.encoding=UTF-8 + steps: - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 + - uses: gradle/wrapper-validation-action@v2 + - uses: actions/setup-java@v4 with: - distribution: 'adopt' + distribution: temurin java-version: ${{ matrix.java }} + - name: Run Tests if: github.event_name == 'pull_request' id: tests - uses: gradle/gradle-build-action@v2 - with: - arguments: check -Dgeb.env=chromeHeadless + uses: gradle/actions/setup-gradle@v3 env: GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + with: + arguments: | + check + -Dgeb.env=chromeHeadless + - name: Run Build if: github.event_name == 'push' id: build - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v3 env: GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} with: - arguments: build -Dgeb.env=chromeHeadless - - name: Publish Test Report - if: steps.build.outcome == 'failure' || steps.tests.outcome == 'failure' - uses: scacap/action-surefire-report@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - report_paths: '**/build/test-results/test/TEST-*.xml' - - name: Publish to repo.grails.org + arguments: | + build + -Dgeb.env=chromeHeadless + + - name: Publish Snapshot to repo.grails.org id: publish - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v3 if: steps.build.outcome == 'success' && github.event_name == 'push' && matrix.java == '11' env: - ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} - ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + ORG_GRADLE_PROJECT_artifactoryUsername: ${{ secrets.ARTIFACTORY_USERNAME }} + ORG_GRADLE_PROJECT_artifactoryPassword: ${{ secrets.ARTIFACTORY_PASSWORD }} GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} with: - arguments: -Dorg.gradle.internal.publish.checksums.insecure=true publish + arguments: | + -Dorg.gradle.internal.publish.checksums.insecure=true + publish + - name: Build Docs id: docs if: steps.build.outcome == 'success' && github.event_name == 'push' && matrix.java == '11' - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v3 env: GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} with: arguments: views-docs:docs - - name: Publish to Github Pages + + - name: Publish Snapshot docs to Github Pages if: steps.docs.outcome == 'success' && github.event_name == 'push' && matrix.java == '11' uses: micronaut-projects/github-pages-deploy-action@grails env: @@ -80,5 +90,5 @@ jobs: GH_TOKEN: ${{ secrets.GH_TOKEN }} BRANCH: gh-pages FOLDER: docs/build/docs - COMMIT_EMAIL: behlp@objectcomputing.com + COMMIT_EMAIL: behlp@unityfoundation.io COMMIT_NAME: Puneet Behl diff --git a/.github/workflows/groovy-joint-workflow.yml b/.github/workflows/groovy-joint-workflow.yml index c636b4d0b..19f271233 100644 --- a/.github/workflows/groovy-joint-workflow.yml +++ b/.github/workflows/groovy-joint-workflow.yml @@ -1,47 +1,27 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: "Grails Joint Validation Build" -# GROOVY_2_5_X == Grails 4.0.x -# GROOVY_3_0_X == grails master -# Groovy master branch does not map to any due to changed package names. +name: "Groovy Joint Validation Build" on: push: branches: - - '[3-9]+.[1-9]+.x' + - '[3-9]+.[0-9]+.x' pull_request: branches: - - '[3-9]+.[1-9]+.x' + - '[3-9]+.[0-9]+.x' workflow_dispatch: permissions: contents: read -env: - CI_GROOVY_VERSION: jobs: build_groovy: - strategy: - fail-fast: true runs-on: ubuntu-latest outputs: - groovyVersion: ${{ steps.groovy-version.outputs.value }} + groovySnapshotVersion: ${{ steps.groovy_snapshot_version.outputs.value }} steps: + - name: Set up JDK uses: actions/setup-java@v4 with: - distribution: 'adopt' - java-version: '11.0.6' + distribution: temurin + java-version: 11 + - name: Cache local Maven repository & Groovy uses: actions/cache@v4 with: @@ -49,59 +29,96 @@ jobs: ~/groovy ~/.m2/repository key: cache-local-groovy-maven-${{ github.sha }} - - name: Checkout Groovy 3_0_X (Grails 5 and later) - if: startsWith(github.ref, 'refs/heads/3.') || startsWith(github.base_ref, '3.') - run: cd .. && git clone --depth 1 https://github.com/apache/groovy.git -b GROOVY_3_0_X --single-branch - - name: Set CI_GROOVY_VERSION for Grails - id: groovy-version + + - name: Checkout project to fetch some versions it uses + uses: actions/checkout@v4 + with: + sparse-checkout-cone-mode: false + sparse-checkout: | + settings.gradle + gradle/libs.versions.toml + + - name: Get version of Gradle Enterprise plugin + id: gradle_enterprise_version + run: | + GE_PLUGIN_VERSION=$(grep -m 1 'id\s*\(\"com.gradle.enterprise\"\|'"'com.gradle.enterprise'"'\)\s*version' settings.gradle | sed -E "s/.*version[[:space:]]*['\"]?([0-9]+\.[0-9]+\.[0-9]+)['\"]?.*/\1/" | tr -d [:space:]) + GE_USER_DATA_PLUGIN_VERSION=$(grep -m 1 'id\s*\(\"com.gradle.common-custom-user-data-gradle-plugin\"\|'"'com.gradle.common-custom-user-data-gradle-plugin'"'\)\s*version' settings.gradle | sed -E "s/.*version[[:space:]]*['\"]?([0-9]+\.[0-9]+\.[0-9]+)['\"]?.*/\1/" | tr -d [:space:]) + echo "Project uses Gradle Enterprise Plugin version: $GE_PLUGIN_VERSION" + echo "Project uses Gradle Common Custom User Data Plugin version: $GE_USER_DATA_PLUGIN_VERSION" + echo "ge_plugin_version=$GE_PLUGIN_VERSION" >> $GITHUB_OUTPUT + echo "ge_user_data_plugin_version=$GE_USER_DATA_PLUGIN_VERSION" >> $GITHUB_OUTPUT + rm settings.gradle + + - name: Select Groovy Branch to checkout + id: groovy_branch + run: | + PROJECT_GROOVY_VERSION=$(grep -m 1 groovy gradle/libs.versions.toml | cut -d\= -f2 | tr -d "[:space:]'\"") + MAJOR_VERSION=$(echo $PROJECT_GROOVY_VERSION | cut -d'.' -f1) + MINOR_VERSION=$(echo $PROJECT_GROOVY_VERSION | cut -d'.' -f2) + BRANCH="GROOVY_${MAJOR_VERSION}_${MINOR_VERSION}_X" + echo "Project uses Groovy $PROJECT_GROOVY_VERSION" + echo "value=$BRANCH" >> $GITHUB_OUTPUT + rm -rf gradle + + - name: Checkout Groovy Snapshot + run: | + BRANCH=${{ steps.groovy_branch.outputs.value }} + echo "Checking out Groovy branch $BRANCH" + cd .. && git clone --depth 1 https://github.com/apache/groovy.git -b $BRANCH --single-branch + + - name: Set Groovy Snapshot version for project build + id: groovy_snapshot_version run: | cd ../groovy - echo "CI_GROOVY_VERSION=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]')" >> $GITHUB_ENV - echo "value=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]')" >> $GITHUB_OUTPUT - - name: Prepare GE Set-up Configuration + GROOVY_SNAPSHOT_VERSION=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d "[:space:]") + echo "value=$GROOVY_SNAPSHOT_VERSION" >> $GITHUB_OUTPUT + + - name: Prepare Gradle Enterprise Set-up Configuration id: ge_conf run: | echo "VALUE<> $GITHUB_OUTPUT echo "plugins { " >> $GITHUB_OUTPUT - echo " id 'com.gradle.enterprise' version '3.15.1'" >> $GITHUB_OUTPUT - echo " id 'com.gradle.common-custom-user-data-gradle-plugin' version '1.11.3'" >> $GITHUB_OUTPUT - echo "}" >> $GITHUB_OUTPUT - echo "" >> $GITHUB_OUTPUT - echo "gradleEnterprise {" >> $GITHUB_OUTPUT - echo " server = 'https://ge.grails.org'" >> $GITHUB_OUTPUT - echo " buildScan {" >> $GITHUB_OUTPUT - echo " publishAlways()" >> $GITHUB_OUTPUT - echo " publishIfAuthenticated()" >> $GITHUB_OUTPUT - echo " uploadInBackground = System.getenv('CI') == null" >> $GITHUB_OUTPUT - echo " capture {" >> $GITHUB_OUTPUT - echo " taskInputFiles = true" >> $GITHUB_OUTPUT - echo " }" >> $GITHUB_OUTPUT - echo " }" >> $GITHUB_OUTPUT - echo "}" >> $GITHUB_OUTPUT + echo " id 'com.gradle.enterprise' version '${{ steps.gradle_enterprise_version.outputs.ge_plugin_version }}'" >> $GITHUB_OUTPUT + echo " id 'com.gradle.common-custom-user-data-gradle-plugin' version '${{ steps.gradle_enterprise_version.outputs.ge_user_data_plugin_version }}'" >> $GITHUB_OUTPUT + echo "}" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "gradleEnterprise {" >> $GITHUB_OUTPUT + echo " server = 'https://ge.grails.org'" >> $GITHUB_OUTPUT + echo " buildScan {" >> $GITHUB_OUTPUT + echo " publishAlways()" >> $GITHUB_OUTPUT + echo " publishIfAuthenticated()" >> $GITHUB_OUTPUT + echo " uploadInBackground = false" >> $GITHUB_OUTPUT + echo " capture {" >> $GITHUB_OUTPUT + echo " taskInputFiles = true" >> $GITHUB_OUTPUT + echo " }" >> $GITHUB_OUTPUT + echo " }" >> $GITHUB_OUTPUT + echo "}" >> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT - echo "buildCache {" >> $GITHUB_OUTPUT - echo " local { enabled = System.getenv('CI') != 'true' }" >> $GITHUB_OUTPUT - echo " remote(HttpBuildCache) {" >> $GITHUB_OUTPUT - echo " push = System.getenv('CI') == 'true'" >> $GITHUB_OUTPUT - echo " enabled = true" >> $GITHUB_OUTPUT - echo " url = 'https://ge.grails.org/cache/'" >> $GITHUB_OUTPUT - echo " credentials {" >> $GITHUB_OUTPUT - echo " username = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER')" >> $GITHUB_OUTPUT - echo " password = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY')" >> $GITHUB_OUTPUT - echo " }" >> $GITHUB_OUTPUT - echo " }" >> $GITHUB_OUTPUT - echo "}" >> $GITHUB_OUTPUT + echo "buildCache {" >> $GITHUB_OUTPUT + echo " local { enabled = false }" >> $GITHUB_OUTPUT + echo " remote(HttpBuildCache) {" >> $GITHUB_OUTPUT + echo " push = true" >> $GITHUB_OUTPUT + echo " enabled = true" >> $GITHUB_OUTPUT + echo " url = 'https://ge.grails.org/cache/'" >> $GITHUB_OUTPUT + echo " credentials {" >> $GITHUB_OUTPUT + echo " username = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER')" >> $GITHUB_OUTPUT + echo " password = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY')" >> $GITHUB_OUTPUT + echo " }" >> $GITHUB_OUTPUT + echo " }" >> $GITHUB_OUTPUT + echo "}" >> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT + - name: Gradle Enterprise Set-up run: | cd ../groovy # Delete exiting plugins and build-scan from settings.gradle file sed -i '21,31d' settings.gradle # Add Gradle Enterprise set-up related configuration after line no 20 in settings.gradle - echo "${{ steps.ge_conf.outputs.value}}" | sed -i -e "20r /dev/stdin" settings.gradle + echo "${{ steps.ge_conf.outputs.value }}" | sed -i -e "20r /dev/stdin" settings.gradle + - name: Build and install groovy (no docs) - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v3 env: GRADLE_SCANS_ACCEPT: yes GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} @@ -117,18 +134,20 @@ jobs: -x groovydocAll -x asciidoc -x docGDK - build_grails_views: + + build_project: needs: [build_groovy] - strategy: - fail-fast: true runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 + - name: Set up JDK uses: actions/setup-java@v4 with: - distribution: 'adopt' - java-version: '11' + distribution: temurin + java-version: 11 + - name: Cache local Maven repository & Groovy uses: actions/cache@v4 with: @@ -136,17 +155,18 @@ jobs: ~/groovy ~/.m2/repository key: cache-local-groovy-maven-${{ github.sha }} - - name: Set CI_GROOVY_VERSION for Grails - run: | - echo "CI_GROOVY_VERSION=${{needs.build_groovy.outputs.groovyVersion}}" >> $GITHUB_ENV - - name: Build - id: build - uses: gradle/gradle-build-action@v2 + + - name: Build Project + uses: gradle/actions/setup-gradle@v3 env: + GROOVY_VERSION: ${{ needs.build_groovy.outputs.groovySnapshotVersion }} + CI_GROOVY_VERSION: ${{ needs.build_groovy.outputs.groovySnapshotVersion }} + ORG_GRADLE_PROJECT_groovyVersion: ${{ needs.build_groovy.outputs.groovySnapshotVersion }} GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} with: arguments: | build + -x groovydoc -Dgeb.env=chromeHeadless \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 660d4cd11..628d57dad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,67 +2,70 @@ name: Release on: release: types: [published] + jobs: + release: runs-on: ubuntu-latest - strategy: - matrix: - java: ['11'] + env: GIT_USER_NAME: puneetbehl - GIT_USER_EMAIL: behlp@objectcomputing.com + GIT_USER_EMAIL: behlp@unityfoundation.io + steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - token: ${{ secrets.GH_TOKEN }} - - uses: gradle/wrapper-validation-action@v1 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: 'adopt' - java-version: ${{ matrix.java }} + + - uses: actions/checkout@v4 + - uses: gradle/wrapper-validation-action@v2 + - uses: actions/setup-java@v4 + with: { java-version: 11, distribution: temurin } + - name: Set the current release version id: release_version run: echo "release_version=${GITHUB_REF:11}" >> $GITHUB_OUTPUT + - name: Run pre-release uses: micronaut-projects/github-actions/pre-release@master - with: - token: ${{ secrets.GITHUB_TOKEN }} + - name: Generate secring file env: SECRING_FILE: ${{ secrets.SECRING_FILE }} run: echo $SECRING_FILE | base64 -d > ${{ github.workspace }}/secring.gpg - - name: Publish to Sonatype OSSRH - id: publish - uses: gradle/gradle-build-action@v2 + + - name: Publish to Sonatype + id: publish_to_sonatype + uses: gradle/actions/setup-gradle@v3 env: - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} - SIGNING_KEY: ${{ secrets.SIGNING_KEY }} - SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} - SECRING_FILE: ${{ secrets.SECRING_FILE }} GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + ORG_GRADLE_PROJECT_sonatypeOssUsername: ${{ secrets.SONATYPE_USERNAME }} + ORG_GRADLE_PROJECT_sonatypeOssPassword: ${{ secrets.SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_sonatypeOssStagingProfileId: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + ORG_GRADLE_PROJECT_sonatypeOssRepo: 'https://s01.oss.sonatype.org/service/local/' + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} with: - arguments: -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg publishToSonatype closeAndReleaseSonatypeStagingRepository - - name: Publish Documentation - id: docs - if: steps.publish.outcome == 'success' - uses: gradle/gradle-build-action@v2 + arguments: | + -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg + publishToSonatype + closeAndReleaseSonatypeStagingRepository + + - name: Generate Documentation + if: success() + uses: gradle/actions/setup-gradle@v3 env: GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} with: arguments: views-docs:docs + - name: Export Gradle Properties uses: micronaut-projects/github-actions/export-gradle-properties@master + - name: Publish to Github Pages - if: steps.docs.outcome == 'success' - uses: micronaut-projects/github-pages-deploy-action@master + if: success() + uses: micronaut-projects/github-pages-deploy-action@grails env: BETA: ${{ contains(steps.release_version.outputs.release_version, 'M') || contains(steps.release_version.outputs.release_version, 'RC') }} GH_TOKEN: ${{ secrets.GH_TOKEN }} @@ -71,10 +74,7 @@ jobs: VERSION: ${{ steps.release_version.outputs.release_version }} COMMIT_EMAIL: ${{ env.GIT_USER_EMAIL }} COMMIT_NAME: ${{ env.GIT_USER_NAME }} + - name: Run post-release if: success() - uses: micronaut-projects/github-actions/post-release@master - with: - token: ${{ secrets.GITHUB_TOKEN }} - env: - SNAPSHOT_SUFFIX: -SNAPSHOT + uses: micronaut-projects/github-actions/post-release@master \ No newline at end of file diff --git a/build.gradle b/build.gradle index a7f7db496..224ef345d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,124 +1,88 @@ -buildscript { - repositories { - maven { url "https://repo.grails.org/grails/core" } - maven { url "https://plugins.gradle.org/m2/" } - } - dependencies { - classpath "io.github.gradle-nexus:publish-plugin:1.3.0" - classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" - } -} +import io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository -ext { - isReleaseVersion = !project.projectVersion.endsWith('-SNAPSHOT') - grailsVersion = project.grailsVersion - userOrg = "grails" +plugins { + id 'groovy' + id 'io.github.gradle-nexus.publish-plugin' + id 'org.asciidoctor.jvm.convert' } -apply plugin:'idea' - -if (isReleaseVersion) { - apply plugin: 'maven-publish' - apply plugin: "io.github.gradle-nexus.publish-plugin" - - nexusPublishing { - repositories { - sonatype { - def ossUser = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : '' - def ossPass = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : '' - def ossStagingProfileId = System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: project.hasProperty("sonatypeOssStagingProfileId") ? project.sonatypeOssStagingProfileId : '' - nexusUrl = uri("https://s01.oss.sonatype.org/service/local/") - username = ossUser - password = ossPass - stagingProfileId = ossStagingProfileId - } +version = projectVersion +ext.set('grailsVersion', libs.versions.grails.asProvider().get()) +ext.set('isSnapshot', version.endsWith('-SNAPSHOT')) +ext.set('isReleaseVersion', !isSnapshot) +ext.set('pomInfo', { + delegate.url 'https://views.grails.org/latest/' + delegate.licenses { + delegate.license { + delegate.name 'The Apache Software License, Version 2.0' + delegate.url 'https://www.apache.org/licenses/LICENSE-2.0.txt' } } -} - -subprojects { subproject-> - - version subproject.projectVersion - - ext['groovyVersion'] = System.getenv('CI_GROOVY_VERSION') ?: project.groovyVersion - - subproject.configurations { - all { - resolutionStrategy { - force 'org.yaml:snakeyaml:1.33' - force 'org.codehaus.groovy:groovy-xml:3.0.13' - force 'org.codehaus.groovy:groovy-sql:3.0.13' - - eachDependency { DependencyResolveDetails details -> - if (details.requested.group == 'org.codehaus.groovy' && - !(details.requested.name in ['groovy-xml', 'groovy-sql'])) { - details.useVersion(groovyVersion) - } - } - } + delegate.scm { + delegate.url 'https://github.com/grails/grails-views/' + delegate.connection 'scm:git:git://github.com/grails/grails-views' + delegate.developerConnection 'scm:git:ssh://github.com:grails/grails-views' + } + delegate.developers { + delegate.developer { + delegate.id 'graemerocher' + delegate.name 'Graeme Rocher' + delegate.email 'graeme.rocher@gmail.com' + } + delegate.developer { + delegate.id 'puneetbehl' + delegate.name 'Puneet Behl' + delegate.email 'behlp@unityfoundation.io' } } +}) +allprojects { + version = rootProject.version repositories { - mavenLocal() + mavenLocal() // Used by Groovy Joint workflow github action after building Groovy mavenCentral() - maven { url "https://repo.grails.org/grails/core" } + maven { url = 'https://repo.grails.org/grails/core' } + if (libs.versions.groovy.get().endsWith('-SNAPSHOT')) { + maven { + name = 'JFrog Groovy snapshot repo' + url = 'https://groovy.jfrog.io/artifactory/libs-snapshot-local' + } + } } - - if (subproject.name.startsWith('examples') || subproject.name.endsWith('docs')) { - return + tasks.withType(Test).configureEach { + useJUnitPlatform() + testLogging { events 'passed', 'skipped', 'failed', 'standardOut', 'standardError' } } - - ext.isGrailsPlugin = subproject.name in ['views-markup', 'views-json'] - - apply plugin: 'eclipse' - apply plugin: 'idea' - apply plugin: 'java-library' - apply plugin: 'groovy' - apply plugin: 'maven-publish' - apply plugin: 'signing' - - if (ext.isGrailsPlugin) { - apply plugin: "org.grails.grails-plugin" + tasks.withType(Jar).configureEach { + manifest.attributes( + 'Built-By': System.properties['user.name'], + 'Created-By': System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")", + 'Implementation-Title': project.findProperty('projectDesc') ?: 'Grails Views', + 'Implementation-Version': project.version, + 'Implementation-Vendor': 'grails.org' + ) } +} - sourceCompatibility = 1.11 - targetCompatibility = 1.11 - - apply from: '../publishing/grailsCentralPublishing.gradle' - - - if (subproject.name in ["views-core", "views-json", "views-markup", "views-json-testing-support"]) { - - configurations { - documentation - } - - dependencies { - documentation "org.fusesource.jansi:jansi:$jansiVersion" - documentation "org.codehaus.groovy:groovy-dateutil:$groovyVersion" - documentation "info.picocli:picocli:4.7.5" - documentation "com.github.javaparser:javaparser-core:$javaParserCoreVersion" - - testImplementation "org.spockframework:spock-core:$spockVersion" - } - - tasks.withType(Test) { - useJUnitPlatform() - testLogging { - showStandardStreams = true - exceptionFormat = 'full' - } - configure { - retry { - maxRetries = 2 - maxFailures = 20 - failOnPassedAfterRetry = true - } +if (isReleaseVersion) { + nexusPublishing { + String ossUser = project.findProperty('sonatypeOssUsername') ?: '' + String ossPass = project.findProperty('sonatypeOssPassword') ?: '' + String ossStagingProfileId = project.findProperty('sonatypeOssStagingProfileId') ?: '' + String ossRepo = project.findProperty('sonatypeOssRepo') ?: '' + repositories { + sonatype { + nexusUrl = uri(ossRepo) + username = ossUser + password = ossPass + stagingProfileId = ossStagingProfileId } } - - groovydoc.classpath = configurations.documentation } - } + +// Do not generate extra load on Nexus with new staging repository if signing fails +tasks.withType(InitializeNexusStagingRepository).configureEach { + shouldRunAfter = tasks.withType(Sign) +} \ No newline at end of file diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 000000000..998d89904 --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,20 @@ +plugins { + id 'groovy-gradle-plugin' +} + +repositories { + mavenCentral() + maven { url = 'https://repo.grails.org/grails/core' } +} + +dependencies { + + // Needs to be implementation, as Asciidoctor task is referenced in docs/build.gradle + implementation buildsrcLibs.asciidoctor.gradle.plugin + + runtimeOnly buildsrcLibs.assetpipeline.gradle.plugin + runtimeOnly buildsrcLibs.nexus.publish.gradle.plugin + runtimeOnly buildsrcLibs.grails.gradle.plugin + runtimeOnly buildsrcLibs.grails.views.gradle.plugin + runtimeOnly buildsrcLibs.groovydoc.gradle.plugin +} \ No newline at end of file diff --git a/buildSrc/settings.gradle b/buildSrc/settings.gradle new file mode 100644 index 000000000..6cd9ab179 --- /dev/null +++ b/buildSrc/settings.gradle @@ -0,0 +1,7 @@ +dependencyResolutionManagement { + versionCatalogs { + buildsrcLibs { + from(files('../gradle/buildsrc.libs.versions.toml')) + } + } +} \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle index 262f7b529..6177e8f6a 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,49 +1,50 @@ -buildscript { - repositories { - maven { url "https://repo.grails.org/grails/core" } - } - dependencies { - classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" - classpath "io.github.gradle-nexus:publish-plugin:1.3.0" - } +plugins { + id 'groovy' + id 'java-library' + id 'maven-publish' + id 'signing' } -group "org.grails" +group = 'org.grails' +ext.set('projectDesc', 'Grails Views Core') -ext { - userOrg = 'grails' - repo = 'grails-core' - isGrailsPlugin = false - projectDesc = "Grails Views Core" -} +// Groovydoc task requires the Groovy version of Gradle +configurations.register('groovydocImplementation') + +dependencies { + + implementation libs.groovy.core + + implementation libs.grails.core + implementation libs.grails.web.urlmappings + implementation libs.grails.mimetypes + implementation libs.grails.datastore.gorm.support + implementation libs.grails.rest -sourceCompatibility = 1.11 -targetCompatibility = 1.11 + implementation libs.slf4j.api -repositories { - mavenCentral() - maven { url "https://repo.grails.org/grails/core" } + api libs.caffeine // Used in public api + + testImplementation libs.spock.core + + groovydocImplementation localGroovy(), { + because 'The Groovydoc task requires the Groovy version of Gradle' + } } -dependencies { - api "org.grails:grails-encoder:$grailsVersion" - api "org.grails:grails-web-common:$grailsVersion" - api "org.grails:grails-web-url-mappings:$grailsVersion" - api "org.grails:grails-plugin-rest:$grailsVersion" - api "com.github.ben-manes.caffeine:caffeine:$caffeineVersion" - api "javax.servlet:javax.servlet-api:$servletApiVersion" +java { + sourceCompatibility = JavaVersion.toVersion(libs.versions.java.baseline.get()) + withJavadocJar() + withSourcesJar() } -if (!tasks.findByName("sourcesJar")) { - tasks.register("sourcesJar", Jar) { - classifier = 'sources' - from project.sourceSets.main.allSource - } +tasks.named('javadocJar', Jar) { + from tasks.named('groovydoc') } -if (!tasks.findByName("javadocJar")) { - tasks.register("javadocJar", Jar) { - classifier = 'javadoc' - from groovydoc.outputs - } +tasks.withType(Groovydoc).configureEach { + classpath = configurations.groovydocImplementation + groovyClasspath = configurations.groovydocImplementation } + +apply from: rootProject.layout.projectDirectory.file('gradle/grailsCentralPublishing.gradle') \ No newline at end of file diff --git a/core/gradle/wrapper/gradle-wrapper.jar b/core/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index e708b1c02..000000000 Binary files a/core/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/core/gradle/wrapper/gradle-wrapper.properties b/core/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index d355f4c4f..000000000 --- a/core/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/core/gradlew b/core/gradlew deleted file mode 100755 index 1b6c78733..000000000 --- a/core/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/core/gradlew.bat b/core/gradlew.bat deleted file mode 100644 index ac1b06f93..000000000 --- a/core/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/core/src/main/groovy/grails/views/AbstractGroovyTemplateCompiler.groovy b/core/src/main/groovy/grails/views/AbstractGroovyTemplateCompiler.groovy index 54e657e22..2221be87b 100644 --- a/core/src/main/groovy/grails/views/AbstractGroovyTemplateCompiler.groovy +++ b/core/src/main/groovy/grails/views/AbstractGroovyTemplateCompiler.groovy @@ -3,6 +3,7 @@ package grails.views import grails.views.compiler.ViewsTransform import grails.views.resolve.GenericGroovyTemplateResolver import groovy.io.FileType +import groovy.transform.CompileStatic import org.codehaus.groovy.control.CompilationUnit import org.codehaus.groovy.control.CompilerConfiguration import org.codehaus.groovy.control.SourceUnit @@ -22,6 +23,7 @@ import java.util.concurrent.Future * @author Graeme Rocher * @since 1.0 */ +@CompileStatic abstract class AbstractGroovyTemplateCompiler { @Delegate CompilerConfiguration configuration = new CompilerConfiguration() @@ -72,7 +74,7 @@ abstract class AbstractGroovyTemplateCompiler { List> futures = [] for(int index=0;index < collatedSources.size();index++) { def sourceFiles = collatedSources[index] - futures << completionService.submit({ -> + futures.add(completionService.submit({ -> CompilerConfiguration configuration = new CompilerConfiguration(this.configuration) for(int viewIndex=0;viewIndex < sourceFiles.size();viewIndex++) { File source = sourceFiles[viewIndex] @@ -93,7 +95,7 @@ abstract class AbstractGroovyTemplateCompiler { unit.compile() } return true - } as Callable) + } as Callable) as Future) } int pending = futures.size() @@ -137,14 +139,14 @@ Usage: java -cp CLASSPATH ${compilerClass.name} [srcDir] [destDir] [targetCompat File configFile = new File(args[5]) String encoding = new File(args[6]) - GenericViewConfiguration configuration = configurationClass.newInstance() + GenericViewConfiguration configuration = configurationClass.getDeclaredConstructor().newInstance() configuration.packageName = packageName configuration.encoding = encoding configuration.packageImports = packageImports configuration.readConfiguration(configFile) - AbstractGroovyTemplateCompiler compiler = compilerClass.newInstance(configuration, srcDir) + AbstractGroovyTemplateCompiler compiler = compilerClass.getDeclaredConstructor(ViewConfiguration, File).newInstance(configuration, srcDir) compiler.setTargetDirectory( destinationDir ) compiler.setSourceEncoding( configuration.encoding ) if(targetCompatibility != null) { diff --git a/core/src/main/groovy/grails/views/GenericViewConfiguration.groovy b/core/src/main/groovy/grails/views/GenericViewConfiguration.groovy index 4592d5b43..1667c9d35 100644 --- a/core/src/main/groovy/grails/views/GenericViewConfiguration.groovy +++ b/core/src/main/groovy/grails/views/GenericViewConfiguration.groovy @@ -107,7 +107,7 @@ trait GenericViewConfiguration implements ViewConfiguration, GrailsApplicationAw for (PropertyDescriptor desc in descriptors) { if (desc.writeMethod != null) { String propertyName = desc.name - Object value + Object value = null if (desc.propertyType == Class) { String className = config.getProperty("grails.views.${moduleName}.$propertyName".toString(), String) if (className) { diff --git a/core/src/main/groovy/grails/views/TemplateResolver.groovy b/core/src/main/groovy/grails/views/TemplateResolver.groovy index 0b0847d78..d8792001c 100644 --- a/core/src/main/groovy/grails/views/TemplateResolver.groovy +++ b/core/src/main/groovy/grails/views/TemplateResolver.groovy @@ -1,6 +1,7 @@ package grails.views import groovy.text.Template +import groovy.transform.CompileStatic /** * Interface for resolving templates @@ -8,6 +9,7 @@ import groovy.text.Template * @author Graeme Rocher * @since 1.0 */ +@CompileStatic interface TemplateResolver { /** diff --git a/core/src/main/groovy/grails/views/ViewCompilationException.groovy b/core/src/main/groovy/grails/views/ViewCompilationException.groovy index cc3824989..eabd6380a 100644 --- a/core/src/main/groovy/grails/views/ViewCompilationException.groovy +++ b/core/src/main/groovy/grails/views/ViewCompilationException.groovy @@ -1,5 +1,6 @@ package grails.views +import groovy.transform.CompileStatic import org.codehaus.groovy.ast.ASTNode import org.codehaus.groovy.control.CompilationFailedException import org.codehaus.groovy.control.MultipleCompilationErrorsException @@ -12,6 +13,7 @@ import org.grails.exceptions.reporting.SourceCodeAware * @author Graeme Rocher * @since 1.0 */ +@CompileStatic class ViewCompilationException extends ViewException implements SourceCodeAware { final String fileName diff --git a/core/src/main/groovy/grails/views/ViewConfiguration.groovy b/core/src/main/groovy/grails/views/ViewConfiguration.groovy index 6bd97a86b..bd79bc855 100644 --- a/core/src/main/groovy/grails/views/ViewConfiguration.groovy +++ b/core/src/main/groovy/grails/views/ViewConfiguration.groovy @@ -1,11 +1,14 @@ package grails.views +import groovy.transform.CompileStatic + /** * Interface for view configurations * * @author Graeme Rocher * @since 1.0 */ +@CompileStatic interface ViewConfiguration { /** * @return Should compile statically diff --git a/core/src/main/groovy/grails/views/ViewException.groovy b/core/src/main/groovy/grails/views/ViewException.groovy index ed7b66504..270ee9d42 100644 --- a/core/src/main/groovy/grails/views/ViewException.groovy +++ b/core/src/main/groovy/grails/views/ViewException.groovy @@ -1,5 +1,6 @@ package grails.views +import groovy.transform.CompileStatic import groovy.transform.InheritConstructors /** @@ -7,6 +8,7 @@ import groovy.transform.InheritConstructors * * @author Graeme Rocher */ +@CompileStatic @InheritConstructors class ViewException extends RuntimeException{ } diff --git a/core/src/main/groovy/grails/views/ViewUriResolver.groovy b/core/src/main/groovy/grails/views/ViewUriResolver.groovy index 86820cf74..0609116cd 100644 --- a/core/src/main/groovy/grails/views/ViewUriResolver.groovy +++ b/core/src/main/groovy/grails/views/ViewUriResolver.groovy @@ -1,11 +1,14 @@ package grails.views +import groovy.transform.CompileStatic + /** * A ViewUriResolver is response for response template and view URIs using Grails' conventions. * * * @author Graeme Rocher */ +@CompileStatic interface ViewUriResolver { /** * Resolves a template URI for the given path diff --git a/core/src/main/groovy/grails/views/Views.groovy b/core/src/main/groovy/grails/views/Views.groovy index ce52dbf7b..22cf59845 100644 --- a/core/src/main/groovy/grails/views/Views.groovy +++ b/core/src/main/groovy/grails/views/Views.groovy @@ -1,10 +1,13 @@ package grails.views +import groovy.transform.CompileStatic + /** * Settings and constants for the Groovy view infrastructure * * @author Graeme Rocher */ +@CompileStatic interface Views { /** diff --git a/core/src/main/groovy/grails/views/ViewsEnvironment.groovy b/core/src/main/groovy/grails/views/ViewsEnvironment.groovy index 59d160999..69b08a71b 100644 --- a/core/src/main/groovy/grails/views/ViewsEnvironment.groovy +++ b/core/src/main/groovy/grails/views/ViewsEnvironment.groovy @@ -2,14 +2,16 @@ package grails.views import grails.util.BuildSettings import grails.util.Environment +import groovy.transform.CompileStatic /** * Environment helper methods * * @author Graeme Rocher */ +@CompileStatic class ViewsEnvironment { - private static final boolean DEVELOPMENT_MODE = Environment.getCurrent() == Environment.DEVELOPMENT && BuildSettings.GRAILS_APP_DIR_PRESENT; + private static final boolean DEVELOPMENT_MODE = Environment.getCurrent() == Environment.DEVELOPMENT && BuildSettings.GRAILS_APP_DIR_PRESENT /** * @return Whether development mode is enabled diff --git a/core/src/main/groovy/grails/views/WritableScript.groovy b/core/src/main/groovy/grails/views/WritableScript.groovy index 5d6df9e59..75026066f 100644 --- a/core/src/main/groovy/grails/views/WritableScript.groovy +++ b/core/src/main/groovy/grails/views/WritableScript.groovy @@ -1,11 +1,14 @@ package grails.views +import groovy.transform.CompileStatic + /** * Interface for scripts that are writable * * @author Graeme Rocher * @since 1.0 */ +@CompileStatic interface WritableScript extends Writable, WriterProvider { /** diff --git a/core/src/main/groovy/grails/views/WritableScriptTemplate.groovy b/core/src/main/groovy/grails/views/WritableScriptTemplate.groovy index a40ff409e..82481da43 100644 --- a/core/src/main/groovy/grails/views/WritableScriptTemplate.groovy +++ b/core/src/main/groovy/grails/views/WritableScriptTemplate.groovy @@ -120,8 +120,7 @@ class WritableScriptTemplate implements Template { @Override Writable make(Map binding) { - WritableScript writableTemplate = templateClass - .newInstance() + WritableScript writableTemplate = templateClass.getDeclaredConstructor().newInstance() writableTemplate.viewTemplate = (GrailsViewTemplate)this writableTemplate.prettyPrint = prettyPrint if(!binding.isEmpty()) { diff --git a/core/src/main/groovy/grails/views/WriterProvider.groovy b/core/src/main/groovy/grails/views/WriterProvider.groovy index 9a026a4c7..a1e09e206 100644 --- a/core/src/main/groovy/grails/views/WriterProvider.groovy +++ b/core/src/main/groovy/grails/views/WriterProvider.groovy @@ -1,10 +1,13 @@ package grails.views +import groovy.transform.CompileStatic + /** * Interface for views that provider a writer * * @author Graeme Rocher */ +@CompileStatic interface WriterProvider { /** diff --git a/core/src/main/groovy/grails/views/api/GrailsViewHelper.groovy b/core/src/main/groovy/grails/views/api/GrailsViewHelper.groovy index f5dfb65ea..5203a7ecc 100644 --- a/core/src/main/groovy/grails/views/api/GrailsViewHelper.groovy +++ b/core/src/main/groovy/grails/views/api/GrailsViewHelper.groovy @@ -1,12 +1,14 @@ package grails.views.api import grails.web.mapping.LinkGenerator +import groovy.transform.CompileStatic /** * Methods available via the 'g' namespace in views * * @author Graeme Rocher */ +@CompileStatic interface GrailsViewHelper extends LinkGenerator { diff --git a/core/src/main/groovy/grails/views/api/HttpView.groovy b/core/src/main/groovy/grails/views/api/HttpView.groovy index f9763417f..56d6e3d91 100644 --- a/core/src/main/groovy/grails/views/api/HttpView.groovy +++ b/core/src/main/groovy/grails/views/api/HttpView.groovy @@ -4,6 +4,7 @@ import grails.views.api.http.Parameters import grails.views.api.http.Request import grails.views.api.http.Response import grails.views.api.internal.EmptyParameters +import groovy.transform.CompileStatic /** * A view that is rendered in the context of an HTTP request @@ -11,6 +12,7 @@ import grails.views.api.internal.EmptyParameters * @author Graeme Rocher * @since 1.0 */ +@CompileStatic trait HttpView extends View { /** diff --git a/core/src/main/groovy/grails/views/api/View.groovy b/core/src/main/groovy/grails/views/api/View.groovy index be7e5c34b..602758639 100644 --- a/core/src/main/groovy/grails/views/api/View.groovy +++ b/core/src/main/groovy/grails/views/api/View.groovy @@ -1,9 +1,12 @@ package grails.views.api +import groovy.transform.CompileStatic + /** * @author Graeme Rocher * @since 1.0 */ +@CompileStatic trait View { /** diff --git a/core/src/main/groovy/grails/views/api/http/Parameters.groovy b/core/src/main/groovy/grails/views/api/http/Parameters.groovy index 801cd3850..86431f483 100644 --- a/core/src/main/groovy/grails/views/api/http/Parameters.groovy +++ b/core/src/main/groovy/grails/views/api/http/Parameters.groovy @@ -1,11 +1,14 @@ package grails.views.api.http +import groovy.transform.CompileStatic + /** * Represents HTTP parameters * * @author Graeme Rocher * @since 1.1.0 */ +@CompileStatic interface Parameters { /** diff --git a/core/src/main/groovy/grails/views/api/http/Request.groovy b/core/src/main/groovy/grails/views/api/http/Request.groovy index d7995fac7..405c7bbd7 100644 --- a/core/src/main/groovy/grails/views/api/http/Request.groovy +++ b/core/src/main/groovy/grails/views/api/http/Request.groovy @@ -1,8 +1,11 @@ package grails.views.api.http +import groovy.transform.CompileStatic + /** * Allows access to request properties */ +@CompileStatic interface Request { /** * @return The context path diff --git a/core/src/main/groovy/grails/views/api/http/Response.groovy b/core/src/main/groovy/grails/views/api/http/Response.groovy index eeeb19889..ea066878f 100644 --- a/core/src/main/groovy/grails/views/api/http/Response.groovy +++ b/core/src/main/groovy/grails/views/api/http/Response.groovy @@ -1,10 +1,12 @@ package grails.views.api.http +import groovy.transform.CompileStatic import org.springframework.http.HttpStatus /** * Allows control over the page response (headers, content type, status) */ +@CompileStatic interface Response { /** diff --git a/core/src/main/groovy/grails/views/api/internal/DefaultGrailsViewHelper.groovy b/core/src/main/groovy/grails/views/api/internal/DefaultGrailsViewHelper.groovy index 820426736..f9003367e 100644 --- a/core/src/main/groovy/grails/views/api/internal/DefaultGrailsViewHelper.groovy +++ b/core/src/main/groovy/grails/views/api/internal/DefaultGrailsViewHelper.groovy @@ -6,7 +6,6 @@ import grails.web.mapping.LinkGenerator import groovy.transform.CompileStatic import org.springframework.context.MessageSourceResolvable import org.springframework.context.NoSuchMessageException -import org.springframework.context.support.DefaultMessageSourceResolvable /** * Default methods for views, additional methods can be added via traits diff --git a/core/src/main/groovy/grails/views/compiler/BuilderTypeCheckingExtension.groovy b/core/src/main/groovy/grails/views/compiler/BuilderTypeCheckingExtension.groovy index d2f349894..99a6237d3 100644 --- a/core/src/main/groovy/grails/views/compiler/BuilderTypeCheckingExtension.groovy +++ b/core/src/main/groovy/grails/views/compiler/BuilderTypeCheckingExtension.groovy @@ -1,6 +1,8 @@ package grails.views.compiler import grails.views.Views +import groovy.transform.CompileDynamic +import groovy.transform.CompileStatic import org.codehaus.groovy.ast.ClassCodeExpressionTransformer import org.codehaus.groovy.ast.ClassNode import org.codehaus.groovy.ast.MethodNode @@ -24,11 +26,13 @@ import static org.codehaus.groovy.ast.ClassHelper.OBJECT_TYPE * @author Graeme Rocher * @since 1.0 */ +@CompileStatic abstract class BuilderTypeCheckingExtension extends GroovyTypeCheckingExtensionSupport.TypeCheckingDSL { boolean insideScope = true @Override + @CompileDynamic Object run() { BuilderTypeCheckingExtension self = this @@ -157,6 +161,7 @@ abstract class BuilderTypeCheckingExtension extends GroovyTypeCheckingExtensionS } @Override + @CompileDynamic Expression transform(final Expression exp) { if (callsToBeReplaced.contains(exp)) { def args = exp.arguments instanceof TupleExpression ? exp.arguments.expressions : [exp.arguments] diff --git a/core/src/main/groovy/grails/views/utils/ViewUtils.groovy b/core/src/main/groovy/grails/views/utils/ViewUtils.groovy index 6a4263013..fdf9b4d1a 100644 --- a/core/src/main/groovy/grails/views/utils/ViewUtils.groovy +++ b/core/src/main/groovy/grails/views/utils/ViewUtils.groovy @@ -43,7 +43,7 @@ class ViewUtils { if(map.containsKey(key)) { def o = map.get(key) if(o instanceof Iterable) { - return (List)((Iterable)o).toList() + return ((Iterable)o).toList() as List } else { return Arrays.asList(o.toString()) diff --git a/core/src/test/groovy/grails/views/GenericViewConfigurationSpec.groovy b/core/src/test/groovy/grails/views/GenericViewConfigurationSpec.groovy index f387b8162..8b43992ad 100644 --- a/core/src/test/groovy/grails/views/GenericViewConfigurationSpec.groovy +++ b/core/src/test/groovy/grails/views/GenericViewConfigurationSpec.groovy @@ -1,11 +1,12 @@ package grails.views -import grails.util.GrailsUtil + import org.grails.config.CodeGenConfig import org.springframework.beans.BeanUtils -import java.beans.PropertyDescriptor import spock.lang.Specification +import java.beans.PropertyDescriptor + class GenericViewConfigurationSpec extends Specification { void "test setting of boolean"() { diff --git a/docs/build.gradle b/docs/build.gradle index 7ee559494..ef9181383 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -1,80 +1,57 @@ -buildscript { - repositories { - maven { - url "https://plugins.gradle.org/m2/" - } - } - dependencies { - classpath("org.asciidoctor:asciidoctor-gradle-jvm:4.0.1") - } -} +import org.asciidoctor.gradle.jvm.AsciidoctorTask -apply plugin: "org.asciidoctor.jvm.convert" - -repositories { - maven { url "https://repo.grails.org/grails/core" } +plugins { + id 'org.asciidoctor.jvm.convert' } -asciidoctor { - - baseDirFollowsSourceFile() +tasks.withType(AsciidoctorTask).configureEach { + baseDirFollowsSourceFile() - resources { - from 'src/docs/images' - into './images' - } + /* No src/docs/images directory in project + resources { from 'src/docs/images'; into './images' } + */ - attributes 'experimental' : 'true', - 'compat-mode' : 'true', - 'toc' : 'left', - 'icons' : 'font', - 'version' : version, - 'sourcedir' : "${rootProject.allprojects.find { it.name == 'views-core'}.projectDir}/src/main/groovy" + /* sourcedir attribute not used in asciidoc sources + def coreSourceDir = rootProject.allprojects.find({ it.name == 'views-core'}).layout.projectDirectory.dir('src/main/groovy').asFile + */ + attributes 'experimental' : 'true', + 'compat-mode' : 'true', + 'toc' : 'left', + 'icons' : 'font', + 'version' : version + //'sourcedir' : coreSourceDir } -configurations { - documentation.extendsFrom(compileClasspath) - documentation { - attributes { - attribute(Bundling.BUNDLING_ATTRIBUTE, (Bundling) objects.named(Bundling, 'external')) - attribute(DocsType.DOCS_TYPE_ATTRIBUTE, (DocsType) objects.named(DocsType, 'javadoc')) - } - } -} +// Groovydoc task requires the Groovy version of Gradle +configurations.register('groovydocImplementation') dependencies { - documentation project(path: ':views-json') - documentation project(path: ':views-markup') - documentation project(path: ':views-gradle') + groovydocImplementation localGroovy(), { + because 'The Groovydoc task requires the Groovy version of Gradle' + } } -task apidocs(type: Groovydoc, group: 'documentation') { - def allProjects = rootProject.allprojects.findAll { project -> - ['views-core', 'views-json', 'views-json-testing-support', 'views-markup','views-gradle'].contains(project.name) - } - source allProjects.collect { project -> - project.files('src/main/groovy') - } +tasks.register('apidocs', Groovydoc) { + + group = 'documentation' + docTitle = "Grails Views $version" - destinationDir = new File(buildDir, 'docs/api') - // Might need a classpath - docTitle = "Grails Views ${version}" - - classpath = configurations.documentation - groovyClasspath = configurations.documentation + def projectNames = ['views-core', 'views-json', 'views-json-testing-support', 'views-markup','views-gradle'] + def projects = rootProject.allprojects.findAll { it.name in projectNames } + source projects.collect { it.layout.projectDirectory.dir('src/main/groovy') } + destinationDir = layout.buildDirectory.dir('docs/api').get().asFile } -tasks.withType(org.gradle.api.tasks.javadoc.Groovydoc) { - configure { - access = GroovydocAccess.PRIVATE - processScripts = false - includeMainForScripts = false - includeAuthor = true - groovyClasspath = configurations.documentation - } +tasks.withType(Groovydoc).configureEach { + access = GroovydocAccess.PRIVATE + processScripts = false + includeMainForScripts = false + includeAuthor = true + classpath = configurations.groovydocImplementation + groovyClasspath = configurations.groovydocImplementation } -task docs(type:Copy, dependsOn:[apidocs, asciidoctor], group:'documentation') { - from "$buildDir/asciidoc/html5" - into "$buildDir/docs" +tasks.register('docs') { + group = 'documentation' + dependsOn 'apidocs', 'asciidoctor' } diff --git a/examples/functional-tests-plugin/build.gradle b/examples/functional-tests-plugin/build.gradle index 98b783c5d..a8980af4b 100644 --- a/examples/functional-tests-plugin/build.gradle +++ b/examples/functional-tests-plugin/build.gradle @@ -1,61 +1,17 @@ -buildscript { - repositories { - maven { url "https://repo.grails.org/grails/core" } - } - dependencies { - classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" - classpath "org.grails.plugins:views-gradle:$viewsGradleVersion" - } +plugins { + id 'java-library' + id 'org.grails.grails-plugin' + id 'org.grails.plugins.views-json' } -version "0.1-SNAPSHOT" -group "org.grails.plugins" - -apply plugin: 'eclipse' -apply plugin: 'idea' -apply plugin: 'java-library' -apply plugin: 'maven-publish' -apply plugin: "org.grails.grails-plugin" -apply plugin: "org.grails.plugins.views-json" -//apply plugin: "org.grails.plugins.views-markup" - -sourceCompatibility = 1.11 -targetCompatibility = 1.11 - -repositories { - mavenCentral() - maven { url "https://repo.grails.org/grails/core" } -} +group = 'functional.tests.plugin' dependencies { - api 'org.springframework.boot:spring-boot-starter-logging' - api "org.springframework.boot:spring-boot-starter-actuator" - api "org.springframework.boot:spring-boot-autoconfigure" - api "org.springframework.boot:spring-boot-starter-tomcat" - - api "org.grails:grails-web-boot" - api "org.grails:grails-dependencies" - api "javax.servlet:javax.servlet-api:$servletApiVersion" - - api project(":views-json") - api project(":views-markup") -} - -tasks.withType(Test) { - useJUnitPlatform() - testLogging { - showStandardStreams = true - exceptionFormat = 'full' - } - configure { - retry { - maxRetries = 2 - maxFailures = 20 - failOnPassedAfterRetry = true - } - } + implementation project(':views-json') + implementation 'org.grails:grails-plugin-rest' + compileOnly libs.slf4j.nop // Used for getting rid of warning about missing slf4j implementation during compileGsonViews task } -compileGsonViews { - classpath += configurations.compileClasspath -} +java { + sourceCompatibility = JavaVersion.toVersion(libs.versions.java.baseline.get()) +} \ No newline at end of file diff --git a/examples/functional-tests-plugin/gradle.properties b/examples/functional-tests-plugin/gradle.properties deleted file mode 100644 index b9ad9b25d..000000000 --- a/examples/functional-tests-plugin/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -grailsVersion=6.0.0 -grailsGradlePluginVersion=6.0.0 -viewsGradleVersion=3.0.0 \ No newline at end of file diff --git a/examples/functional-tests-plugin/grails-app/conf/application.yml b/examples/functional-tests-plugin/grails-app/conf/application.yml index e06899a51..95071ef41 100644 --- a/examples/functional-tests-plugin/grails-app/conf/application.yml +++ b/examples/functional-tests-plugin/grails-app/conf/application.yml @@ -1,117 +1,4 @@ ---- grails: profile: web-plugin codegen: defaultPackage: functional.tests.plugin -info: - app: - name: '@info.app.name@' - version: '@info.app.version@' - grailsVersion: '@info.app.grailsVersion@' -spring: - groovy: - template: - check-template-location: false - ---- -grails: - mime: - disable: - accept: - header: - userAgents: - - Gecko - - WebKit - - Presto - - Trident - types: - json: - - application/json - - text/json - hal: - - application/hal+json - - application/hal+xml - xml: - - text/xml - - application/xml - atom: application/atom+xml - css: text/css - csv: text/csv - js: text/javascript - rss: application/rss+xml - text: text/plain - form: appication/x-www-form-urlencoded - html: - - text/html - - application/xhtml+xml - multipartForm: multipart/form-data - pdf: application/pdf - all: '*/*' - urlmapping: - cache: - maxsize: 1000 - controllers: - defaultScope: singleton - converters: - encoding: UTF-8 - views: - default: - codec: html - gsp: - encoding: UTF-8 - htmlcodec: xml - codecs: - expression: html - scriptlets: html - taglib: none - staticparts: none ---- -hibernate: - cache: - queries: false - use_second_level_cache: true - use_query_cache: false - region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory' - -endpoints: - jmx: - unique-names: true - -dataSource: - pooled: true - jmxExport: true - driverClassName: org.h2.Driver - username: sa - password: - -environments: - development: - dataSource: - dbCreate: create-drop - url: jdbc:h2:mem:devDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE - test: - dataSource: - dbCreate: update - url: jdbc:h2:mem:testDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE - production: - dataSource: - dbCreate: update - url: jdbc:h2:./prodDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE - properties: - jmxEnabled: true - initialSize: 5 - maxActive: 50 - minIdle: 5 - maxIdle: 25 - maxWait: 10000 - maxAge: 600000 - timeBetweenEvictionRunsMillis: 5000 - minEvictableIdleTimeMillis: 60000 - validationQuery: SELECT 1 - validationQueryTimeout: 3 - validationInterval: 15000 - testOnBorrow: true - testWhileIdle: true - testOnReturn: false - jdbcInterceptors: ConnectionState - defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED diff --git a/examples/functional-tests-plugin/grails-app/conf/logback.xml b/examples/functional-tests-plugin/grails-app/conf/logback.xml deleted file mode 100644 index f4e778361..000000000 --- a/examples/functional-tests-plugin/grails-app/conf/logback.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - UTF-8 - '%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex' - - - - - - - \ No newline at end of file diff --git a/examples/functional-tests-plugin/grails-app/controllers/functional/tests/plugin/AuthorController.groovy b/examples/functional-tests-plugin/grails-app/controllers/functional/tests/plugin/AuthorController.groovy index d262d5709..915b924b4 100644 --- a/examples/functional-tests-plugin/grails-app/controllers/functional/tests/plugin/AuthorController.groovy +++ b/examples/functional-tests-plugin/grails-app/controllers/functional/tests/plugin/AuthorController.groovy @@ -1,7 +1,9 @@ package functional.tests.plugin +import grails.compiler.GrailsCompileStatic import grails.rest.RestfulController +@GrailsCompileStatic class AuthorController extends RestfulController { static responseFormats = ['json'] diff --git a/examples/functional-tests-plugin/grails-app/domain/functional/tests/plugin/Author.groovy b/examples/functional-tests-plugin/grails-app/domain/functional/tests/plugin/Author.groovy index 2a5ef0861..838d537f2 100644 --- a/examples/functional-tests-plugin/grails-app/domain/functional/tests/plugin/Author.groovy +++ b/examples/functional-tests-plugin/grails-app/domain/functional/tests/plugin/Author.groovy @@ -1,5 +1,8 @@ package functional.tests.plugin +import grails.compiler.GrailsCompileStatic + +@GrailsCompileStatic class Author { String name diff --git a/examples/functional-tests-plugin/grails-app/init/functional/tests/plugin/Application.groovy b/examples/functional-tests-plugin/grails-app/init/functional/tests/plugin/Application.groovy index b6c4cb186..4f186993f 100644 --- a/examples/functional-tests-plugin/grails-app/init/functional/tests/plugin/Application.groovy +++ b/examples/functional-tests-plugin/grails-app/init/functional/tests/plugin/Application.groovy @@ -2,7 +2,11 @@ package functional.tests.plugin import grails.boot.GrailsApp import grails.boot.config.GrailsAutoConfiguration +import grails.plugins.metadata.PluginSource +import groovy.transform.CompileStatic +@PluginSource +@CompileStatic class Application extends GrailsAutoConfiguration { static void main(String[] args) { GrailsApp.run(Application, args) diff --git a/examples/functional-tests-plugin/grails-app/views/author/_author.gson b/examples/functional-tests-plugin/grails-app/views/author/_author.gson index 65bbb0aeb..5a4626812 100644 --- a/examples/functional-tests-plugin/grails-app/views/author/_author.gson +++ b/examples/functional-tests-plugin/grails-app/views/author/_author.gson @@ -1,7 +1,6 @@ import functional.tests.plugin.Author +import groovy.transform.Field -model { - Author author -} +@Field Author author = null json g.render(author) diff --git a/examples/functional-tests-plugin/grails-app/views/author/index.gson b/examples/functional-tests-plugin/grails-app/views/author/index.gson index a6f63657c..754529be9 100644 --- a/examples/functional-tests-plugin/grails-app/views/author/index.gson +++ b/examples/functional-tests-plugin/grails-app/views/author/index.gson @@ -1,7 +1,6 @@ import functional.tests.plugin.Author +import groovy.transform.Field -model { - Iterable authorList -} +@Field Iterable authorList = null json tmpl.author(authorList ?: []) diff --git a/examples/functional-tests-plugin/grails-app/views/author/show.gson b/examples/functional-tests-plugin/grails-app/views/author/show.gson index 185aae2c3..16a392bd0 100644 --- a/examples/functional-tests-plugin/grails-app/views/author/show.gson +++ b/examples/functional-tests-plugin/grails-app/views/author/show.gson @@ -1,7 +1,6 @@ import functional.tests.plugin.Author +import groovy.transform.Field -model { - Author author -} +@Field Author author = null json tmpl.author(author) diff --git a/examples/functional-tests/build.gradle b/examples/functional-tests/build.gradle index 434ff5cc8..ca15003a1 100644 --- a/examples/functional-tests/build.gradle +++ b/examples/functional-tests/build.gradle @@ -1,103 +1,57 @@ -buildscript { - repositories { - maven { url "https://repo.grails.org/grails/core" } - } - dependencies { - classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" - classpath "org.grails.plugins:views-gradle:$viewsGradleVersion" - classpath "com.bertramlabs.plugins:asset-pipeline-gradle:$assetPipelineVersion" - } +plugins { + id 'application' + id 'com.bertramlabs.asset-pipeline' + id 'groovy' + id 'org.grails.grails-gsp' + id 'org.grails.grails-web' } -version "0.1" -group "functional.tests" +group = 'functional.tests' -apply plugin: "eclipse" -apply plugin: "idea" -apply plugin: "war" -apply plugin: "com.bertramlabs.asset-pipeline" -apply plugin: "org.grails.grails-web" -apply plugin: "org.grails.grails-gsp" - -// uncommenting fails because we have functional tests for compilation errors -//apply plugin: "org.grails.plugins.views-json" -//apply plugin: "org.grails.plugins.views-markup" - -assets { - minifyJs = true - minifyCss = true -} - -repositories { - maven { url "https://repo.grails.org/grails/core" } -} +dependencies { -configurations.configureEach { - resolutionStrategy.eachDependency { DependencyResolveDetails details -> - if (details.requested.group == 'org.grails' && - details.requested.name.startsWith('grails-datastore')) { - if (details.requested.name.equals("grails-datastore-gorm-hibernate5")) { - details.useVersion("$hibernateGormVersion") - } else if (details.requested.name.startsWith("grails-datastore-gorm-mongodb") || - details.requested.name.equals("grails-datastore-gorm-bson")) { - details.useVersion("$mongodbVersion") - } else { - details.useVersion("$gormVersion") - } - } else if (details.requested.group == 'org.mongodb' && details.requested.module.name != 'mongodb-driver-rx') { - details.useVersion(mongodbDriverVersion) - } else if (details.requested.group == 'org.grails.plugins') { - if (details.requested.name == 'hibernate5') { - details.useVersion(hibernateGormVersion) - } else if (details.requested.name == 'mongodb') { - details.useVersion(mongodbVersion) - } - } + implementation project(':examples-functional-tests-plugin') + implementation project(':views-json') + implementation project(':views-markup') - } - resolutionStrategy.cacheChangingModulesFor 0, 'seconds' -} + runtimeOnly project(':views-json-templates') + testImplementation project(':views-json-testing-support') -dependencies { - implementation "org.springframework.boot:spring-boot-starter-logging" - implementation "org.springframework.boot:spring-boot-starter-actuator" - implementation "org.springframework.boot:spring-boot-autoconfigure" - implementation "org.springframework.boot:spring-boot-starter-tomcat" - implementation "org.grails:grails-dependencies" - implementation "org.grails:grails-web-boot" + implementation 'org.grails:grails-core' + implementation 'org.grails:grails-logging' + implementation 'org.grails:grails-web-boot' - implementation "org.grails.plugins:hibernate5" - implementation "org.grails.plugins:mongodb" - implementation "org.grails.plugins:cache" - implementation "org.hibernate:hibernate-ehcache" - implementation "org.grails.plugins:scaffolding" + implementation 'org.grails:grails-plugin-databinding' + implementation 'org.grails:grails-plugin-i18n' + implementation 'org.grails:grails-plugin-interceptors' + implementation 'org.grails:grails-plugin-rest' + implementation 'org.grails:grails-plugin-services' + implementation 'org.grails:grails-plugin-url-mappings' + implementation 'org.grails:grails-plugin-validation' - implementation project(":views-json") - implementation project(":views-markup") - implementation project(":examples-functional-tests-plugin") + 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 - runtimeOnly "org.apache.tomcat:tomcat-jdbc:9.0.13" - runtimeOnly "com.bertramlabs.plugins:asset-pipeline-grails:$assetPipelineVersion" - runtimeOnly project(":views-json-templates") + implementation 'org.springframework.boot:spring-boot-autoconfigure' + implementation 'org.springframework.boot:spring-boot-starter-logging' + implementation 'org.springframework.boot:spring-boot-starter-tomcat' - testImplementation project(":views-json-testing-support") + runtimeOnly 'com.h2database:h2' + runtimeOnly 'org.apache.tomcat:tomcat-jdbc' + runtimeOnly libs.assetpipeline - testImplementation "io.micronaut:micronaut-http-client:$micronautVersion" + testImplementation libs.grails.testing.support.core + testImplementation libs.micronaut.http.client } -integrationTest { - testLogging { - showStandardStreams = true - exceptionFormat = 'full' - } +assets { + minifyJs = true + minifyCss = true } -tasks.withType(Test) { - useJUnitPlatform() - testLogging { - showStandardStreams = true - exceptionFormat = 'full' - } -} +java { + sourceCompatibility = JavaVersion.toVersion(libs.versions.java.baseline.get()) +} \ No newline at end of file diff --git a/examples/functional-tests/gradle.properties b/examples/functional-tests/gradle.properties deleted file mode 100644 index b9ad9b25d..000000000 --- a/examples/functional-tests/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -grailsVersion=6.0.0 -grailsGradlePluginVersion=6.0.0 -viewsGradleVersion=3.0.0 \ No newline at end of file diff --git a/examples/functional-tests/grails-app/conf/application.yml b/examples/functional-tests/grails-app/conf/application.yml index 9f748d7f2..8212747b7 100644 --- a/examples/functional-tests/grails-app/conf/application.yml +++ b/examples/functional-tests/grails-app/conf/application.yml @@ -12,7 +12,10 @@ 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: @@ -69,9 +72,9 @@ grails: hibernate: cache: queries: false - use_second_level_cache: true + use_second_level_cache: false use_query_cache: false - region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory' + #region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory' endpoints: jmx: 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 b28748ab7..d178f3e95 100644 --- a/examples/functional-tests/grails-app/controllers/functional/tests/PlaceController.groovy +++ b/examples/functional-tests/grails-app/controllers/functional/tests/PlaceController.groovy @@ -17,3 +17,8 @@ class PlaceController { respond new Place(name: "London", location: Point.valueOf(10,10)) } } + +class Place { + String name + Point location +} \ No newline at end of file diff --git a/examples/functional-tests/grails-app/domain/functional/tests/Bus.groovy b/examples/functional-tests/grails-app/domain/functional/tests/Bus.groovy index 225e6a6fe..c5002172b 100644 --- a/examples/functional-tests/grails-app/domain/functional/tests/Bus.groovy +++ b/examples/functional-tests/grails-app/domain/functional/tests/Bus.groovy @@ -2,4 +2,9 @@ package functional.tests class Bus extends Vehicle { String route + + static mapping = { + discriminator column: 'vehicleClass' + } + } diff --git a/examples/functional-tests/grails-app/domain/functional/tests/Car.groovy b/examples/functional-tests/grails-app/domain/functional/tests/Car.groovy index e078ede28..36f0c3f2b 100644 --- a/examples/functional-tests/grails-app/domain/functional/tests/Car.groovy +++ b/examples/functional-tests/grails-app/domain/functional/tests/Car.groovy @@ -4,4 +4,9 @@ class Car extends Vehicle { String make String model Integer year + + static mapping = { + discriminator column: 'vehicleClass' + year column: '`year`' + } } diff --git a/examples/functional-tests/grails-app/domain/functional/tests/Place.groovy b/examples/functional-tests/grails-app/domain/functional/tests/Place.groovy deleted file mode 100644 index 7959774b5..000000000 --- a/examples/functional-tests/grails-app/domain/functional/tests/Place.groovy +++ /dev/null @@ -1,13 +0,0 @@ -package functional.tests - -import grails.mongodb.geo.Point - -/** - * Created by graemerocher on 19/05/16. - */ -class Place { - String name - Point location - - static mapWith = "mongo" -} diff --git a/examples/functional-tests/grails-app/domain/functional/tests/User.groovy b/examples/functional-tests/grails-app/domain/functional/tests/User.groovy index 0a4161a9f..10851d002 100644 --- a/examples/functional-tests/grails-app/domain/functional/tests/User.groovy +++ b/examples/functional-tests/grails-app/domain/functional/tests/User.groovy @@ -3,4 +3,8 @@ package functional.tests class User { String publicId String username + + static mapping = { + table name: '`user`' + } } diff --git a/examples/functional-tests/grails-app/init/BootStrap.groovy b/examples/functional-tests/grails-app/init/BootStrap.groovy index 0f514b8fe..a13e4aedb 100644 --- a/examples/functional-tests/grails-app/init/BootStrap.groovy +++ b/examples/functional-tests/grails-app/init/BootStrap.groovy @@ -11,7 +11,9 @@ import functional.tests.Site import functional.tests.Team import functional.tests.Proxy import grails.gorm.transactions.Transactional +import groovy.transform.CompileStatic +@CompileStatic class BootStrap { def init = { servletContext -> @@ -49,7 +51,4 @@ class BootStrap { .addToEmployees(new Employee(name: "Iván López")) .save(flush: true, failOnError: true) } - - def destroy = { - } } diff --git a/examples/functional-tests/grails-app/init/functional/tests/Application.groovy b/examples/functional-tests/grails-app/init/functional/tests/Application.groovy index d259eded6..0e5f9a3c3 100644 --- a/examples/functional-tests/grails-app/init/functional/tests/Application.groovy +++ b/examples/functional-tests/grails-app/init/functional/tests/Application.groovy @@ -2,7 +2,9 @@ package functional.tests import grails.boot.GrailsApp import grails.boot.config.GrailsAutoConfiguration +import groovy.transform.CompileStatic +@CompileStatic class Application extends GrailsAutoConfiguration { static void main(String[] args) { GrailsApp.run(Application, args) diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/BookSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/BookSpec.groovy index 58c1b88f9..3c7465766 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/BookSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/BookSpec.groovy @@ -7,19 +7,15 @@ import io.micronaut.core.type.Argument import io.micronaut.http.HttpRequest import io.micronaut.http.HttpResponse import io.micronaut.http.HttpStatus -import io.micronaut.http.client.HttpClient import io.micronaut.http.client.exceptions.HttpClientResponseException import org.junit.jupiter.api.BeforeEach -import spock.lang.AutoCleanup -import spock.lang.Shared -import spock.lang.Specification @Integration(applicationClass = Application) class BookSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/BulletinSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/BulletinSpec.groovy index d5a0552c9..79244c94a 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/BulletinSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/BulletinSpec.groovy @@ -13,7 +13,7 @@ class BulletinSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/CircularSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/CircularSpec.groovy index 37aca4c07..634072a02 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/CircularSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/CircularSpec.groovy @@ -15,7 +15,7 @@ class CircularSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/CustomerSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/CustomerSpec.groovy index 15dae9a29..a389df171 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/CustomerSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/CustomerSpec.groovy @@ -12,7 +12,7 @@ class CustomerSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/EmbeddedSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/EmbeddedSpec.groovy index 1c964a3bd..151b44283 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/EmbeddedSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/EmbeddedSpec.groovy @@ -15,7 +15,7 @@ class EmbeddedSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } 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 index 7b84d6192..d084815db 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/GlobalTemplatesSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/GlobalTemplatesSpec.groovy @@ -15,7 +15,7 @@ class GlobalTemplatesSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/HttpClientSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/HttpClientSpec.groovy index 743e19ee2..7f3933ee5 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/HttpClientSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/HttpClientSpec.groovy @@ -19,7 +19,7 @@ class HttpClientSpec extends Specification { @RunOnce @BeforeEach - def init() { + void init() { this.baseUrl = "http://localhost:$serverPort" this.client = HttpClient.create(new URL(baseUrl)) } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/InheritanceSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/InheritanceSpec.groovy index 85e4eb529..a9ed7a76a 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/InheritanceSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/InheritanceSpec.groovy @@ -13,7 +13,7 @@ class InheritanceSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/ModelInterceptorIntSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/ModelInterceptorIntSpec.groovy index 33f6ca827..25c68705a 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/ModelInterceptorIntSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/ModelInterceptorIntSpec.groovy @@ -15,7 +15,7 @@ class ModelInterceptorIntSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } 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 1ccc98610..206e3ea78 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 @@ -12,7 +12,7 @@ class ObjectTemplateSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/PersonInheritanceSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/PersonInheritanceSpec.groovy index d554cb422..4f301ab2f 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/PersonInheritanceSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/PersonInheritanceSpec.groovy @@ -13,7 +13,7 @@ class PersonInheritanceSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/ProductSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/ProductSpec.groovy index 6cd793cf0..c0e276a46 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/ProductSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/ProductSpec.groovy @@ -13,7 +13,7 @@ class ProductSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/ProjectSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/ProjectSpec.groovy index de6b8bcfa..e01b51559 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/ProjectSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/ProjectSpec.groovy @@ -12,7 +12,7 @@ class ProjectSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/ProxySpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/ProxySpec.groovy index 06bb33fcc..04ca54747 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/ProxySpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/ProxySpec.groovy @@ -13,7 +13,7 @@ class ProxySpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/TeamSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/TeamSpec.groovy index 526b25ca2..da2ae2c85 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/TeamSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/TeamSpec.groovy @@ -15,7 +15,7 @@ class TeamSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/TestControllerSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/TestControllerSpec.groovy index a67016fb9..bf13c2f98 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/TestControllerSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/TestControllerSpec.groovy @@ -15,7 +15,7 @@ class TestControllerSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/TestGmlControllerSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/TestGmlControllerSpec.groovy index 7ebd9441a..b83c08341 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/TestGmlControllerSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/TestGmlControllerSpec.groovy @@ -12,7 +12,7 @@ class TestGmlControllerSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/TestGsonControllerSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/TestGsonControllerSpec.groovy index 577707920..33b879aa1 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/TestGsonControllerSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/TestGsonControllerSpec.groovy @@ -11,7 +11,7 @@ class TestGsonControllerSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/VehicleSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/VehicleSpec.groovy index c3b893d7d..3cf553330 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/VehicleSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/VehicleSpec.groovy @@ -12,7 +12,7 @@ class VehicleSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/integration-test/groovy/functional/tests/api/NamespacedBookSpec.groovy b/examples/functional-tests/src/integration-test/groovy/functional/tests/api/NamespacedBookSpec.groovy index c13fdc608..fdf014b0a 100644 --- a/examples/functional-tests/src/integration-test/groovy/functional/tests/api/NamespacedBookSpec.groovy +++ b/examples/functional-tests/src/integration-test/groovy/functional/tests/api/NamespacedBookSpec.groovy @@ -17,7 +17,7 @@ class NamespacedBookSpec extends HttpClientSpec { @RunOnce @BeforeEach - def init() { + void init() { super.init() } diff --git a/examples/functional-tests/src/main/groovy/functional/tests/CustomClass.groovy b/examples/functional-tests/src/main/groovy/functional/tests/CustomClass.groovy index 1e502dd39..17d38a0c3 100644 --- a/examples/functional-tests/src/main/groovy/functional/tests/CustomClass.groovy +++ b/examples/functional-tests/src/main/groovy/functional/tests/CustomClass.groovy @@ -1,8 +1,12 @@ package functional.tests +import groovy.transform.CompileStatic + + /** * Created by jameskleeh on 10/25/16. */ +@CompileStatic class CustomClass { String name } diff --git a/examples/functional-tests/src/main/groovy/functional/tests/DomainObject.groovy b/examples/functional-tests/src/main/groovy/functional/tests/DomainObject.groovy index 91e8164eb..8fa6c6a93 100644 --- a/examples/functional-tests/src/main/groovy/functional/tests/DomainObject.groovy +++ b/examples/functional-tests/src/main/groovy/functional/tests/DomainObject.groovy @@ -1,7 +1,9 @@ package functional.tests +import groovy.transform.CompileStatic import groovy.transform.ToString +@CompileStatic @ToString(includePackage = false, includeNames = true) class DomainObject { String id diff --git a/examples/functional-tests/src/main/groovy/functional/tests/MyConverter.groovy b/examples/functional-tests/src/main/groovy/functional/tests/MyConverter.groovy index b8dc13bb6..b17fae731 100644 --- a/examples/functional-tests/src/main/groovy/functional/tests/MyConverter.groovy +++ b/examples/functional-tests/src/main/groovy/functional/tests/MyConverter.groovy @@ -1,11 +1,13 @@ package functional.tests import grails.plugin.json.builder.JsonGenerator +import groovy.transform.CompileStatic import org.springframework.core.Ordered /** * Created by jameskleeh on 10/25/16. */ +@CompileStatic class MyConverter implements JsonGenerator.Converter, Ordered { @Override diff --git a/examples/functional-tests/src/main/groovy/functional/tests/MyEnum.groovy b/examples/functional-tests/src/main/groovy/functional/tests/MyEnum.groovy index c654d3d8a..3e819faba 100644 --- a/examples/functional-tests/src/main/groovy/functional/tests/MyEnum.groovy +++ b/examples/functional-tests/src/main/groovy/functional/tests/MyEnum.groovy @@ -1,8 +1,11 @@ package functional.tests +import groovy.transform.CompileStatic + /** * Created by Jim on 8/31/2016. */ +@CompileStatic enum MyEnum { FOO("Foo"), diff --git a/examples/functional-tests/src/main/groovy/functional/tests/MyOtherConverter.groovy b/examples/functional-tests/src/main/groovy/functional/tests/MyOtherConverter.groovy index 7ed2b8a93..09985ed2b 100644 --- a/examples/functional-tests/src/main/groovy/functional/tests/MyOtherConverter.groovy +++ b/examples/functional-tests/src/main/groovy/functional/tests/MyOtherConverter.groovy @@ -1,11 +1,13 @@ package functional.tests import grails.plugin.json.builder.JsonGenerator +import groovy.transform.CompileStatic import org.springframework.core.Ordered /** * Created by jameskleeh on 12/12/16. */ +@CompileStatic class MyOtherConverter implements JsonGenerator.Converter, Ordered { @Override diff --git a/examples/functional-tests/src/main/groovy/functional/tests/Person.groovy b/examples/functional-tests/src/main/groovy/functional/tests/Person.groovy index 5ac55ae68..886c63303 100644 --- a/examples/functional-tests/src/main/groovy/functional/tests/Person.groovy +++ b/examples/functional-tests/src/main/groovy/functional/tests/Person.groovy @@ -1,5 +1,8 @@ package functional.tests +import groovy.transform.CompileStatic + +@CompileStatic class Person { String firstName String lastName diff --git a/examples/functional-tests/grails-app/conf/logback.xml b/examples/functional-tests/src/test/resources/logback-test.xml similarity index 79% rename from examples/functional-tests/grails-app/conf/logback.xml rename to examples/functional-tests/src/test/resources/logback-test.xml index d576ceb42..be486aaae 100644 --- a/examples/functional-tests/grails-app/conf/logback.xml +++ b/examples/functional-tests/src/test/resources/logback-test.xml @@ -7,7 +7,7 @@ UTF-8 - '%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex' + %clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex diff --git a/gradle-plugin/build.gradle b/gradle-plugin/build.gradle new file mode 100644 index 000000000..374a75714 --- /dev/null +++ b/gradle-plugin/build.gradle @@ -0,0 +1,71 @@ +plugins { + id 'java-gradle-plugin' + id 'groovy' + id 'maven-publish' + id 'signing' +} + +group = 'org.grails.plugins' +ext.set('projectDesc', 'Grails Views Gradle Plugin') + +dependencies { + implementation libs.grails.bootstrap + implementation libs.grails.gradle.plugin + implementation libs.groovy.core + implementation libs.spring.boot.gradle.plugin + + // This is a workaround for grails-bootstrap exposing a + // different version of groovy-xml than the one used by Gradle. + // This causes issues with the Groovy compiler. + compileOnly "org.codehaus.groovy:groovy-xml:$GroovySystem.version" +} + +java { + sourceCompatibility = JavaVersion.toVersion(libs.versions.java.baseline.get()) + withJavadocJar() + withSourcesJar() +} + +tasks.named('javadocJar', Jar) { + from tasks.named('groovydoc') +} + +tasks.withType(Sign).configureEach { + onlyIf { isReleaseVersion } +} + +gradlePlugin { + plugins { + register('viewsJson') { + id = 'org.grails.plugins.views-json' + implementationClass = 'grails.views.gradle.json.GrailsJsonViewsPlugin' + displayName = 'Grails Json Views Gradle Plugin' + description = 'The Gradle plugin for Json Views' + } + register('viewsMarkup') { + id = 'org.grails.plugins.views-markup' + implementationClass = 'grails.views.gradle.markup.GrailsMarkupViewsPlugin' + displayName = 'Grails Markup Views Gradle Plugin' + description = 'The Gradle plugin for Markup Views' + } + } +} + +afterEvaluate { + signing { + required { isReleaseVersion && gradle.taskGraph.hasTask('publish') } + Publication[] publications = new Publication[publishing.publications.size() - 1] + publishing.publications.findAll { it.name != 'pluginMaven' }.toArray(publications) + sign(publications) + } + + publishing.publications.each { publication -> + MavenPublication pub = publication as MavenPublication + if (pub.name != 'pluginMaven') { + pub.pom.withXml { + def xml = asNode() + xml.children().last() + pomInfo + } + } + } +} \ No newline at end of file diff --git a/gradle/src/main/groovy/grails/views/gradle/AbstractGroovyTemplateCompileTask.groovy b/gradle-plugin/src/main/groovy/grails/views/gradle/AbstractGroovyTemplateCompileTask.groovy similarity index 100% rename from gradle/src/main/groovy/grails/views/gradle/AbstractGroovyTemplateCompileTask.groovy rename to gradle-plugin/src/main/groovy/grails/views/gradle/AbstractGroovyTemplateCompileTask.groovy diff --git a/gradle/src/main/groovy/grails/views/gradle/AbstractGroovyTemplatePlugin.groovy b/gradle-plugin/src/main/groovy/grails/views/gradle/AbstractGroovyTemplatePlugin.groovy similarity index 100% rename from gradle/src/main/groovy/grails/views/gradle/AbstractGroovyTemplatePlugin.groovy rename to gradle-plugin/src/main/groovy/grails/views/gradle/AbstractGroovyTemplatePlugin.groovy diff --git a/gradle/src/main/groovy/grails/views/gradle/ViewCompileOptions.groovy b/gradle-plugin/src/main/groovy/grails/views/gradle/ViewCompileOptions.groovy similarity index 100% rename from gradle/src/main/groovy/grails/views/gradle/ViewCompileOptions.groovy rename to gradle-plugin/src/main/groovy/grails/views/gradle/ViewCompileOptions.groovy diff --git a/gradle/src/main/groovy/grails/views/gradle/json/GrailsJsonViewsPlugin.groovy b/gradle-plugin/src/main/groovy/grails/views/gradle/json/GrailsJsonViewsPlugin.groovy similarity index 100% rename from gradle/src/main/groovy/grails/views/gradle/json/GrailsJsonViewsPlugin.groovy rename to gradle-plugin/src/main/groovy/grails/views/gradle/json/GrailsJsonViewsPlugin.groovy diff --git a/gradle/src/main/groovy/grails/views/gradle/json/JsonViewCompilerTask.groovy b/gradle-plugin/src/main/groovy/grails/views/gradle/json/JsonViewCompilerTask.groovy similarity index 100% rename from gradle/src/main/groovy/grails/views/gradle/json/JsonViewCompilerTask.groovy rename to gradle-plugin/src/main/groovy/grails/views/gradle/json/JsonViewCompilerTask.groovy diff --git a/gradle/src/main/groovy/grails/views/gradle/markup/GrailsMarkupViewsPlugin.groovy b/gradle-plugin/src/main/groovy/grails/views/gradle/markup/GrailsMarkupViewsPlugin.groovy similarity index 100% rename from gradle/src/main/groovy/grails/views/gradle/markup/GrailsMarkupViewsPlugin.groovy rename to gradle-plugin/src/main/groovy/grails/views/gradle/markup/GrailsMarkupViewsPlugin.groovy diff --git a/gradle/src/main/groovy/grails/views/gradle/markup/MarkupViewCompilerTask.groovy b/gradle-plugin/src/main/groovy/grails/views/gradle/markup/MarkupViewCompilerTask.groovy similarity index 100% rename from gradle/src/main/groovy/grails/views/gradle/markup/MarkupViewCompilerTask.groovy rename to gradle-plugin/src/main/groovy/grails/views/gradle/markup/MarkupViewCompilerTask.groovy diff --git a/gradle.properties b/gradle.properties index dd59eb45a..faa637f4b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,23 +1,8 @@ -assetPipelineVersion=3.4.6 -caffeineVersion=2.9.3 -githubSlug=grails/grails-views -gormVersion=8.0.1 -grailsVersion=6.1.1 -grailsGradlePluginVersion=6.1.1 -groovyVersion=3.0.11 -hibernateGormVersion=8.0.0 -jansiVersion=2.4.1 -javaParserCoreVersion=3.25.8 -micronautVersion=3.8.7 -mongodbDriverVersion=4.0.3 -mongodbVersion=8.1.2 -projectUrl=https://views.grails.org projectVersion=3.1.3-SNAPSHOT -servletApiVersion=4.0.1 -spockVersion=2.1-groovy-3.0 -springBootVersion=2.7.18 -springDependencyManagementPluginVersion=1.1.0 -testingSupportVersion=3.1.2 + +# This prevents the Grails Gradle Plugin from unnecessarily excluding slf4j-simple in the generated POMs +# https://github.com/grails/grails-gradle-plugin/issues/222 +slf4jPreventExclusion=true org.gradle.caching=true org.gradle.daemon=true diff --git a/gradle/build.gradle b/gradle/build.gradle deleted file mode 100644 index 85330bad8..000000000 --- a/gradle/build.gradle +++ /dev/null @@ -1,80 +0,0 @@ -buildscript { - repositories { - maven { url "https://repo.grails.org/grails/core" } - } - dependencies { - } -} - -apply plugin: 'java-gradle-plugin' -apply plugin: 'groovy' - -ext { - userOrg = 'grails' - isGrailsPlugin = false - projectDesc = "Grails Views Gradle Plugin" -} - -group "org.grails.plugins" - -repositories { - mavenCentral() - maven { url "https://repo.grails.org/grails/core" } -} - -dependencies { - compileOnly gradleApi() - api "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion" - api "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" - api "org.codehaus.groovy:groovy:$groovyVersion" -} - -if (!tasks.findByName("sourcesJar")) { - tasks.register("sourcesJar", Jar) { - classifier = 'sources' - from project.sourceSets.main.allSource - } -} - -if (!tasks.findByName("javadocJar")) { -// no javadocs, just a workaround - tasks.register("javadocJar", Jar) { - classifier = 'javadoc' - from tasks.named("groovydoc").get().outputs - } -} - -gradlePlugin { - plugins { - viewsJson { - id = 'org.grails.plugins.views-json' - implementationClass = 'grails.views.gradle.json.GrailsJsonViewsPlugin' - displayName = "Grails Json Views Gradle Plugin" - description = 'The Gradle plugin for Json Views' - } - viewsMarkup { - id = 'org.grails.plugins.views-markup' - implementationClass = 'grails.views.gradle.markup.GrailsMarkupViewsPlugin' - displayName = "Grails Markup Views Gradle Plugin" - description = 'The Gradle plugin for Markup Views' - } - } -} - -afterEvaluate { - signing { - required { isReleaseVersion && gradle.taskGraph.hasTask("publish") } - Publication[] publications = new Publication[publishing.publications.size() - 1] - project.publishing.publications.findAll { it.name != 'pluginMaven' }.toArray(publications) - sign(publications) - } - - publishing.publications.each { MavenPublication publication -> - if (publication.name != "pluginMaven") { - publication.pom.withXml { - def xml = asNode() - xml.children().last() + pomInfo - } - } - } -} diff --git a/gradle/buildsrc.libs.versions.toml b/gradle/buildsrc.libs.versions.toml new file mode 100644 index 000000000..f64815544 --- /dev/null +++ b/gradle/buildsrc.libs.versions.toml @@ -0,0 +1,15 @@ +[versions] +asciidoctor-gradle-jvm = '4.0.1' +assetpipeline = '4.3.0' +grails-gradle-plugin = '6.1.2' +grails-views = '3.1.2' +groovy-doc = '1.0.1' +nexus-publish-gradle-plugin = '1.3.0' + +[libraries] +asciidoctor-gradle-plugin = { module = 'org.asciidoctor:asciidoctor-gradle-jvm', version.ref = 'asciidoctor-gradle-jvm' } +assetpipeline-gradle-plugin = { module = 'com.bertramlabs.plugins:asset-pipeline-gradle', version.ref = 'assetpipeline' } +grails-gradle-plugin = { module = 'org.grails:grails-gradle-plugin', version.ref = 'grails-gradle-plugin' } +grails-views-gradle-plugin = { module = 'org.grails.plugins:views-gradle', version.ref = 'grails-views' } +nexus-publish-gradle-plugin = { module = 'io.github.gradle-nexus:publish-plugin', version.ref = 'nexus-publish-gradle-plugin' } +groovydoc-gradle-plugin = { module = 'io.github.groovylang.groovydoc:groovydoc-gradle-plugin', version.ref = 'groovy-doc' } diff --git a/gradle/gradlew b/gradle/gradlew deleted file mode 100755 index 1b6c78733..000000000 --- a/gradle/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/gradle/gradlew.bat b/gradle/gradlew.bat deleted file mode 100644 index ac1b06f93..000000000 --- a/gradle/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/gradle/grailsCentralPublishing.gradle b/gradle/grailsCentralPublishing.gradle new file mode 100644 index 000000000..c7ac1470f --- /dev/null +++ b/gradle/grailsCentralPublishing.gradle @@ -0,0 +1,56 @@ +ext.set('signing.keyId', project.findProperty('signing.keyId') ?: System.getenv('SIGNING_KEY')) +ext.set('signing.password', project.findProperty('signing.password') ?: System.getenv('SIGNING_PASSPHRASE')) + +def javaComponent = components.named('java') +project.extensions.configure(PublishingExtension) { PublishingExtension pe -> + + pe.publications.register('pluginMaven', MavenPublication) { + artifactId = project.name + from javaComponent.get() + versionMapping { + usage('java-api') { fromResolutionOf('runtimeClasspath') } + usage('java-runtime') { fromResolutionResult() } + } + pom { + name = 'Grails Views' + description = 'Provides additional view technologies to the Grails framework, including JSON and Markup views.' + } + pom.withXml { + def pomNode = asNode() + pomNode.children().last() + pomInfo + + // dependency management shouldn't be included + try { pomNode.dependencyManagement.replaceNode({}) } catch (Throwable ignore) {} + } + } + + if (isSnapshot) { + repositories { + maven { + credentials { + username = project.findProperty('artifactoryUsername') ?: '' + password = project.findProperty('artifactoryPassword') ?: '' + } + url = group == 'org.grails.plugins' ? + uri('https://repo.grails.org/grails/plugins3-snapshots-local') : + uri('https://repo.grails.org/grails/libs-snapshots-local') + } + } + } +} + +afterEvaluate { + def mavenPublication = project.extensions.findByType(PublishingExtension).publications.named('pluginMaven') + project.extensions.configure(SigningExtension) { SigningExtension se -> + se.required = { isReleaseVersion && gradle.taskGraph.hasTask('publish') } + se.sign mavenPublication.get() + } +} + +tasks.withType(Sign).configureEach { + onlyIf { isReleaseVersion } +} + +tasks.register('install') { + dependsOn 'publishToMavenLocal' +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..7863c79e7 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,38 @@ +[versions] +assetpipeline = '4.3.0' +caffeine = '2.9.3' +gorm = '8.0.4' +gorm-hibernate5 = '8.0.3' +gorm-mongodb = '8.1.2' +grails = '6.1.2' +grails-gradle-plugin = '6.1.2' +grails-testing-support = '3.1.2' +groovy = '3.0.11' +java-baseline = '11' +micronaut = '3.8.7' +slf4j = '1.7.36' +spock = '2.3-groovy-3.0' +spring-boot = '2.7.18' + +[libraries] +assetpipeline = { module = 'com.bertramlabs.plugins:asset-pipeline-grails', version.ref = 'assetpipeline' } +caffeine = { module = 'com.github.ben-manes.caffeine:caffeine', version.ref = 'caffeine' } +grails-bootstrap = { module = 'org.grails:grails-bootstrap', version.ref = 'grails' } +grails-core = { module = 'org.grails:grails-core', version.ref = 'grails' } +grails-datastore-core = { module = 'org.grails:grails-datastore-core', version.ref = 'gorm' } +grails-datastore-gorm-hibernate5 = { module = 'org.grails:grails-datastore-gorm-hibernate5', version.ref = 'gorm-hibernate5' } +grails-datastore-gorm-mongodb = { module = 'org.grails:grails-datastore-gorm-mongodb', version.ref = 'gorm-mongodb' } +grails-datastore-gorm-support = { module = 'org.grails:grails-datastore-gorm-support', version.ref = 'gorm' } +grails-gradle-plugin = { module = 'org.grails:grails-gradle-plugin', version.ref = 'grails-gradle-plugin' } +grails-mimetypes = { module = 'org.grails:grails-plugin-mimetypes', version.ref = 'grails' } +grails-rest = { module = 'org.grails:grails-plugin-rest', version.ref = 'grails' } +grails-testing-support-core = { module = 'org.grails:grails-testing-support', version.ref = 'grails-testing-support' } +grails-testing-support-gorm = { module = 'org.grails:grails-gorm-testing-support', version.ref = 'grails-testing-support' } +grails-web-urlmappings = { module = 'org.grails:grails-web-url-mappings', version.ref = 'grails' } +groovy-core = { module = 'org.codehaus.groovy:groovy', version.ref = 'groovy' } +groovy-json = { module = 'org.codehaus.groovy:groovy-json', version.ref = 'groovy' } +micronaut-http-client = { module = 'io.micronaut:micronaut-http-client', version.ref = 'micronaut' } +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' } +spring-boot-gradle-plugin = { module = 'org.springframework.boot:spring-boot-gradle-plugin', version.ref = 'spring-boot' } \ No newline at end of file diff --git a/json-templates/build.gradle b/json-templates/build.gradle index 7ef77d365..615cc70d2 100644 --- a/json-templates/build.gradle +++ b/json-templates/build.gradle @@ -1,47 +1,58 @@ -group "org.grails.plugins" - -ext { - userOrg = 'grails' - repo = 'plugins' - isGrailsPlugin = false - projectDesc = "JSON Views Templates" +plugins { + id 'groovy' + id 'java-library' + id 'maven-publish' + id 'signing' } -repositories { - mavenCentral() - maven { url "https://repo.grails.org/grails/core" } -} +group = 'org.grails.plugins' +ext.set('projectDesc', 'JSON Views Templates') dependencies { + api project(':views-json') - compileOnly "org.grails:grails-plugin-rest:$grailsVersion" - compileOnly "javax.servlet:javax.servlet-api:$servletApiVersion" - compileOnly "org.grails:grails-datastore-gorm-mongodb:$mongodbVersion" + + // 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 + implementation libs.grails.datastore.gorm.mongodb + + compileOnly libs.slf4j.nop // Get rid of warning about missing slf4j implementation during compileGsonViews task +} + +def sourceDir = layout.projectDirectory.dir('src/templates') +def outputDir = layout.buildDirectory.dir('classes/groovy/main') +sourceSets { + main { + groovy { + srcDirs = [sourceDir] + } + } } -def compileViews = tasks.register("compileViews", JavaExec) { - inputs.files 'src/templates' - outputs.dir 'build/classes/groovy/main' - mainClass.set("grails.plugin.json.view.JsonViewCompiler") +tasks.register('compileViews', JavaExec) { + inputs.dir sourceDir + outputs.dir outputDir + mainClass = 'grails.plugin.json.view.JsonViewCompiler' classpath configurations.compileClasspath + configurations.runtimeClasspath - args("src/templates", "build/classes/groovy/main", "1.11", ' ', ' ', "none", "UTF-8") + args(sourceDir.asFile, outputDir.get().asFile, libs.versions.java.baseline.get(), ' ', ' ', 'none', 'UTF-8') } -if (!tasks.findByName("sourcesJar")) { - tasks.register("sourcesJar", Jar) { - archiveClassifier.set('sources') - archiveClassifier.convention('sources') - from 'src/templates' - } +tasks.named('classes') { + dependsOn 'compileViews' } -if (!tasks.findByName("javadocJar")) { -// no javadocs, just a workaround - tasks.register("javadocJar", Jar) { - archiveClassifier.set('javadoc') - archiveClassifier.convention('javadoc') - from 'src/templates' - } +java { + sourceCompatibility = JavaVersion.toVersion(libs.versions.java.baseline.get()) + withSourcesJar() + withJavadocJar() +} + +// 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' } -classes.dependsOn(compileViews) +apply from: rootProject.layout.projectDirectory.file('gradle/grailsCentralPublishing.gradle') \ No newline at end of file diff --git a/json-templates/gradle/wrapper/gradle-wrapper.jar b/json-templates/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index e708b1c02..000000000 Binary files a/json-templates/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/json-templates/gradle/wrapper/gradle-wrapper.properties b/json-templates/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index d355f4c4f..000000000 --- a/json-templates/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/json-templates/gradlew b/json-templates/gradlew deleted file mode 100755 index 1b6c78733..000000000 --- a/json-templates/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/json-templates/gradlew.bat b/json-templates/gradlew.bat deleted file mode 100644 index ac1b06f93..000000000 --- a/json-templates/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/json-templates/src/templates/grails/mongodb/geo/_geometryCollection.gson b/json-templates/src/templates/grails/mongodb/geo/_geometryCollection.gson index 2668a13a6..8e040c8de 100644 --- a/json-templates/src/templates/grails/mongodb/geo/_geometryCollection.gson +++ b/json-templates/src/templates/grails/mongodb/geo/_geometryCollection.gson @@ -2,10 +2,9 @@ * A template for rendering a GeoJSON GeometryCollection in MongoDB */ import grails.mongodb.geo.* +import groovy.transform.Field -model { - GeometryCollection geometryCollection -} +@Field GeometryCollection geometryCollection json { type "GeometryCollection" diff --git a/json-templates/src/templates/grails/mongodb/geo/_lineString.gson b/json-templates/src/templates/grails/mongodb/geo/_lineString.gson index 5644e1766..5c36f64db 100644 --- a/json-templates/src/templates/grails/mongodb/geo/_lineString.gson +++ b/json-templates/src/templates/grails/mongodb/geo/_lineString.gson @@ -2,10 +2,9 @@ * A template for rendering a GeoJSON LineString in MongoDB */ import grails.mongodb.geo.* +import groovy.transform.Field -model { - LineString lineString -} +@Field LineString lineString json { type "LineString" diff --git a/json-templates/src/templates/grails/mongodb/geo/_multiLineString.gson b/json-templates/src/templates/grails/mongodb/geo/_multiLineString.gson index 34062f79d..a4124edcd 100644 --- a/json-templates/src/templates/grails/mongodb/geo/_multiLineString.gson +++ b/json-templates/src/templates/grails/mongodb/geo/_multiLineString.gson @@ -2,10 +2,9 @@ * A template for rendering a GeoJSON MultiLineString in MongoDB */ import grails.mongodb.geo.* +import groovy.transform.Field -model { - MultiLineString multiLineString -} +@Field MultiLineString multiLineString json { type "MultiLineString" diff --git a/json-templates/src/templates/grails/mongodb/geo/_multiPoint.gson b/json-templates/src/templates/grails/mongodb/geo/_multiPoint.gson index 0e43bd956..5ff1bd5dd 100644 --- a/json-templates/src/templates/grails/mongodb/geo/_multiPoint.gson +++ b/json-templates/src/templates/grails/mongodb/geo/_multiPoint.gson @@ -2,10 +2,9 @@ * A template for rendering a GeoJSON MultiPoint in MongoDB */ import grails.mongodb.geo.* +import groovy.transform.Field -model { - MultiPoint multiPoint -} +@Field MultiPoint multiPoint json { type "MultiPoint" diff --git a/json-templates/src/templates/grails/mongodb/geo/_multiPolygon.gson b/json-templates/src/templates/grails/mongodb/geo/_multiPolygon.gson index b906cb06d..6ccdc0d2d 100644 --- a/json-templates/src/templates/grails/mongodb/geo/_multiPolygon.gson +++ b/json-templates/src/templates/grails/mongodb/geo/_multiPolygon.gson @@ -2,10 +2,9 @@ * A template for rendering a GeoJSON MultiPoint in MongoDB */ import grails.mongodb.geo.* +import groovy.transform.Field -model { - MultiPolygon multiPolygon -} +@Field MultiPoint multiPolygon json { type "MultiPolygon" diff --git a/json-templates/src/templates/grails/mongodb/geo/_point.gson b/json-templates/src/templates/grails/mongodb/geo/_point.gson index ecae353a0..e776fa126 100644 --- a/json-templates/src/templates/grails/mongodb/geo/_point.gson +++ b/json-templates/src/templates/grails/mongodb/geo/_point.gson @@ -2,10 +2,9 @@ * A template for rendering a GeoJSON Point in MongoDB */ import grails.mongodb.geo.* +import groovy.transform.Field -model { - Point point -} +@Field Point point json { type "Point" diff --git a/json-templates/src/templates/grails/mongodb/geo/_polygon.gson b/json-templates/src/templates/grails/mongodb/geo/_polygon.gson index 8771cdf8e..eeb782154 100644 --- a/json-templates/src/templates/grails/mongodb/geo/_polygon.gson +++ b/json-templates/src/templates/grails/mongodb/geo/_polygon.gson @@ -2,10 +2,9 @@ * A template for rendering a GeoJSON Polygon in MongoDB */ import grails.mongodb.geo.* +import groovy.transform.Field -model { - Polygon polygon -} +@Field Polygon polygon json { type "Polygon" diff --git a/json-templates/src/templates/org/bson/types/_objectId.gson b/json-templates/src/templates/org/bson/types/_objectId.gson index 711c87191..2983e3dbd 100644 --- a/json-templates/src/templates/org/bson/types/_objectId.gson +++ b/json-templates/src/templates/org/bson/types/_objectId.gson @@ -3,6 +3,6 @@ import org.bson.types.* import groovy.transform.* import grails.plugin.json.builder.* -@Field ObjectId objectId +@Field ObjectId objectId = null -json(JsonOutput.unescaped("\"${objectId.toString()}\"")) \ No newline at end of file +json(JsonOutput.unescaped("\"${objectId?.toString()}\"")) \ No newline at end of file diff --git a/json-testing-support/build.gradle b/json-testing-support/build.gradle index 62722e41a..5e6ccb7cd 100644 --- a/json-testing-support/build.gradle +++ b/json-testing-support/build.gradle @@ -1,53 +1,44 @@ -buildscript { - repositories { - maven { url "https://repo.grails.org/grails/core" } - } - dependencies { - classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" - classpath "io.github.gradle-nexus:publish-plugin:1.3.0" - } +plugins { + id 'groovy' + id 'java-library' + id 'maven-publish' + id 'signing' } -group "org.grails" +group = 'org.grails' +ext.set('projectDesc', 'JSON Views Testing Support') -ext { - userOrg = 'grails' - repo = 'grails-core' - isGrailsPlugin = false - projectDesc = "JSON Views Testing Support" -} -sourceCompatibility = 1.11 -targetCompatibility = 1.11 +configurations.register('groovydocImplementation') + +dependencies { + + api project(':views-json') + api libs.grails.datastore.core // Used in public api -repositories { - mavenCentral() - maven { url "https://repo.grails.org/grails/core" } + implementation libs.grails.core + implementation libs.grails.testing.support.core + implementation libs.groovy.core + implementation libs.groovy.json + implementation libs.spock.core + + groovydocImplementation localGroovy(), { + because 'The Groovydoc task requires the same Groovy version as Gradle' + } } -dependencies { - api "org.grails:grails-core:$grailsVersion" - api "org.grails:grails-dependencies:$grailsVersion" - api "javax.servlet:javax.servlet-api:$servletApiVersion" +java { + sourceCompatibility = JavaVersion.toVersion(libs.versions.java.baseline.get()) + withJavadocJar() + withSourcesJar() +} - api "org.grails:grails-gorm-testing-support:$testingSupportVersion" - api "org.grails:grails-web-testing-support:$testingSupportVersion" - api project(":views-json") +tasks.withType(Groovydoc).configureEach { + classpath = configurations.groovydocImplementation } -if (!tasks.findByName("sourcesJar")) { - tasks.register("sourcesJar", Jar) { - archiveClassifier.set('sources') - archiveClassifier.convention('sources') - from project.sourceSets.main.allSource - } +tasks.named('javadocJar', Jar) { + from tasks.named('groovydoc') } -if (!tasks.findByName("javadocJar")) { -// no javadocs, just a workaround - tasks.register("javadocJar", Jar) { - archiveClassifier.set('javadoc') - archiveClassifier.convention('javadoc') - from tasks.named("groovydoc").get().outputs - } -} \ No newline at end of file +apply from: rootProject.layout.projectDirectory.file('gradle/grailsCentralPublishing.gradle') \ No newline at end of file diff --git a/json-testing-support/gradle/wrapper/gradle-wrapper.jar b/json-testing-support/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index e708b1c02..000000000 Binary files a/json-testing-support/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/json-testing-support/gradle/wrapper/gradle-wrapper.properties b/json-testing-support/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index d355f4c4f..000000000 --- a/json-testing-support/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/json-testing-support/gradlew b/json-testing-support/gradlew deleted file mode 100755 index 1b6c78733..000000000 --- a/json-testing-support/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/json-testing-support/gradlew.bat b/json-testing-support/gradlew.bat deleted file mode 100644 index ac1b06f93..000000000 --- a/json-testing-support/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/json-testing-support/src/main/groovy/grails/views/json/test/JsonViewUnitTest.groovy b/json-testing-support/src/main/groovy/grails/views/json/test/JsonViewUnitTest.groovy index 06b07a476..c6a21c25d 100644 --- a/json-testing-support/src/main/groovy/grails/views/json/test/JsonViewUnitTest.groovy +++ b/json-testing-support/src/main/groovy/grails/views/json/test/JsonViewUnitTest.groovy @@ -8,10 +8,12 @@ import grails.views.api.HttpView import grails.views.api.http.Response import groovy.json.JsonSlurper import groovy.text.Template +import groovy.transform.CompileStatic import org.grails.datastore.mapping.model.MappingContext import org.grails.testing.GrailsUnitTest import org.springframework.http.HttpStatus +@CompileStatic trait JsonViewUnitTest extends GrailsUnitTest { private static JsonViewTemplateEngine _templateEngine diff --git a/json-testing-support/src/main/groovy/grails/views/json/test/spock/JsonViewSetupSpecInterceptor.groovy b/json-testing-support/src/main/groovy/grails/views/json/test/spock/JsonViewSetupSpecInterceptor.groovy index 53b9def53..6bc2773fd 100644 --- a/json-testing-support/src/main/groovy/grails/views/json/test/spock/JsonViewSetupSpecInterceptor.groovy +++ b/json-testing-support/src/main/groovy/grails/views/json/test/spock/JsonViewSetupSpecInterceptor.groovy @@ -25,21 +25,21 @@ class JsonViewSetupSpecInterceptor implements IMethodInterceptor { @CompileStatic(TypeCheckingMode.SKIP) protected void setup(JsonViewUnitTest test) { - GrailsApplication grailsApplication = test.grailsApplication - def config = grailsApplication.config + GrailsApplication grailsApp = test.grailsApplication + def config = grailsApp.config test.defineBeans { grailsLinkGenerator(DefaultLinkGenerator, config?.grails?.serverURL ?: "http://localhost:8080") localeResolver(SessionLocaleResolver) grailsUrlMappingsHolder(UrlMappingsHolderFactoryBean) { - grailsApplication = grailsApplication + grailsApplication = grailsApp } grailsDomainClassMappingContext(KeyValueMappingContext, 'test') { canInitializeEntities = true } } JsonViewGrailsPlugin plugin = new JsonViewGrailsPlugin() - plugin.setApplicationContext(grailsApplication.mainContext) + plugin.setApplicationContext(grailsApp.mainContext) test.defineBeans(plugin) } } diff --git a/json-testing-support/src/main/groovy/grails/views/json/test/spock/JsonViewSpockExtension.groovy b/json-testing-support/src/main/groovy/grails/views/json/test/spock/JsonViewSpockExtension.groovy index 6b17e6f30..e5b6882c6 100644 --- a/json-testing-support/src/main/groovy/grails/views/json/test/spock/JsonViewSpockExtension.groovy +++ b/json-testing-support/src/main/groovy/grails/views/json/test/spock/JsonViewSpockExtension.groovy @@ -2,14 +2,15 @@ package grails.views.json.test.spock import grails.views.json.test.JsonViewUnitTest import groovy.transform.CompileStatic -import org.spockframework.runtime.extension.AbstractGlobalExtension +import org.spockframework.runtime.extension.IGlobalExtension import org.spockframework.runtime.model.SpecInfo @CompileStatic -class JsonViewSpockExtension extends AbstractGlobalExtension { +class JsonViewSpockExtension implements IGlobalExtension { JsonViewSetupSpecInterceptor jsonViewSetupSpecInterceptor = new JsonViewSetupSpecInterceptor() + @Override void visitSpec(SpecInfo spec) { if (JsonViewUnitTest.isAssignableFrom(spec.reflection)) { spec.addSetupSpecInterceptor(jsonViewSetupSpecInterceptor) diff --git a/json/build.gradle b/json/build.gradle index 49dc7a37c..2e9a09b52 100644 --- a/json/build.gradle +++ b/json/build.gradle @@ -1,59 +1,63 @@ -import org.grails.gradle.plugin.web.gsp.GroovyPageCompileTask - -buildscript { - repositories { - maven { url "https://repo.grails.org/grails/core" } - } - dependencies { - classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" - classpath "io.github.gradle-nexus:publish-plugin:1.3.0" - } +plugins { + id 'java-library' + id 'groovy' + id 'org.grails.grails-plugin' + id 'maven-publish' + id 'signing' } -group "org.grails.plugins" +group = 'org.grails.plugins' +ext.set('projectDesc', 'Grails JSON Views') + +dependencies { + + api project(':views-core') -apply plugin: "org.grails.grails-gsp" + implementation libs.grails.core + implementation libs.grails.rest + implementation libs.groovy.json -configurations.configureEach { - resolutionStrategy { - eachDependency { DependencyResolveDetails details -> - if(details.requested.group == 'org.grails' && - details.requested.name.startsWith('grails-datastore')) { + testImplementation libs.grails.testing.support.core + testImplementation libs.grails.testing.support.gorm + testImplementation libs.grails.datastore.gorm.hibernate5 + testImplementation libs.spock.core - if (details.requested.name.equals("grails-datastore-gorm-hibernate5")) { - details.useVersion("$hibernateGormVersion") - } else if (details.requested.name.startsWith("grails-datastore-gorm-mongodb") || - details.requested.name.equals("grails-datastore-gorm-bson")) { - details.useVersion("$mongodbVersion") - } else { - details.useVersion("$gormVersion") - } - } + testRuntimeOnly libs.slf4j.nop // Get rid of warning about missing slf4j implementation during test task +} - } - } +java { + sourceCompatibility = JavaVersion.toVersion(libs.versions.java.baseline.get()) + withJavadocJar() + withSourcesJar() } -dependencies { - api "org.grails:grails-core:$grailsVersion" - api project(":views-core") +springBoot { + // Project has 2 classes with main methods, so we need to specify which one to select + mainClass = 'grails.plugin.json.view.Application' +} + +tasks.named('bootJar') { + enabled = false // Don't need a bootJar for plugin +} - testImplementation "org.grails:grails-web-testing-support:$testingSupportVersion" - testImplementation "org.grails:grails-gorm-testing-support:$testingSupportVersion" - testImplementation "org.grails:grails-datastore-gorm-hibernate5" - testRuntimeOnly "org.javassist:javassist:3.30.2-GA" +def testArtifacts = ['*.gson', 'circular/**'] - console "org.grails:grails-console" +tasks.named('jar', Jar) { + enabled = true // Need a jar for plugin + archiveClassifier = '' // Don't want the '-plain' classifier + exclude testArtifacts } -tasks.withType(GroovyPageCompileTask) { - classpath += configurations.compileClasspath +tasks.named('sourcesJar', Jar) { + exclude testArtifacts } -jar { - exclude "*.gson" +tasks.named('javadocJar', Jar) { + from tasks.named('groovydoc') } -springBoot { - mainClass.set('grails.plugin.json.view.Application') +tasks.named('build') { + finalizedBy 'javadocJar', 'sourcesJar' } + +apply from: rootProject.layout.projectDirectory.file('gradle/grailsCentralPublishing.gradle') \ No newline at end of file diff --git a/json/gradle/wrapper/gradle-wrapper.jar b/json/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index e708b1c02..000000000 Binary files a/json/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/json/gradle/wrapper/gradle-wrapper.properties b/json/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index d355f4c4f..000000000 --- a/json/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/json/gradlew b/json/gradlew deleted file mode 100755 index 1b6c78733..000000000 --- a/json/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/json/gradlew.bat b/json/gradlew.bat deleted file mode 100644 index ac1b06f93..000000000 --- a/json/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/json/grails-app/conf/application.yml b/json/grails-app/conf/application.yml deleted file mode 100644 index e8ecc9717..000000000 --- a/json/grails-app/conf/application.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -grails: - profile: web-plugin - codegen: - defaultPackage: grails.plugins.json.view -info: - app: - name: '@info.app.name@' - version: '@info.app.version@' - grailsVersion: '@info.app.grailsVersion@' -spring: - groovy: - template: - check-template-location: false - diff --git a/json/grails-app/conf/logback.xml b/json/grails-app/conf/logback.xml deleted file mode 100644 index f4e778361..000000000 --- a/json/grails-app/conf/logback.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - UTF-8 - '%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex' - - - - - - - \ No newline at end of file diff --git a/json/grails-app/init/grails/plugin/json/view/Application.groovy b/json/grails-app/init/grails/plugin/json/view/Application.groovy deleted file mode 100644 index 95cba7b36..000000000 --- a/json/grails-app/init/grails/plugin/json/view/Application.groovy +++ /dev/null @@ -1,10 +0,0 @@ -package grails.plugin.json.view - -import grails.boot.GrailsApp -import grails.boot.config.GrailsAutoConfiguration - -class Application extends GrailsAutoConfiguration { - static void main(String[] args) { - GrailsApp.run(Application, args) - } -} \ No newline at end of file diff --git a/json/src/main/groovy/grails/plugin/json/builder/DefaultJsonGenerator.java b/json/src/main/groovy/grails/plugin/json/builder/DefaultJsonGenerator.java index 304127b92..2bcf562e9 100644 --- a/json/src/main/groovy/grails/plugin/json/builder/DefaultJsonGenerator.java +++ b/json/src/main/groovy/grails/plugin/json/builder/DefaultJsonGenerator.java @@ -57,8 +57,7 @@ /** * Temporary fork of DefaultJsonGenerator until Groovy 2.5.0 is out. - * - * A JsonGenerator that can be configured with various {@link JsonGenerator.Options}. + *

A JsonGenerator that can be configured with various {@link JsonGenerator.Options}. * If the default options are sufficient consider using the static {@code JsonOutput.toJson} * methods. * @@ -72,9 +71,9 @@ public class DefaultJsonGenerator implements JsonGenerator { protected final String dateFormat; protected final Locale dateLocale; protected final TimeZone timezone; - protected final Set converters = new LinkedHashSet(); - protected final Set excludedFieldNames = new HashSet(); - protected final Set> excludedFieldTypes = new HashSet>(); + protected final Set converters = new LinkedHashSet<>(); + protected final Set excludedFieldNames = new HashSet<>(); + protected final Set> excludedFieldTypes = new HashSet<>(); protected DefaultJsonGenerator(Options options) { excludeNulls = options.excludeNulls; @@ -236,13 +235,7 @@ protected void writeObject(String key, Object object, CharBuf buffer) { } else if (File.class.isAssignableFrom(objectClass)) { Map properties = getObjectProperties(object); //Clean up all recursive references to File objects - Iterator> iterator = properties.entrySet().iterator(); - while(iterator.hasNext()) { - Map.Entry entry = iterator.next(); - if(entry.getValue() instanceof File) { - iterator.remove(); - } - } + properties.entrySet().removeIf(entry -> entry.getValue() instanceof File); writeMap(properties, buffer); } else { Map properties = getObjectProperties(object); @@ -393,7 +386,7 @@ protected void writeMap(Map map, CharBuf buffer) { buffer.addChar(OPEN_BRACE); for (Map.Entry entry : map.entrySet()) { if (entry.getKey() == null) { - throw new IllegalArgumentException("Maps with null keys can\'t be converted to JSON"); + throw new IllegalArgumentException("Maps with null keys can't be converted to JSON"); } String key = entry.getKey().toString(); Object value = entry.getValue(); @@ -502,12 +495,12 @@ protected ClosureConverter(Class type, Closure closure) { } Class param1 = closure.getParameterTypes()[0]; if (!param1.isAssignableFrom(type)) { - throw new IllegalArgumentException("Expected first parameter to be of type: " + type.toString()); + throw new IllegalArgumentException("Expected first parameter to be of type: " + type); } if (paramCount > 1) { Class param2 = closure.getParameterTypes()[1]; if (!param2.isAssignableFrom(String.class)) { - throw new IllegalArgumentException("Expected second parameter to be of type: " + String.class.toString()); + throw new IllegalArgumentException("Expected second parameter to be of type: " + String.class); } } this.type = type; diff --git a/json/src/main/groovy/grails/plugin/json/builder/JsonGenerator.java b/json/src/main/groovy/grails/plugin/json/builder/JsonGenerator.java index 50a2e812c..d7e5a42d3 100644 --- a/json/src/main/groovy/grails/plugin/json/builder/JsonGenerator.java +++ b/json/src/main/groovy/grails/plugin/json/builder/JsonGenerator.java @@ -33,9 +33,9 @@ /** * Temporary fork of groovy JsonGenerator until Groovy 2.5.0 is out. * - * Generates JSON from objects. + *

Generates JSON from objects. * - * The {@link Options} builder can be used to configure an instance of a JsonGenerator. + *

The {@link Options} builder can be used to configure an instance of a JsonGenerator. * * @see Options#build() * @since 2.5 @@ -130,9 +130,9 @@ class Options { protected String dateFormat = JSON_DATE_FORMAT; protected Locale dateLocale = JSON_DATE_FORMAT_LOCALE; protected TimeZone timezone = TimeZone.getTimeZone(DEFAULT_TIMEZONE); - protected final Set converters = new LinkedHashSet(); - protected final Set excludedFieldNames = new HashSet(); - protected final Set> excludedFieldTypes = new HashSet>(); + protected final Set converters = new LinkedHashSet<>(); + protected final Set excludedFieldNames = new HashSet<>(); + protected final Set> excludedFieldTypes = new HashSet<>(); public Options() {} @@ -217,7 +217,7 @@ public Options addConverter(Converter converter) { * is serialized. * *

The closure must accept either 1 or 2 parameters. The first parameter - * is required and will be instance of the {@code type} for which the closure + * is required and will be an instance of the {@code type} for which the closure * is registered. The second optional parameter should be of type {@code String} * and, if available, will be passed the name of the key associated with this * value if serializing a JSON Object. This parameter will be {@code null} when @@ -239,7 +239,7 @@ public Options addConverter(Converter converter) { * *

If two or more closures are registered for the exact same type the last * closure based on the order they were specified will be used. When serializing an - * object its type is compared to the list of registered types in the order the were + * object its type is compared to the list of registered types in the order they were * given and the closure for the first suitable type will be called. Therefore, it is * important to register more specific types first. * @@ -257,9 +257,7 @@ public Options addConverter(Class type, Closure closure) { Converter converter = new DefaultJsonGenerator.ClosureConverter(type, closure); - if (converters.contains(converter)) { - converters.remove(converter); - } + converters.remove(converter); return addConverter(converter); } diff --git a/json/src/main/groovy/grails/plugin/json/builder/JsonOutput.java b/json/src/main/groovy/grails/plugin/json/builder/JsonOutput.java index 75a64df4b..06b3be316 100644 --- a/json/src/main/groovy/grails/plugin/json/builder/JsonOutput.java +++ b/json/src/main/groovy/grails/plugin/json/builder/JsonOutput.java @@ -28,6 +28,7 @@ import org.apache.groovy.json.internal.Chr; import org.grails.buffer.FastStringWriter; +import javax.validation.constraints.NotNull; import java.io.*; import java.net.URL; import java.util.*; @@ -35,8 +36,8 @@ /** * Temporary fork of {@link groovy.json.JsonOutput} until Groovy 2.5.0 is out. * - * Class responsible for the actual String serialization of the possible values of a JSON structure. - * This class can also be used as a category, so as to add toJson() methods to various types. + *

Class responsible for the actual String serialization of the possible values of a JSON structure. + * This class can also be used as a category, to add toJson() methods to various types. * * @author Guillaume Laforge * @author Roshan Dawrani @@ -193,7 +194,7 @@ public static String prettyPrint(String jsonPayload) { JsonLexer lexer = new JsonLexer(new StringReader(jsonPayload)); // Will store already created indents. - Map indentCache = new HashMap(); + Map indentCache = new HashMap<>(); while (lexer.hasNext()) { JsonToken token = lexer.next(); switch (token.getType()) { @@ -236,7 +237,7 @@ public static String prettyPrint(String jsonPayload) { case STRING: String textStr = token.getText(); String textWithoutQuotes = textStr.substring(1, textStr.length() - 1); - if (textWithoutQuotes.length() > 0) { + if (!textWithoutQuotes.isEmpty()) { output.addJsonEscapedString(textWithoutQuotes); } else { output.addQuoted(Chr.array()); @@ -281,7 +282,7 @@ public static JsonUnescaped unescaped(CharSequence text) { * Represents unescaped JSON */ public static class JsonUnescaped { - private CharSequence text; + private final CharSequence text; public JsonUnescaped(CharSequence text) { this.text = text; diff --git a/json/src/main/groovy/grails/plugin/json/builder/StreamingJsonBuilder.java b/json/src/main/groovy/grails/plugin/json/builder/StreamingJsonBuilder.java index 2738a1439..75937f5a1 100644 --- a/json/src/main/groovy/grails/plugin/json/builder/StreamingJsonBuilder.java +++ b/json/src/main/groovy/grails/plugin/json/builder/StreamingJsonBuilder.java @@ -39,7 +39,7 @@ public class StreamingJsonBuilder extends GroovyObjectSupport { private static final String DOUBLE_CLOSE_BRACKET = "}}"; private static final String COLON_WITH_OPEN_BRACE = ":{"; - private Writer writer; + private final Writer writer; private final JsonGenerator generator; /** @@ -49,7 +49,7 @@ public class StreamingJsonBuilder extends GroovyObjectSupport { */ public StreamingJsonBuilder(Writer writer) { this.writer = writer; - generator = JsonOutput.DEFAULT_GENERATOR; + this.generator = JsonOutput.DEFAULT_GENERATOR; } /** @@ -369,7 +369,7 @@ public void call(String name, Map map, @DelegatesTo(value = StreamingJsonDelegat writer.write(JsonOutput.COLON); writer.write(generator.toJson(value)); } - StreamingJsonDelegate.cloneDelegateAndGetContent(writer, callable, map.size() == 0, generator); + StreamingJsonDelegate.cloneDelegateAndGetContent(writer, callable, map.isEmpty(), generator); writer.write(DOUBLE_CLOSE_BRACKET); } @@ -793,8 +793,8 @@ public static boolean isCollectionWithClosure(Object[] args) { return args.length == 2 && args[0] instanceof Iterable && args[1] instanceof Closure; } - public static Object writeCollectionWithClosure(Writer writer, Collection coll, @DelegatesTo(value = StreamingJsonDelegate.class, strategy = Closure.DELEGATE_FIRST) Closure closure) throws IOException { - return writeCollectionWithClosure(writer, (Iterable)coll, closure, JsonOutput.DEFAULT_GENERATOR); + public static Object writeCollectionWithClosure(Writer writer, Collection coll, @DelegatesTo(value = StreamingJsonDelegate.class, strategy = Closure.DELEGATE_FIRST) Closure closure) throws IOException { + return writeCollectionWithClosure(writer, coll, closure, JsonOutput.DEFAULT_GENERATOR); } public static Object writeCollectionWithClosure(Writer writer, Iterable coll, @DelegatesTo(value = StreamingJsonDelegate.class, strategy = Closure.DELEGATE_FIRST) Closure closure, JsonGenerator generator) throws IOException { @@ -820,8 +820,7 @@ private static void writeObject(Writer writer, Object object, @DelegatesTo(value writer.write(JsonOutput.CLOSE_BRACE); } - public static void cloneDelegateAndGetContent(Writer w, @DelegatesTo(value = StreamingJsonDelegate.class, strategy = Closure.DELEGATE_FIRST) Closure c) - { + public static void cloneDelegateAndGetContent(Writer w, @DelegatesTo(value = StreamingJsonDelegate.class, strategy = Closure.DELEGATE_FIRST) Closure c) { cloneDelegateAndGetContent(w, c, true); } diff --git a/json/src/main/groovy/grails/plugin/json/renderer/AbstractJsonViewContainerRenderer.groovy b/json/src/main/groovy/grails/plugin/json/renderer/AbstractJsonViewContainerRenderer.groovy index 0466eba48..ff8595420 100644 --- a/json/src/main/groovy/grails/plugin/json/renderer/AbstractJsonViewContainerRenderer.groovy +++ b/json/src/main/groovy/grails/plugin/json/renderer/AbstractJsonViewContainerRenderer.groovy @@ -5,7 +5,6 @@ import grails.rest.render.ContainerRenderer import grails.rest.render.RenderContext import grails.util.GrailsNameUtils import grails.views.Views -import grails.views.resolve.TemplateResolverUtils import groovy.transform.CompileStatic import groovy.transform.InheritConstructors import org.grails.plugins.web.rest.render.ServletRenderContext diff --git a/json/src/main/groovy/grails/plugin/json/renderer/JsonViewJsonRenderer.groovy b/json/src/main/groovy/grails/plugin/json/renderer/JsonViewJsonRenderer.groovy index 82f8633da..dad8e5680 100644 --- a/json/src/main/groovy/grails/plugin/json/renderer/JsonViewJsonRenderer.groovy +++ b/json/src/main/groovy/grails/plugin/json/renderer/JsonViewJsonRenderer.groovy @@ -7,7 +7,6 @@ import grails.views.mvc.SmartViewResolver import grails.views.mvc.renderer.DefaultViewRenderer import grails.web.mime.MimeType import groovy.transform.CompileStatic -import org.springframework.web.servlet.ViewResolver /** * A renderer that will lookup a JSON view if it exists and render it, otherwise fallback to default diff --git a/json/src/main/groovy/grails/plugin/json/view/JsonViewConfiguration.groovy b/json/src/main/groovy/grails/plugin/json/view/JsonViewConfiguration.groovy index dd93baf24..fbe9b72af 100644 --- a/json/src/main/groovy/grails/plugin/json/view/JsonViewConfiguration.groovy +++ b/json/src/main/groovy/grails/plugin/json/view/JsonViewConfiguration.groovy @@ -2,6 +2,7 @@ package grails.plugin.json.view import grails.views.GenericViewConfiguration import grails.web.mime.MimeType +import groovy.transform.CompileStatic import org.springframework.beans.BeanUtils import org.springframework.boot.context.properties.ConfigurationProperties @@ -13,6 +14,7 @@ import java.beans.PropertyDescriptor * @author Graeme Rocher * @since 1.0 */ +@CompileStatic @ConfigurationProperties('grails.views.json') class JsonViewConfiguration implements GenericViewConfiguration { diff --git a/json/src/main/groovy/grails/plugin/json/view/JsonViewGeneratorConfiguration.groovy b/json/src/main/groovy/grails/plugin/json/view/JsonViewGeneratorConfiguration.groovy index 345576e59..4b912ad5b 100644 --- a/json/src/main/groovy/grails/plugin/json/view/JsonViewGeneratorConfiguration.groovy +++ b/json/src/main/groovy/grails/plugin/json/view/JsonViewGeneratorConfiguration.groovy @@ -1,8 +1,11 @@ package grails.plugin.json.view +import groovy.transform.CompileStatic + /** * Created by jameskleeh on 11/8/16. */ +@CompileStatic class JsonViewGeneratorConfiguration { Boolean escapeUnicode = false diff --git a/json/src/main/groovy/grails/plugin/json/view/JsonViewGrailsPlugin.groovy b/json/src/main/groovy/grails/plugin/json/view/JsonViewGrailsPlugin.groovy index a93e1ef30..514c50663 100644 --- a/json/src/main/groovy/grails/plugin/json/view/JsonViewGrailsPlugin.groovy +++ b/json/src/main/groovy/grails/plugin/json/view/JsonViewGrailsPlugin.groovy @@ -1,34 +1,25 @@ package grails.plugin.json.view -import grails.plugin.json.renderer.ErrorsJsonViewRenderer + import grails.plugin.json.view.api.jsonapi.DefaultJsonApiIdRenderer -import grails.plugin.json.view.api.jsonapi.JsonApiIdRenderStrategy import grails.plugin.json.view.mvc.JsonViewResolver -import grails.plugins.* -import grails.util.BuildSettings -import grails.util.Environment -import grails.util.Metadata -import grails.views.ViewsEnvironment +import grails.plugins.Plugin import grails.views.mvc.GenericGroovyTemplateViewResolver import grails.views.resolve.PluginAwareTemplateResolver -import org.grails.io.support.GrailsResourceUtils -import org.springframework.validation.Errors class JsonViewGrailsPlugin extends Plugin { // the version or versions of Grails the plugin is designed for - def grailsVersion = "4.0.0.BUILD-SNAPSHOT > *" + def grailsVersion = "6.0.0 > *" - def title = "JSON View" // Headline display name of the plugin + def title = "JSON Views" // Headline display name of the plugin def author = "Graeme Rocher" def authorEmail = "graeme.rocher@gmail.com" - def description = '''\ -A plugin that allows rendering of JSON views -''' + def description = "A plugin that allows rendering of JSON views" def profiles = ['web'] // URL to the plugin's documentation - def documentation = "http://grails.github.io/grails-views/latest" + def documentation = "https://grails.github.io/grails-views/latest" // Extra (optional) plugin metadata @@ -36,16 +27,16 @@ A plugin that allows rendering of JSON views def license = "APACHE" // Details of company behind the plugin (if there is one) - def organization = [ name: "OCI", url: "http://www.ociweb.com/" ] + def organization = [ name: "OCI", url: "https://www.ociweb.com/" ] // Any additional developers beyond the author specified above. def developers = [ [ name: "Graeme Rocher", email: "graeme.rocher@gmail.com" ]] // Location of the plugin's issue tracker. - def issueManagement = [ system: "Github", url: "http://github.com/grails/grails-views/issues" ] + def issueManagement = [ system: "Github", url: "https://github.com/grails/grails-views/issues" ] // Online location of the plugin's browseable source code. - def scm = [ url: "http://github.com/grails/grails-views" ] + def scm = [ url: "https://github.com/grails/grails-views" ] Closure doWithSpring() { {-> jsonApiIdRenderStrategy(DefaultJsonApiIdRenderer) diff --git a/json/src/main/groovy/grails/plugin/json/view/api/GrailsJsonViewHelper.groovy b/json/src/main/groovy/grails/plugin/json/view/api/GrailsJsonViewHelper.groovy index 0a519cfa7..42c5870a1 100644 --- a/json/src/main/groovy/grails/plugin/json/view/api/GrailsJsonViewHelper.groovy +++ b/json/src/main/groovy/grails/plugin/json/view/api/GrailsJsonViewHelper.groovy @@ -3,6 +3,7 @@ package grails.plugin.json.view.api import grails.plugin.json.builder.JsonOutput import grails.plugin.json.builder.StreamingJsonBuilder import grails.views.api.GrailsViewHelper +import groovy.transform.CompileStatic /** * Additional methods specific to JSON views @@ -10,6 +11,7 @@ import grails.views.api.GrailsViewHelper * @author Graeme Rocher * @since 1.0 */ +@CompileStatic interface GrailsJsonViewHelper extends GrailsViewHelper { /** diff --git a/json/src/main/groovy/grails/plugin/json/view/api/HalViewHelper.groovy b/json/src/main/groovy/grails/plugin/json/view/api/HalViewHelper.groovy index e36f80635..92e0667d2 100644 --- a/json/src/main/groovy/grails/plugin/json/view/api/HalViewHelper.groovy +++ b/json/src/main/groovy/grails/plugin/json/view/api/HalViewHelper.groovy @@ -2,11 +2,13 @@ package grails.plugin.json.view.api import grails.plugin.json.builder.JsonOutput import grails.plugin.json.builder.StreamingJsonBuilder +import groovy.transform.CompileStatic /** * @author Graeme Rocher * @since 1.1.0 */ +@CompileStatic interface HalViewHelper { /** diff --git a/json/src/main/groovy/grails/plugin/json/view/api/JsonView.groovy b/json/src/main/groovy/grails/plugin/json/view/api/JsonView.groovy index 9ac2e962c..1f9210152 100644 --- a/json/src/main/groovy/grails/plugin/json/view/api/JsonView.groovy +++ b/json/src/main/groovy/grails/plugin/json/view/api/JsonView.groovy @@ -107,7 +107,7 @@ trait JsonView extends GrailsView { * @return * @throws IOException */ - public Object json(Map m) throws IOException { + Object json(Map m) throws IOException { json.call m } diff --git a/json/src/main/groovy/grails/plugin/json/view/api/internal/DefaultGrailsJsonViewHelper.groovy b/json/src/main/groovy/grails/plugin/json/view/api/internal/DefaultGrailsJsonViewHelper.groovy index a5b38d7ab..0efba58be 100644 --- a/json/src/main/groovy/grails/plugin/json/view/api/internal/DefaultGrailsJsonViewHelper.groovy +++ b/json/src/main/groovy/grails/plugin/json/view/api/internal/DefaultGrailsJsonViewHelper.groovy @@ -616,7 +616,7 @@ class DefaultGrailsJsonViewHelper extends DefaultJsonViewHelper implements Grail } } else { jsonDelegate.call(propertyName, (Iterable)value) { child -> - Map idProperties = getValidIdProperties(associatedEntity, child, incs, excs, "${qualified}.") + Map idProperties = getValidIdProperties(associatedEntity, child, incs, excs, "${qualified}.") as Map if (idProperties.size() > 0) { renderEntityId((StreamingJsonBuilder.StreamingJsonDelegate) getDelegate(), processedObjects, incs, excs, "${qualified}.", isDeep, renderNulls, expandProperties, idProperties) } else { @@ -764,7 +764,6 @@ class DefaultGrailsJsonViewHelper extends DefaultJsonViewHelper implements Grail return out } } - } @Override diff --git a/json/src/main/groovy/grails/plugin/json/view/api/internal/DefaultHalViewHelper.groovy b/json/src/main/groovy/grails/plugin/json/view/api/internal/DefaultHalViewHelper.groovy index 9c1f3f149..a60ce0997 100644 --- a/json/src/main/groovy/grails/plugin/json/view/api/internal/DefaultHalViewHelper.groovy +++ b/json/src/main/groovy/grails/plugin/json/view/api/internal/DefaultHalViewHelper.groovy @@ -202,7 +202,7 @@ class DefaultHalViewHelper extends DefaultJsonViewHelper implements HalViewHelpe } if(paginationObject != null) { - List links = getPaginationLinks(paginationObject, total.intValue(), jsonView.params) + List links = getPaginationLinks(paginationObject, total.intValue(), jsonView.params) as List for(link in links) { ((StreamingJsonDelegate) delegate).call(link.rel) { ((StreamingJsonDelegate) delegate).call(HREF_ATTRIBUTE, link.href) @@ -253,7 +253,7 @@ class DefaultHalViewHelper extends DefaultJsonViewHelper implements HalViewHelpe ((StreamingJsonDelegate) delegate).call(HREFLANG_ATTRIBUTE, locale.toString()) ((StreamingJsonDelegate) delegate).call(TYPE_ATTRIBUTE, contentTypeMimeType ?: contentType) } - List links = getPaginationLinks(object, total, max, offset, sort, order) + List links = getPaginationLinks(object, total, max, offset, sort, order) as List for(link in links) { ((StreamingJsonDelegate) delegate).call(link.rel) { ((StreamingJsonDelegate) delegate).call(HREF_ATTRIBUTE, link.href) @@ -401,7 +401,7 @@ class DefaultHalViewHelper extends DefaultJsonViewHelper implements HalViewHelpe ((StreamingJsonDelegate) delegate).call(TYPE_ATTRIBUTE, contentType) } - Set links = getLinks(object) + Set links = getLinks(object) as Set for (link in links) { ((StreamingJsonDelegate) delegate).call(link.rel) { ((StreamingJsonDelegate) delegate).call(HREF_ATTRIBUTE, link.href) diff --git a/json/src/main/groovy/grails/plugin/json/view/api/jsonapi/JsonApiIdRenderStrategy.groovy b/json/src/main/groovy/grails/plugin/json/view/api/jsonapi/JsonApiIdRenderStrategy.groovy index 18f8739cb..e89779034 100644 --- a/json/src/main/groovy/grails/plugin/json/view/api/jsonapi/JsonApiIdRenderStrategy.groovy +++ b/json/src/main/groovy/grails/plugin/json/view/api/jsonapi/JsonApiIdRenderStrategy.groovy @@ -1,7 +1,9 @@ package grails.plugin.json.view.api.jsonapi +import groovy.transform.CompileStatic import org.grails.datastore.mapping.model.PersistentProperty +@CompileStatic interface JsonApiIdRenderStrategy { /** diff --git a/json/src/main/groovy/grails/plugin/json/view/internal/JsonTemplateTypeCheckingExtension.groovy b/json/src/main/groovy/grails/plugin/json/view/internal/JsonTemplateTypeCheckingExtension.groovy index 737c6643c..1ddb71518 100644 --- a/json/src/main/groovy/grails/plugin/json/view/internal/JsonTemplateTypeCheckingExtension.groovy +++ b/json/src/main/groovy/grails/plugin/json/view/internal/JsonTemplateTypeCheckingExtension.groovy @@ -4,10 +4,11 @@ import grails.plugin.json.builder.StreamingJsonBuilder import grails.plugin.json.view.api.internal.TemplateRenderer import grails.views.api.http.Parameters import grails.views.compiler.BuilderTypeCheckingExtension +import groovy.transform.CompileDynamic +import groovy.transform.CompileStatic import org.codehaus.groovy.ast.ClassHelper import org.codehaus.groovy.ast.ClassNode import org.codehaus.groovy.ast.MethodNode -import org.codehaus.groovy.ast.expr.Expression import org.codehaus.groovy.ast.expr.MethodCallExpression import org.codehaus.groovy.ast.expr.PropertyExpression import org.codehaus.groovy.ast.expr.VariableExpression @@ -18,6 +19,7 @@ import org.codehaus.groovy.control.SourceUnit * * @author Graeme Rocher */ +@CompileStatic class JsonTemplateTypeCheckingExtension extends BuilderTypeCheckingExtension { private static final ClassNode BUILDER_CLASS_NODE = ClassHelper.make(StreamingJsonBuilder) private static final MethodNode JSON_BUILDER_INVOKE_METHOD = ClassHelper.make(StreamingJsonBuilder).getMethods('invokeMethod')[0] @@ -37,7 +39,7 @@ class JsonTemplateTypeCheckingExtension extends BuilderTypeCheckingExtension { insideScope = true } else if(methodCallExpression.objectExpression instanceof VariableExpression) { - VariableExpression ve = methodCallExpression.objectExpression + VariableExpression ve = methodCallExpression.objectExpression as VariableExpression if(ve.name == 'json') { insideScope = true } @@ -46,6 +48,7 @@ class JsonTemplateTypeCheckingExtension extends BuilderTypeCheckingExtension { } @Override + @CompileDynamic boolean isMethodDynamic(Object receiver, Object name, Object argList, Object argTypes, Object call) { if( receiver.name == TEMPLATE_NAMESPACE.name) { return true diff --git a/markup/build.gradle b/markup/build.gradle index d1b784adb..f17a3ebb0 100644 --- a/markup/build.gradle +++ b/markup/build.gradle @@ -1,36 +1,46 @@ -buildscript { - repositories { - maven { url "https://repo.grails.org/grails/core" } - } - dependencies { - classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" - } +plugins { + id 'groovy' + id 'java-library' + id 'maven-publish' + id 'org.grails.grails-plugin' + id 'signing' } -ext { - userOrg = 'grails' -} +group = 'org.grails.plugins' +ext.set('projectDesc', 'Grails Markup Views') + +dependencies { -group "org.grails.plugins" + api project(':views-core') -apply plugin: "org.grails.grails-gsp" + implementation libs.grails.core + implementation libs.grails.rest -dependencyManagement { - imports { - mavenBom "org.grails:grails-bom:$grailsVersion" - } - applyMavenExclusions false + testImplementation libs.spock.core + testRuntimeOnly libs.slf4j.nop // Get rid of warning about missing slf4j implementation during test task } -dependencies { - api "org.grails:grails-core:$grailsVersion" - api project(":views-core") +java { + sourceCompatibility = JavaVersion.toVersion(libs.versions.java.baseline.get()) + withJavadocJar() + withSourcesJar() +} - testImplementation "org.grails:grails-web-testing-support:$testingSupportVersion" +tasks.named('bootJar') { + enabled = false // Don't need a bootJar for plugin +} + +tasks.named('jar', Jar) { + enabled = true // Need a jar for plugin + archiveClassifier = '' // Don't want the '-plain' classifier +} - console "org.grails:grails-console" +tasks.named('javadocJar', Jar) { + from tasks.named('groovydoc') } -springBoot { - mainClass.set('grails.plugin.markup.view.Application') +tasks.named('build') { + finalizedBy 'javadocJar', 'sourcesJar' } + +apply from: rootProject.layout.projectDirectory.file('gradle/grailsCentralPublishing.gradle') \ No newline at end of file diff --git a/markup/gradle/wrapper/gradle-wrapper.jar b/markup/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index e708b1c02..000000000 Binary files a/markup/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/markup/gradle/wrapper/gradle-wrapper.properties b/markup/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index d355f4c4f..000000000 --- a/markup/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/markup/gradlew b/markup/gradlew deleted file mode 100755 index 1b6c78733..000000000 --- a/markup/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/markup/gradlew.bat b/markup/gradlew.bat deleted file mode 100644 index ac1b06f93..000000000 --- a/markup/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/markup/grails-app/init/grails/plugin/markup/view/Application.groovy b/markup/grails-app/init/grails/plugin/markup/view/Application.groovy deleted file mode 100644 index f7afac43e..000000000 --- a/markup/grails-app/init/grails/plugin/markup/view/Application.groovy +++ /dev/null @@ -1,10 +0,0 @@ -package grails.plugin.markup.view - -import grails.boot.GrailsApp -import grails.boot.config.GrailsAutoConfiguration - -class Application extends GrailsAutoConfiguration { - static void main(String[] args) { - GrailsApp.run(Application, args) - } -} \ No newline at end of file diff --git a/markup/src/main/groovy/grails/plugin/markup/view/MarkupViewCompiler.groovy b/markup/src/main/groovy/grails/plugin/markup/view/MarkupViewCompiler.groovy index 307066dea..e16778e50 100644 --- a/markup/src/main/groovy/grails/plugin/markup/view/MarkupViewCompiler.groovy +++ b/markup/src/main/groovy/grails/plugin/markup/view/MarkupViewCompiler.groovy @@ -2,14 +2,14 @@ package grails.plugin.markup.view import grails.plugin.markup.view.internal.MarkupViewsTransform import grails.views.AbstractGroovyTemplateCompiler +import grails.views.ViewConfiguration import grails.views.compiler.ViewsTransform -import groovy.io.FileType -import groovy.text.markup.BaseTemplate import groovy.transform.CompileStatic import groovy.transform.InheritConstructors import org.codehaus.groovy.control.CompilerConfiguration import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer import org.codehaus.groovy.control.customizers.CompilationCustomizer + /** * A compiler for markup templates * @@ -23,10 +23,11 @@ class MarkupViewCompiler extends AbstractGroovyTemplateCompiler { @Override protected CompilerConfiguration configureCompiler(CompilerConfiguration configuration) { super.configureCompiler(configuration) + ViewConfiguration viewConfiguration = (ViewConfiguration) this.viewConfiguration def templateCustomizer = (CompilationCustomizer) getClass().classLoader.loadClass("groovy.text.markup.TemplateASTTransformer") .newInstance(viewConfiguration) configuration.addCompilationCustomizers(templateCustomizer) - if(viewConfiguration.compileStatic) { + if(viewConfiguration.isCompileStatic()) { configuration.addCompilationCustomizers( new ASTTransformationCustomizer(Collections.singletonMap("extensions", "groovy.text.markup.MarkupTemplateTypeCheckingExtension"), CompileStatic.class)); } diff --git a/markup/src/main/groovy/grails/plugin/markup/view/MarkupViewGrailsPlugin.groovy b/markup/src/main/groovy/grails/plugin/markup/view/MarkupViewGrailsPlugin.groovy index 97e88e5a1..149f32b13 100644 --- a/markup/src/main/groovy/grails/plugin/markup/view/MarkupViewGrailsPlugin.groovy +++ b/markup/src/main/groovy/grails/plugin/markup/view/MarkupViewGrailsPlugin.groovy @@ -19,18 +19,16 @@ import org.grails.io.support.GrailsResourceUtils class MarkupViewGrailsPlugin extends Plugin { // the version or versions of Grails the plugin is designed for - def grailsVersion = "4.0.0.BUILD-SNAPSHOT > *" + def grailsVersion = "6.0.0 > *" - def title = "JSON View" // Headline display name of the plugin + def title = "Markup Views" // Headline display name of the plugin def author = "Graeme Rocher" def authorEmail = "graeme.rocher@gmail.com" - def description = '''\ -A plugin that allows rendering of JSON views -''' + def description = "A plugin that allows rendering of markup views" def profiles = ['web'] // URL to the plugin's documentation - def documentation = "http://grails.github.io/grails-views/latest/" + def documentation = "https://grails.github.io/grails-views/latest/" // Extra (optional) plugin metadata @@ -38,16 +36,16 @@ A plugin that allows rendering of JSON views def license = "APACHE" // Details of company behind the plugin (if there is one) - def organization = [ name: "OCI", url: "http://www.ociweb.com/" ] + def organization = [ name: "OCI", url: "https://www.ociweb.com/" ] // Any additional developers beyond the author specified above. def developers = [ [ name: "Graeme Rocher", email: "graeme.rocher@gmail.com" ]] // Location of the plugin's issue tracker. - def issueManagement = [ system: "Github", url: "http://github.com/grails/grails-views/issues" ] + def issueManagement = [ system: "Github", url: "https://github.com/grails/grails-views/issues" ] // Online location of the plugin's browseable source code. - def scm = [ url: "http://github.com/grails/grails-views" ] + def scm = [ url: "https://github.com/grails/grails-views" ] Closure doWithSpring() { {-> markupViewConfiguration(MarkupViewConfiguration) diff --git a/publishing/grailsCentralPublishing.gradle b/publishing/grailsCentralPublishing.gradle deleted file mode 100644 index fe31d7539..000000000 --- a/publishing/grailsCentralPublishing.gradle +++ /dev/null @@ -1,122 +0,0 @@ -ext."signing.keyId" = rootProject.hasProperty("signing.keyId") ? rootProject.getProperty('signing.keyId') : System.getenv('SIGNING_KEY') -ext."signing.password" = rootProject.hasProperty("signing.password") ? rootProject.getProperty('signing.password') : System.getenv('SIGNING_PASSPHRASE') -ext."signing.secretKeyRingFile" = rootProject.hasProperty("signing.secretKeyRingFile") ? rootProject.getProperty('signing.secretKeyRingFile') : "${System.properties['user.home']}${File.separator}.gnupg${File.separator}secring.gpg" - -ext.pomInfo = { - delegate.url 'https://views.grails.org/latest/' - delegate.licenses { - delegate.license { - delegate.name 'The Apache Software License, Version 2.0' - delegate.url 'https://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - delegate.scm { - delegate.url 'https://github.com/grails/grails-views/' - delegate.connection 'scm:git:git://github.com/grails/grails-views' - delegate.developerConnection 'scm:git:ssh://github.com:grails/grails-views' - } - delegate.developers { - delegate.developer { - delegate.id 'graemerocher' - delegate.name 'Graeme Rocher' - delegate.email 'graeme.rocher@gmail.com' - } - developer { - delegate.id 'puneetbehl' - delegate.name 'Puneet Behl' - delegate.email 'behlp@objectcomputing.com' - } - } -} - -publishing { - publications { - pluginMaven(MavenPublication) { - artifactId project.name - if (project.name != "views-gradle") { - from components.java - } - afterEvaluate { - artifact source: sourcesJar, classifier: "sources" - artifact source: javadocJar, classifier: "javadoc" - } - - if (isGrailsPlugin) { - artifact source: "${project.sourceSets.main.groovy.classesDirectory.getAsFile().get()}/META-INF/grails-plugin.xml", - classifier: "plugin", - extension: 'xml' - } - - pom { - name = 'Grails Views' - description = 'Provides additional view technologies to the Grails framework, including JSON and Markup views.' - } - - pom.withXml { - def pomNode = asNode() - pomNode.children().last() + pomInfo - try { - pomNode.dependencyManagement.replaceNode {} - } catch (Throwable e) { - // ignore - } - - // simply remove dependencies without a version - // version-less dependencies are handled with dependencyManagement - // see https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/8 for more complete solutions - pomNode.dependencies.dependency.findAll { - it.version.text().isEmpty() - }.each { - try { - it.replaceNode {} - } catch (Throwable e) { - // ignore - } - } - } - } - } - - if (version.endsWith('-SNAPSHOT')) { - repositories { - maven { - credentials { - username System.getenv('ARTIFACTORY_USERNAME') ?: rootProject.properties.get('artifactoryUsername') - password System.getenv("ARTIFACTORY_PASSWORD") ?: rootProject.properties.get('artifactoryPassword') - } - - if (group == 'org.grails.plugins') { - url "https://repo.grails.org/grails/plugins3-snapshots-local" - } else { - url "https://repo.grails.org/grails/libs-snapshots-local" - } - } - } - } -} - -jar { - manifest.mainAttributes( - "Built-By": System.properties['user.name'], - "Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")", - "Implementation-Title": "Grails", - "Implementation-Version": grailsVersion, - "Implementation-Vendor": 'grails.org') -} - -afterEvaluate { - signing { - required { isReleaseVersion && gradle.taskGraph.hasTask("publish") } - Publication[] publications = new Publication[project.publishing.publications.size()] - project.publishing.publications.findAll().toArray(publications) - sign(publications) - } - - tasks.withType(Sign) { - onlyIf { isReleaseVersion } - } -} - - - -task install(dependsOn: project.tasks.withType(PublishToMavenLocal)) diff --git a/settings.gradle b/settings.gradle index ea633a995..937467559 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,5 @@ plugins { - id "com.gradle.enterprise" version "3.16.1" + id 'com.gradle.enterprise' version '3.16.1' id 'com.gradle.common-custom-user-data-gradle-plugin' version '1.12.1' } @@ -8,7 +8,7 @@ gradleEnterprise { buildScan { publishAlwaysIf(System.getenv('CI') == 'true') publishIfAuthenticated() - uploadInBackground = System.getenv("CI") == null + uploadInBackground = System.getenv('CI') == null capture { taskInputFiles = true } @@ -25,22 +25,33 @@ buildCache { username = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER') password = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY') } - }} + } +} +rootProject.name = 'grails-views' +dependencyResolutionManagement { + versionCatalogs { + libs { + // Make it possible to override the Groovy version + // via environment variable + def groovyVersion = System.getenv('GROOVY_VERSION') + if (groovyVersion) { + logger.warn "Using custom version $groovyVersion of Groovy due to GROOVY_VERSION being set." + version('groovy', groovyVersion) + } + } + } +} -['core', - 'json', - 'markup', - 'gradle', - 'docs', - 'json-templates', - 'json-testing-support'].each { - include("views-$it") - project(":views-$it").projectDir = new File(settingsDir, it) +['core', 'json', 'docs', 'json-templates', 'json-testing-support', 'markup'].each {dirName -> + include("views-$dirName") + project(":views-$dirName").projectDir = file(dirName) } -include "examples-functional-tests" -project(":examples-functional-tests").projectDir = new File(settingsDir, "examples/functional-tests") +include 'views-gradle' +project(':views-gradle').projectDir = file('gradle-plugin') -include "examples-functional-tests-plugin" -project(":examples-functional-tests-plugin").projectDir = new File(settingsDir, "examples/functional-tests-plugin") +file('examples').eachDir { dir -> + include "examples-$dir.name" + project(":examples-$dir.name").projectDir = dir +}