Grails + Maven + Assets Pipeline = HEADACHE??

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails + Maven + Assets Pipeline = HEADACHE??

ksnj
I just finished converting a project over from resources to the assets pipeline (an application plus a couple custom plugins)... took a bit to get it all working due to the number of resources (assets) and plugins -- but finally got it all working locally.

Last step was to prove this all out in our build pipeline and deployed to tomcat.  Got all the maven dependency issues and exclusions worked out (grails 2.3.7) which was it's own headache.  

Last step, finally got the app up and running... go the the home page... completely unstylized 1995 web app.  ??!

View source shows:
    <asset:stylesheet href="application.css"/>
in the header!

Why are assets not getting processed with the war is built using "mvn install"?

I'm hoping there is some simple thing I'm missing that will make me look foolish for asking such a simple question.

(And yes, in this environment I have NO choice but to use a mvn command to build the final deployed artifacts due to the build and ci environments in place here.)

Grails 2.3.7
Assets: 1.7.2
Less-Asset: 1.7.0

Kevin
Reply | Threaded
Open this post in threaded view
|

Re: Grails + Maven + Assets Pipeline = HEADACHE??

David Estes
The AssetCompiler is triggered by a GANT event via grails war…Are you saying that this event is not being triggered. Sorry, not familiar with the mvn build process. If there is a hook to trigger this build that would be awesome.
-- 
David Estes
Sent with Airmail

On April 15, 2014 at 3:56:00 PM, ksnj ([hidden email]) wrote:

I just finished converting a project over from resources to the assets
pipeline (an application plus a couple custom plugins)... took a bit to get
it all working due to the number of resources (assets) and plugins -- but
finally got it all working locally.

Last step was to prove this all out in our build pipeline and deployed to
tomcat. Got all the maven dependency issues and exclusions worked out
(grails 2.3.7) which was it's own headache.

Last step, finally got the app up and running... go the the home page...
completely unstylized 1995 web app. ??!

View source shows:
<asset:stylesheet href="application.css"/>
in the header!

Why are assets not getting processed with the war is built using "mvn
install"?

I'm hoping there is some simple thing I'm missing that will make me look
foolish for asking such a simple question.

(And yes, in this environment I have NO choice but to use a mvn command to
build the final deployed artifacts due to the build and ci environments in
place here.)

Grails 2.3.7
Assets: 1.7.2
Less-Asset: 1.7.0

Kevin




--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-Maven-Assets-Pipeline-HEADACHE-tp4656057.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Grails + Maven + Assets Pipeline = HEADACHE??

ksnj
Whew... ok found it.  I was pulling in the asset-pipeline transitively through one of my custom plugins.  This appears to be fine for grails run-app but not grails war or mvn package.  

Putting the dependencies (asset-pipeline, less-asset-pipeline, webxml) explicitly in the pom.xml triggered the "Precompiling Assets!" (which I hadn't seen before).

Now I've got an issue where it fails on a bootstrap less file:
|Processing File 95 of 218 - css\bootstrap\less\alerts.less
.Error
|
WAR packaging error: Cannot invoke method replaceAll() on null object


(".Error" is such a helpful message!)

Kevin
Reply | Threaded
Open this post in threaded view
|

Re: Grails + Maven + Assets Pipeline = HEADACHE??

rlovtangen
You should exclude all bootstrap less files except bootstrap.less.
That's because bootstrap.less imports all the other files. The other files are meant for inclusion, not to be compiled on their own.
The easiest would be to exclude all Bootstrap less files:

grails.assets.excludes = [
        "bootstrap/less/*.less"
]

then include bootstrap.less from your main css or less file:

/*
*= require bootstrap/less/bootstrap.less
*= require_self
*/

(note: I have bootstrap less files under assets/stylesheets/bootstrap/less, you might have organised them differently)

Ronny

On 15 Apr 2014, at 22:17, ksnj <[hidden email]> wrote:

> Whew... ok found it.  I was pulling in the asset-pipeline transitively
> through one of my custom plugins.  This appears to be fine for grails
> run-app but not grails war or mvn package.  
>
> Putting the dependencies (asset-pipeline, less-asset-pipeline, webxml)
> explicitly in the pom.xml triggered the "Precompiling Assets!" (which I
> hadn't seen before).
>
> Now I've got an issue where it fails on a bootstrap less file:
> |Processing File 95 of 218 - css\bootstrap\less\alerts.less
> .Error
> |
> WAR packaging error: Cannot invoke method replaceAll() on null object
>
>
> (".Error" is such a helpful message!)
>
> Kevin
>
>
>
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Grails-Maven-Assets-Pipeline-HEADACHE-tp4656057p4656060.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Grails + Maven + Assets Pipeline = HEADACHE??

David Estes
Yup, and not exactly sure what your log4j configuration is set at nor what version of less-asset-pipeline you are using but it does log specifics if the compiler can determine the cause. Can also try less4j compiler mode in the docs.

-- 
David Estes
Sent with Airmail

On April 15, 2014 at 4:37:04 PM, Ronny Løvtangen ([hidden email]) wrote:

You should exclude all bootstrap less files except bootstrap.less.
That's because bootstrap.less imports all the other files. The other files are meant for inclusion, not to be compiled on their own.
The easiest would be to exclude all Bootstrap less files:

grails.assets.excludes = [
"bootstrap/less/*.less"
]

then include bootstrap.less from your main css or less file:

/*
*= require bootstrap/less/bootstrap.less
*= require_self
*/

(note: I have bootstrap less files under assets/stylesheets/bootstrap/less, you might have organised them differently)

Ronny

On 15 Apr 2014, at 22:17, ksnj <[hidden email]> wrote:

> Whew... ok found it. I was pulling in the asset-pipeline transitively
> through one of my custom plugins. This appears to be fine for grails
> run-app but not grails war or mvn package.
>
> Putting the dependencies (asset-pipeline, less-asset-pipeline, webxml)
> explicitly in the pom.xml triggered the "Precompiling Assets!" (which I
> hadn't seen before).
>
> Now I've got an issue where it fails on a bootstrap less file:
> |Processing File 95 of 218 - css\bootstrap\less\alerts.less
> .Error
> |
> WAR packaging error: Cannot invoke method replaceAll() on null object
>
>
> (".Error" is such a helpful message!)
>
> Kevin
>
>
>
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Grails-Maven-Assets-Pipeline-HEADACHE-tp4656057p4656060.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Grails + Maven + Assets Pipeline = HEADACHE??

ksnj
this is using less4j with less-asset-pipeline 1.7.0 at build time (grails war/mvn package produce the same message)-- i'm not sure what logging settings are in use at build time.  

Is there a particular entry i should put in log4j = {...} in Config.groovy that would impact build time messages for the asset-pipeline?

also, it would be nice to validate assets in a plugin.  i tried "grails asset-precompile" from the command line of a plugin (that uses assets) and get this error:

|Environment set to development
......Error
|
Error executing script AssetPrecompile: No such property: specs for class: org.codehaus.gant.GantBinding

(and thank you for you quick responses, much appreciated)
Reply | Threaded
Open this post in threaded view
|

Re: Grails + Maven + Assets Pipeline = HEADACHE??

David Estes
hmm that gant script isn’t exactly designed to run from inside a plugin. Ill check the log4j thing
-- 
David Estes
Sent with Airmail

On April 15, 2014 at 4:50:57 PM, ksnj ([hidden email]) wrote:

this is using less4j with less-asset-pipeline 1.7.0 at build time (grails
war/mvn package produce the same message)-- i'm not sure what logging
settings are in use at build time.

Is there a particular entry i should put in log4j = {...} in Config.groovy
that would impact build time messages for the asset-pipeline?

also, it would be nice to validate assets in a plugin. i tried "grails
asset-precompile" from the command line of a plugin (that uses assets) and
get this error:

|Environment set to development
......Error
|
Error executing script AssetPrecompile: No such property: specs for class:
org.codehaus.gant.GantBinding

(and thank you for you quick responses, much appreciated)



--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-Maven-Assets-Pipeline-HEADACHE-tp4656057p4656065.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Grails + Maven + Assets Pipeline = HEADACHE??

ksnj
In reply to this post by rlovtangen
thanks, that got me past the '.Error' messages.
Reply | Threaded
Open this post in threaded view
|

Re: Grails + Maven + Assets Pipeline = HEADACHE??

ksnj
In reply to this post by David Estes
again, appreciate all of your help... got the assets in the war and running in tomcat looking pretty good.

now i'm just down to js dependency ordering issues ("Uncaught ReferenceError: jQuery is not defined "), oddly did not have any issues with run-app.  (chrome dev tools show it is correctly pulling in application-xxx.js (270+k))

probably need to split up the javascript between the head and body a bit better.  didn't expect run-app vs precomiled to make a difference here though.

Reply | Threaded
Open this post in threaded view
|

Re: Grails + Maven + Assets Pipeline = HEADACHE??

David Estes
Look for a trailing ; that wasn’t added. In dev mode your files are kept separate for debug purposes. You can always pre-test before going into production by setting grails.assets.bundle=true or running grails run-war
-- 
David Estes
Sent with Airmail

On April 15, 2014 at 5:28:16 PM, ksnj ([hidden email]) wrote:

again, appreciate all of your help... got the assets in the war and running
in tomcat looking pretty good.

now i'm just down to js dependency ordering issues ("Uncaught
ReferenceError: jQuery is not defined "), oddly did not have any issues with
run-app. (chrome dev tools show it is correctly pulling in
application-xxx.js (270+k))

probably need to split up the javascript between the head and body a bit
better. didn't expect run-app vs precomiled to make a difference here
though.





--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-Maven-Assets-Pipeline-HEADACHE-tp4656057p4656070.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Grails + Maven + Assets Pipeline = HEADACHE??

ksnj
It seems to be that it is due to the dependency being two layers deep.

App depends on plugin A which depends on plugin JQuery.

app asset refers to //= require plugin_a
plugin a refers to //= require jquery

asset compiling is not pulling in jquery but it works fine with run-app.

I tracked this down by reducing separating out the jquery dependency from the rest of the application.js dependencies and turning setting grails.assets.minifyJs=false.

so now app asset ("head.js") refers directly to //= require jquery
jquery is still a dependency of plugin a

this also works with run-app (even with grails.assets.bundle=true) but in the deployed war the contents of "head-xxx.js" is literally still just the text "//= require jquery"

(What we're trying to setup is a UI plugin with all the common look and feel (theme) assets to be reusable across multiple grails apps in an enterprise shop.)

Kevin

Reply | Threaded
Open this post in threaded view
|

Re: Grails + Maven + Assets Pipeline = HEADACHE??

ksnj
In reply to this post by David Estes
adding the jquery plugin dependency up in the application's pom.xml did resolve this last issue.

the only mystery then is why it works differently between run-app and build time asset compilation.
Reply | Threaded
Open this post in threaded view
|

Re: Grails + Maven + Assets Pipeline = HEADACHE??

David Estes
This sounds like when running grails run-app its resolving your missing dependencies via BuildConfig but when you run WAR the full app stack is not loaded so if your using mvn as your dependency resolution for war creation, It’s switching gears.

-- 
David Estes
Sent with Airmail

On April 15, 2014 at 7:04:31 PM, ksnj ([hidden email]) wrote:

adding the jquery plugin dependency up in the application's pom.xml did
resolve this last issue.

the only mystery then is why it works differently between run-app and build
time asset compilation.



--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-Maven-Assets-Pipeline-HEADACHE-tp4656057p4656073.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Grails + Maven + Assets Pipeline = HEADACHE??

ksnj
This post was updated on .
makes sense, but are you saying grails is acting different or that I have something in my BuildConfig?

here's my dependency section of my BuildConfig:

grails.project.dependency.resolver = 'maven'
grails.project.dependency.resolution = {
        pom true
    inherits("global") {
    }
    log "warn"
    repositories {
        mavenLocal()
    }
    dependencies {
    }
    plugins {
    }
}


I've got everything working under the caveat that the assets plugin will not precompile/package assets that are nested more than one level deep in the dependency hierarchy when using maven, even though they will show up in developer mode with a grails run-app or when using the grails war command.  

I've got it down to a simple set of reproducible steps: adding/removing the pom dependency then using grails war and mvn package to then verify when "assets/jquery" shows up in the war file.  It can also be seen during the precompile of the build process by looking at the "File X of Y" messages.

Thanks for your help.