getting grails 2.5.4 asset pipeline excludes to work - grails

I am unable to get either the sass asset pipeline or the less asset pipeline plugin to work, if I am using sass or less imports.
If I only have one sass or less file, grail war works fine.
In my scenario however, file1.scss imports file2.scss, and in the end I only want to end up with a file1.css created from both. This should be possible according to this
https://grails.org/plugin/sass-asset-pipeline
But I am getting this output
| Minifying File 345 of 398 - file2.
| Error WAR packaging error: Stream closed
from grails war --stacktrace --verbose
Both files are in the same directory and have teh following contents:
file1.scss
#import "file2";
.brand {background-color:$mainColor;}
file2.scss
$mainColor: #277D85;
My build config has this:
plugins = {
...
compile ':asset-pipeline:2.5.7'
provided ":sass-asset-pipeline:2.9.1"
}
grails.assets.minifyJs = false
grails.assets.minifyCss = false
grails.assets.minifyOptions = [
optimizationLevel: 'WHITESPACE_ONLY'
]
grails.assets.excludes = ["**/file2.scss"]
What am I doing wrong?
How can I get more insights into what's going on here.

Your plugin block should remain in BuildConfig.groovy. However, the rest should be placed in Config.groovy

Related

Grails: excluding a JS file from minification

I read tons of documentation on asset-pipeline Grails plugin, but found no definite answers and I can not exclude a single stupid JS file from being minified.
Grails is in ver. 3.3.6 and assetPipelineVersion 2.14.1.
Goal:
Stop minifying grails-app/assets/javascripts/json-tree/json-tree.js.
What I tried:
I changed the assets block in build.gradle:
assets {
minifyJs = true
minifyCss = true
includes = []
excludes = [ '**/json-tree.js' ] // tried also with 'json-tree/json-tree.js'
}
I also added a section to my application.yml:
grails:
assets:
excludes: ['json-tree/*.js'] # also tried with **
Problem: the file still gets minified.
How can I solve the problem?
Also, how the assets pipeline should be configured: per build.gradle or application.yml or both?
Please try with following :
grails.assets.minifyOptions.excludes = ["json-tree/json-tree.js"]
To exclude single file you can try above otherwise you can exclude whole folder from minify
grails.assets.minifyOptions.excludes = ["json-tree/*.js"]
For more information you check documentation
Hope this will help you

Grails 3 JNDI datasource for Tomcat, Weblogic, Glassfish - Vs Grails 2

I'm experimenting with migrating from Grails 2 to Grails 3.
In Grails 2, I used this as my JNDI name within datasource.groovy file, within the Production-env
jndiName = "${(System.getProperty('catalina.home') && (System.getProperty('java.class.path')).trim().toLowerCase().indexOf('tomcat') > 0 ) ? 'java:comp/env/' : ''}jdbc/myGrails"
I found that worked well for me for Glassfish, Weblogic, and Tomcat.
However, when i try this in Grails 3, within the application.yml:
jndiName: ${(System.getProperty('catalina.home') && (System.getProperty('java.class.path')).trim().toLowerCase().indexOf('tomcat') > 0 ) ? 'java:comp/env/' : ''}jdbc/myGrails
I get this error when running "grails run-app":
| Error Error occurred running Grails CLI: mapping values are not allowed here
in 'reader', line 123, column 169:
... mcat') > 0 ) ? 'java:comp/env/' : ''}jdbc/traxGrails
^
(Use --stacktrace to see the full trace)
If I do use this in Grails 3:
jndiName: java:/comp/env/jdbc/myGrails
Then it works fine when using Grails run-app, and also works fine to deploy the WAR to Tomcat.
Can someone help me in getting my "jndi expression" from Grails 2 to work in Grails 3?
It looks like you're trying to use groovy syntax in a yml file, which does not work. You can create an application.groovy file (which will be merged with the application.yml file) if you want to use groovy syntax.
Also take a look at the many ways spring-boot allows you to inject properties via env variables, properties, yml, etc. http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html

What classspath is used for executing Grails' application.groovy

What classspath is used for compiling/executing Grails' application.groovy?
In my application.groovy, I instantiate a custom class (contained in a dependency's jar) and assign it to one of the config properties, like so:
environments {
production {
configProperty = new com.example.CustomClass()
I recently upgraded my application from Grails 3.1.5 to 3.2.2, and now this no longer works.
I receive an error like the following when I try to run grails run-app:
Error occurred running Grails CLI: startup failed:
script14788250424471597489853.groovy: 43: unable to resolve class com.example.CustomClass
# line 43, column 33.
configProperty = new com.example.CustomClass()
(Notice that the code is in the production block, but I'm running in development (run-app). That makes me think it's the compilation of this script that is failing.)
So I'm guessing I just need to add my dependency (that contains the CustomClass) to the appropriate classpath, but I'm not sure which one.
I'm using gradle, and have the following in my build.gradle file, to pull in the dependency containing CustomClass:
buildscript {
dependencies {
classpath "com.example:custom-module:1.1"
// ...
dependencies {
compile group: 'com.example', name: 'custom-module', version:'1.1'
}
The grails-app/conf/application.groovy file shouldn't reference application classes because it is read before compilation. If you wish to reference application classes in configuration please use grails-app/conf/runtime.groovy

Grails Asset Pipeline - minifyJs set to true not working

I used grails asset pipeline plugin to minify my application (I don't have any problem when running grails run-app) the problem arises when I'm going to generate a war file to deploy into tomcat server.
Currently using ':asset-pipeline:1.9.9'
currently My Config.groovy has this setup
grails.assets.minifyJs = true
grails.assets.minifyCss = true
grails.assets.bundle = true
The Particular problem here is when I'm going to set minifyJs = true
when I'm going to set minifyJs = false there's no error but my war file are not going to work when deployed to tomcat server.
| Error 2016-03-13 01:50:16,590 [main] ERROR pipeline.AssetCompiler - Uglify JS Exception
Message: [object Object] (/application/target/work/resources/uglifyjs/lib/parse-js.js#273)
Line | Method ->> 273 | _c_js_error_13 in org.mozilla.javascript.gen._application_target_work_resources_uglifyjs_lib_parse_js_js_2
I don't know whats going on or I missed something?
Immediately above the error message lines you quoted should be lines like this:
| Processing File 851 of 888 - jquery/src/intro.js
| Uglifying File 851 of 888 - jquery/src/intro
Whatever javascript file that is mentioned there probably has either some syntax error, or possibly weird non-ascii characters that were introduced because of file encoding issues or something.

Grails and release plugin

I'm trying to use the release 2.0.4 plugin to deploy my war through grails 2.1.1 to artifactory server.
My BuildConfig.groovy has:
grails.project.repos.snap.url = "http://server:8080/artifactory/apps-snapshot-local"
grails.project.repos.snap.username = "user"
grails.project.repos.snap.password = "password"
grails.project.repos.rel.url = "http://server:8080/artifactory/apps-release-local"
grails.project.repos.rel.username = "user"
grails.project.repos.rel.password = "password"
grails.project.repos.default = "rel"
When I just do the "grails maven-deploy" it works and deploys to my rel server as expected. When I try to override the default target through the command line I get failures.
grails maven-deploy --repository=snap
I get this:
| Done creating WAR snap
| POM generated: C:\dev-git\DBUpdateWeb\target/pom.xml.
| Error Error deploying artifact: C:\dev-git\DBUpdateWeb\target\DBUpdateWeb.war (The system cannot find the file specified)
| Error Have you specified a configured repository to deploy to (--repository argument) or specified distributionManagement in your POM?
When I do specify the --repository tag it doesn't generate a war even though it says it did. Any help is appreciated. Thanks in advance.
Try grails maven-deploy "--repository=snap".
Also, specify app.version in application.properties so that the WAR will be standard compliant (1.0-SNAPSHOT for publishing to the snapshots repository and 1.0 for releases), and comment out the grails.project.war.file line in BuildConfig.groovy.

Resources