From e6b2684b588201f5884a256b71daf8ad957e37b0 Mon Sep 17 00:00:00 2001 From: Puneet Behl Date: Fri, 22 Sep 2023 20:32:19 +0530 Subject: [PATCH] For WEB_PLUGIN set packagePlugin prop Fixes #197 --- .../feature/assetPipeline/AssetPipeline.java | 2 +- .../assetPipelineExtension.rocker.raw | 8 ++++++++ .../assetPipeline/AssetPipelineSpec.groovy | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/grails-forge-core/src/main/java/org/grails/forge/feature/assetPipeline/AssetPipeline.java b/grails-forge-core/src/main/java/org/grails/forge/feature/assetPipeline/AssetPipeline.java index 479203de..bf74cbf3 100644 --- a/grails-forge-core/src/main/java/org/grails/forge/feature/assetPipeline/AssetPipeline.java +++ b/grails-forge-core/src/main/java/org/grails/forge/feature/assetPipeline/AssetPipeline.java @@ -66,7 +66,7 @@ public void apply(GeneratorContext generatorContext) { .buildscript()); generatorContext.addBuildPlugin(GradlePlugin.builder() .id("com.bertramlabs.asset-pipeline") - .extension(new RockerWritable(assetPipelineExtension.template())) + .extension(new RockerWritable(assetPipelineExtension.template(generatorContext.getApplicationType()))) .build()); generatorContext.addDependency(Dependency.builder() diff --git a/grails-forge-core/src/main/java/org/grails/forge/feature/assetPipeline/templates/assetPipelineExtension.rocker.raw b/grails-forge-core/src/main/java/org/grails/forge/feature/assetPipeline/templates/assetPipelineExtension.rocker.raw index 753d23b1..27bd22ca 100644 --- a/grails-forge-core/src/main/java/org/grails/forge/feature/assetPipeline/templates/assetPipelineExtension.rocker.raw +++ b/grails-forge-core/src/main/java/org/grails/forge/feature/assetPipeline/templates/assetPipelineExtension.rocker.raw @@ -1,5 +1,13 @@ +@import org.grails.forge.application.ApplicationType + +@args ( + org.grails.forge.application.ApplicationType applicationType +) assets { +@if (applicationType == ApplicationType.WEB_PLUGIN) { + packagePlugin = true +} minifyJs = true minifyCss = true } \ No newline at end of file diff --git a/grails-forge-core/src/test/groovy/org/grails/forge/feature/assetPipeline/AssetPipelineSpec.groovy b/grails-forge-core/src/test/groovy/org/grails/forge/feature/assetPipeline/AssetPipelineSpec.groovy index b278ef0c..8453a7b0 100644 --- a/grails-forge-core/src/test/groovy/org/grails/forge/feature/assetPipeline/AssetPipelineSpec.groovy +++ b/grails-forge-core/src/test/groovy/org/grails/forge/feature/assetPipeline/AssetPipelineSpec.groovy @@ -48,6 +48,24 @@ assets { }''') } + void "test extension packagePlugin is set for application #applicationType"() { + when: + final String template = new BuildBuilder(beanContext) + .applicationType(applicationType) + .features(["asset-pipeline-grails"]) + .render() + + then: + template.contains(''' +assets { + packagePlugin = true + minifyJs = true + minifyCss = true +}''') + where: + applicationType << [ApplicationType.WEB_PLUGIN] + } + void "test assets files are present"() { given: final Map output = generate(ApplicationType.WEB, new Options(TestFramework.SPOCK, JdkVersion.JDK_11))