From 8f6d1ef8dcfa34a6e03a70027f57960abc334a23 Mon Sep 17 00:00:00 2001 From: Puneet Behl Date: Wed, 2 Aug 2023 13:24:00 +0530 Subject: [PATCH 1/2] Move Gradle build plugin version to settings.gradle --- .../main/java/org/grails/forge/build/gradle/GradleBuild.java | 5 +++++ .../feature/build/gradle/templates/buildGradle.rocker.raw | 2 +- .../feature/build/gradle/templates/settingsGradle.rocker.raw | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/grails-forge-core/src/main/java/org/grails/forge/build/gradle/GradleBuild.java b/grails-forge-core/src/main/java/org/grails/forge/build/gradle/GradleBuild.java index 8eaf3bb1..68430680 100644 --- a/grails-forge-core/src/main/java/org/grails/forge/build/gradle/GradleBuild.java +++ b/grails-forge-core/src/main/java/org/grails/forge/build/gradle/GradleBuild.java @@ -79,6 +79,11 @@ public List getPlugins() { return plugins; } + @NonNull + public List getPluginsWithVersion() { + return plugins.stream().filter(plugin -> plugin.getVersion() != null).collect(Collectors.toList()); + } + @NonNull public String renderExtensions() { return renderWritableExtensions(Stream.concat( diff --git a/grails-forge-core/src/main/java/org/grails/forge/feature/build/gradle/templates/buildGradle.rocker.raw b/grails-forge-core/src/main/java/org/grails/forge/feature/build/gradle/templates/buildGradle.rocker.raw index b089c569..10f9be5d 100644 --- a/grails-forge-core/src/main/java/org/grails/forge/feature/build/gradle/templates/buildGradle.rocker.raw +++ b/grails-forge-core/src/main/java/org/grails/forge/feature/build/gradle/templates/buildGradle.rocker.raw @@ -25,7 +25,7 @@ GradleBuild gradleBuild } plugins { @for (GradlePlugin gradlePlugin : gradleBuild.getPlugins()) { - id "@gradlePlugin.getId()" @(gradlePlugin.getVersion() != null ? "version \"" + gradlePlugin.getVersion() + "\"" : "") + id "@gradlePlugin.getId()" } } diff --git a/grails-forge-core/src/main/java/org/grails/forge/feature/build/gradle/templates/settingsGradle.rocker.raw b/grails-forge-core/src/main/java/org/grails/forge/feature/build/gradle/templates/settingsGradle.rocker.raw index ae52614c..0c7d9e6e 100644 --- a/grails-forge-core/src/main/java/org/grails/forge/feature/build/gradle/templates/settingsGradle.rocker.raw +++ b/grails-forge-core/src/main/java/org/grails/forge/feature/build/gradle/templates/settingsGradle.rocker.raw @@ -3,6 +3,7 @@ @import org.grails.forge.build.dependencies.CoordinateResolver @import org.grails.forge.build.dependencies.Coordinate @import org.grails.forge.build.gradle.GradleBuild +@import org.grails.forge.build.gradle.GradlePlugin @import org.grails.forge.feature.Features @args ( @@ -39,6 +40,10 @@ pluginManagement { @if(features.contains("asset-pipeline-grails")) { id "com.bertramlabs.asset-pipeline" version "@assetPipelineVersion" } + + @for (GradlePlugin gradlePlugin : gradleBuild.getPluginsWithVersion()) { + id "@gradlePlugin.getId()" version "@gradlePlugin.getVersion()" + } } } From 34d0c5b3e46db7ab494d217ebb0563a45cd899cc Mon Sep 17 00:00:00 2001 From: Puneet Behl Date: Wed, 2 Aug 2023 20:55:57 +0530 Subject: [PATCH 2/2] Update specifications --- .../asciidoctor/AsciidoctorSpec.groovy | 66 +++++++++++++------ .../grails/forge/feature/test/GebSpec.groovy | 8 ++- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/grails-forge-core/src/test/groovy/org/grails/forge/feature/asciidoctor/AsciidoctorSpec.groovy b/grails-forge-core/src/test/groovy/org/grails/forge/feature/asciidoctor/AsciidoctorSpec.groovy index b3ac0ab0..2c9ab388 100644 --- a/grails-forge-core/src/test/groovy/org/grails/forge/feature/asciidoctor/AsciidoctorSpec.groovy +++ b/grails-forge-core/src/test/groovy/org/grails/forge/feature/asciidoctor/AsciidoctorSpec.groovy @@ -1,35 +1,63 @@ package org.grails.forge.feature.asciidoctor -import io.micronaut.core.version.SemanticVersion import org.grails.forge.ApplicationContextSpec -import org.grails.forge.BuildBuilder -import spock.lang.Unroll +import org.grails.forge.application.ApplicationType +import org.grails.forge.feature.Features +import org.grails.forge.fixture.CommandOutputFixture +import org.grails.forge.options.JdkVersion +import org.grails.forge.options.Options +import org.grails.forge.options.TestFramework -class AsciidoctorSpec extends ApplicationContextSpec { +class AsciidoctorSpec extends ApplicationContextSpec implements CommandOutputFixture { - @Unroll void 'test gradle asciidoctor feature'() { when: - String template = new BuildBuilder(beanContext) - .features(['asciidoctor']) - .render() + final Features features = getFeatures(["asciidoctor"]) then: - template.contains("apply from: \"gradle/asciidoc.gradle\"") + features.contains("asciidoctor") + } - when: - String pluginId = 'org.asciidoctor.jvm.convert' - String applyPlugin = 'id "' + pluginId + '" version "' + void "test asciidoctor gradle configurations"() { + given: + final def output = generate(ApplicationType.WEB, new Options(TestFramework.SPOCK, JdkVersion.JDK_11), ["asciidoctor"]) + final def buildGradle = output["build.gradle"] + final def settingGradle = output["settings.gradle"] - then: - template.contains(applyPlugin) + expect: + settingGradle.contains("id \"org.asciidoctor.jvm.convert\" version \"4.0.0-alpha.1\"") + buildGradle.contains("apply from: \"gradle/asciidoc.gradle\"") + } - when: - Optional semanticVersionOptional = parseCommunityGradlePluginVersion(pluginId, template).map(SemanticVersion::new) + void "test asciidoctor gradle configurations"() { + given: + final def output = generate(ApplicationType.WEB, new Options(TestFramework.SPOCK, JdkVersion.JDK_11), ["asciidoctor"]) + final def asciidocGradle = output["gradle/asciidoc.gradle"] + + expect: + asciidocGradle.contains("""asciidoctorj { + version '2.1.0' + modules { + diagram { + version '1.5.18' + } + } - then: - noExceptionThrown() - semanticVersionOptional.isPresent() + options doctype: "book", ruby: "erubis" + + attributes "sourcedir": "src/docs/asciidoc", + "source-highlighter": "coderay", + "toc": "left", + "idprefix": "", + "idseparator": "-", + "icons": "font", + "setanchors": "", + "listing-caption": "", + "imagesdir": "images", + "project-version": "\$project.version", + "revnumber": "\$project.version" +} +""") } } diff --git a/grails-forge-core/src/test/groovy/org/grails/forge/feature/test/GebSpec.groovy b/grails-forge-core/src/test/groovy/org/grails/forge/feature/test/GebSpec.groovy index 58dac40d..d29775ab 100644 --- a/grails-forge-core/src/test/groovy/org/grails/forge/feature/test/GebSpec.groovy +++ b/grails-forge-core/src/test/groovy/org/grails/forge/feature/test/GebSpec.groovy @@ -61,9 +61,11 @@ class GebSpec extends ApplicationContextSpec implements CommandOutputFixture { given: final def output = generate(ApplicationType.WEB, new Options(TestFramework.SPOCK, JdkVersion.JDK_11)) final def buildGradle = output["build.gradle"] + final def settingGradle = output["settings.gradle"] expect: - buildGradle.contains("id \"com.github.erdi.webdriver-binaries\" version \"3.0\"") + settingGradle.contains("id \"com.github.erdi.webdriver-binaries\" version \"3.0\"") + buildGradle.contains("id \"com.github.erdi.webdriver-binaries\"") buildGradle.contains("webdriverBinaries") buildGradle.contains("chromedriver '110.0.5481.77'") buildGradle.contains("geckodriver '0.32.2'") @@ -74,9 +76,11 @@ class GebSpec extends ApplicationContextSpec implements CommandOutputFixture { given: final def output = generate(ApplicationType.WEB, new Options(TestFramework.SPOCK, JdkVersion.JDK_11, OperatingSystem.WINDOWS)) final def buildGradle = output["build.gradle"] + final def settingGradle = output["settings.gradle"] expect: - buildGradle.contains("id \"com.github.erdi.webdriver-binaries\" version \"3.0\"") + settingGradle.contains("id \"com.github.erdi.webdriver-binaries\" version \"3.0\"") + buildGradle.contains("id \"com.github.erdi.webdriver-binaries\"") buildGradle.contains("webdriverBinaries") buildGradle.contains("chromedriver '110.0.5481.77'") buildGradle.contains("geckodriver '0.32.2'")