grails-lesscss-resources icon indicating copy to clipboard operation
grails-lesscss-resources copied to clipboard

lesscss-resources + gsp-resources?

Open timbonicus opened this issue 13 years ago • 0 comments

I've been using lesscss-resources with great success to compile LESS files to CSS. I'm attempting to introduce the gsp-resources plugin in combination to render a GSP file to LESS and then to CSS. The chain seems to fall down and I'm curious if this has been attempted before.

The first problem I ran into was that both lesscss-resources and gsp-resources define the mapper in MapperPhase.GENERATION and lesscss seemed to be running before gsp-resources. I haven't found an option to control the order of execution for resource mappers within a certain phase. I modified lesscss as an experiment to use MapperPhase.MUTATION.

After this change, I can see with resources debugging that gsp-resources gets applied before lesscss, but lesscss claims that the generated .less file can't be found:

[2012-10-03 09:53:40.417] DEBUG: plugin.resource.ResourceProcessor Preparing resource /less/epcm.less.gsp (<org.grails.plugin.resource.ResourceMeta@3cc8996d log=org.slf4j.impl.GrailsLog4jLoggerAdapter(org.grails.plugin.resource.ResourceMeta) id=/less/epcm.less.gsp module=org.grails.plugin.resource.ResourceModule@7e438935 workDir=C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources originalUrl=/less/epcm.less.gsp sourceUrl=/less/epcm.less.gsp sourceUrlExtension=gsp sourceUrlParamsAndFragment=null actualUrl=null linkOverride=null bundle=null contentType=null disposition=head excludedMappers=null attributes=[:] tagAttributes=[rel:stylesheet/less, type:css] prePostWrapper=null delegate=null originalResource=null originalSize=null processedSize=null processedFile=null originalLastMod=0 requestProcessors=[] _linkUrl=null processed=false _resourceExists=false declaringResource=null contentLength=0 originalContentLength=0>)
[2012-10-03 09:53:40.420] DEBUG: plugin.resource.ResourceMeta Resource [/less/epcm.less.gsp] (file:C:/applications/epcm/web-app/less/epcm.less.gsp) has content type [null]
[2012-10-03 09:53:40.427] DEBUG: plugin.resource.ResourceProcessor Creating file object for URI [/less/epcm.less.gsp] from [C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources\less] and [epcm.less.gsp]
[2012-10-03 09:53:40.428] DEBUG: plugin.resource.ResourceProcessor Applying mappers to C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources\less\epcm.less.gsp
[2012-10-03 09:53:40.429] DEBUG: plugin.resource.ResourceProcessor Applying mapper gsp to C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources\less\epcm.less.gsp - delegating? false
[2012-10-03 09:53:40.430] DEBUG: resource.mapper.gsp Beginning mapping <org.grails.plugin.resource.ResourceMeta@3cc8996d log=org.slf4j.impl.GrailsLog4jLoggerAdapter(org.grails.plugin.resource.ResourceMeta) id=/less/epcm.less.gsp module=org.grails.plugin.resource.ResourceModule@7e438935 workDir=C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources originalUrl=/less/epcm.less.gsp sourceUrl=/less/epcm.less.gsp sourceUrlExtension=gsp sourceUrlParamsAndFragment=null actualUrl=/less/epcm.less.gsp linkOverride=null bundle=null contentType=null disposition=head excludedMappers=null attributes=[:] tagAttributes=[rel:stylesheet/less, type:css] prePostWrapper=null delegate=null originalResource=URL [file:C:/applications/epcm/web-app/less/epcm.less.gsp] originalSize=0 processedSize=null processedFile=C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources\less\epcm.less.gsp originalLastMod=1349277871844 requestProcessors=[] _linkUrl=/less/epcm.less.gsp processed=false _resourceExists=true declaringResource=null contentLength=0 originalContentLength=364>
[2012-10-03 09:53:40.536] DEBUG: plugin.resource.ResourceProcessor Creating synthetic resource of type class org.grails.plugin.gspresources.GspResourceMeta for URI [/less/epcm.less]
[2012-10-03 09:53:40.550] DEBUG: plugin.resource.ResourceProcessor synthetic module resources: [ResourceMeta for URI /less/epcm.less served by /less/epcm.less (delegate: none)]
[2012-10-03 09:53:40.553] DEBUG: resource.mapper.gsp Done mapping <org.grails.plugin.resource.ResourceMeta@3cc8996d log=org.slf4j.impl.GrailsLog4jLoggerAdapter(org.grails.plugin.resource.ResourceMeta) id=/less/epcm.less.gsp module=org.grails.plugin.resource.ResourceModule@7e438935 workDir=C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources originalUrl=/less/epcm.less.gsp sourceUrl=/less/epcm.less.gsp sourceUrlExtension=gsp sourceUrlParamsAndFragment=null actualUrl=/less/epcm.less linkOverride=null bundle=null contentType=null disposition=head excludedMappers=null attributes=[gsp.rendered:/less/epcm.less] tagAttributes=[rel:stylesheet/less, type:css] prePostWrapper=null delegate=ResourceMeta for URI /less/epcm.less served by /less/epcm.less (delegate: none) originalResource=URL [file:C:/applications/epcm/web-app/less/epcm.less.gsp] originalSize=0 processedSize=null processedFile=C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources\less\epcm.less.gsp originalLastMod=1349277871844 requestProcessors=[] _linkUrl=/less/epcm.less processed=true _resourceExists=true declaringResource=null contentLength=0 originalContentLength=364>
[2012-10-03 09:53:40.558] DEBUG: plugin.resource.ResourceProcessor Applied mapper gsp to C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources\less\epcm.less.gsp
[2012-10-03 09:53:40.558] DEBUG: resource.util.ResourceMetaStore Adding declared resource ResourceMeta for URI /less/epcm.less.gsp served by /less/epcm.less (delegate: ResourceMeta for URI /less/epcm.less served by /less/epcm.less (delegate: none))
[2012-10-03 09:53:40.558] DEBUG: resource.util.ResourceMetaStore Storing mapping for resource URI /less/epcm.less.gsp to ResourceMeta for URI /less/epcm.less served by /less/epcm.less (delegate: none)
[2012-10-03 09:53:43.596] DEBUG: plugin.resource.ResourceProcessor Preparing synthetic resource: /less/epcm.less
[2012-10-03 09:53:43.609] DEBUG: plugin.resource.ResourceProcessor Preparing resource /less/epcm.less (<org.grails.plugin.gspresources.GspResourceMeta@2d41737a log=org.apache.commons.logging.impl.SLF4JLog@240465cc gsp=URL [file:C:/applications/epcm/web-app/less/epcm.less.gsp] renderedFile=null renderedContentLength=null renderedContentType=null renderedLastModified=null log=org.slf4j.impl.GrailsLog4jLoggerAdapter(org.grails.plugin.resource.ResourceMeta) id=/less/epcm.less module=org.grails.plugin.resource.ResourceModule@490586be workDir=C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources originalUrl=/less/epcm.less sourceUrl=/less/epcm.less sourceUrlExtension=less sourceUrlParamsAndFragment=null actualUrl=null linkOverride=null bundle=null contentType=null disposition=head excludedMappers=null attributes=[gsp.rendered:/less/epcm.less] tagAttributes=[rel:stylesheet/less, type:css] prePostWrapper=null delegate=null originalResource=null originalSize=null processedSize=null processedFile=null originalLastMod=0 requestProcessors=[] _linkUrl=null processed=false _resourceExists=false declaringResource=null contentLength=0 originalContentLength=0>)
[2012-10-03 09:53:43.633] DEBUG: plugin.resource.ResourceProcessor Creating file object for URI [/less/epcm.less] from [C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources\less] and [epcm.less]
[2012-10-03 09:53:46.285] DEBUG: plugin.resource.ResourceProcessor Applying mappers to C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources\less\epcm.less
[2012-10-03 09:53:46.285] DEBUG: plugin.resource.ResourceProcessor Applying mapper gsp to C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources\less\epcm.less - delegating? false
[2012-10-03 09:53:46.287] DEBUG: resource.mapper.gsp Skipping /less/epcm.less due to includes pattern [**/*.gsp] not including it
[2012-10-03 09:53:46.287] DEBUG: plugin.resource.ResourceProcessor Applied mapper gsp to C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources\less\epcm.less
[2012-10-03 09:53:46.288] DEBUG: plugin.resource.ResourceProcessor Applying mapper lesscss to C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources\less\epcm.less - delegating? false
[2012-10-03 09:53:46.288] DEBUG: resource.mapper.lesscss Beginning mapping <org.grails.plugin.gspresources.GspResourceMeta@2d41737a log=org.apache.commons.logging.impl.SLF4JLog@240465cc gsp=URL [file:C:/applications/epcm/web-app/less/epcm.less.gsp] renderedFile=C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources\less\epcm.less renderedContentLength=346 renderedContentType=null renderedLastModified=1349279626282 log=org.slf4j.impl.GrailsLog4jLoggerAdapter(org.grails.plugin.resource.ResourceMeta) id=/less/epcm.less module=org.grails.plugin.resource.ResourceModule@490586be workDir=C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources originalUrl=/less/epcm.less sourceUrl=/less/epcm.less sourceUrlExtension=less sourceUrlParamsAndFragment=null actualUrl=/less/epcm.less linkOverride=null bundle=null contentType=null disposition=head excludedMappers=null attributes=[gsp.rendered:/less/epcm.less, processed.by.gsp:false] tagAttributes=[rel:stylesheet/less, type:css] prePostWrapper=null delegate=null originalResource=file [C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources\less\epcm.less] originalSize=0 processedSize=null processedFile=C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources\less\epcm.less originalLastMod=1349279626282 requestProcessors=[] _linkUrl=/less/epcm.less processed=false _resourceExists=true declaringResource=null contentLength=346 originalContentLength=346>
[2012-10-03 09:53:46.331] WARN : plugin.gspresources.GspResourceProcessor ServletContext resource [/less/epcm.less] cannot be resolved to URL because it does not exist
[2012-10-03 09:54:17.838] DEBUG: resource.util.ResourceMetaStore getOrCreateAdHocResource for /less/epcm.less
[2012-10-03 09:54:17.838] DEBUG: resource.util.ResourceMetaStore getOrCreateAdHocResource for /less/epcm.less, latch is null
[2012-10-03 09:54:17.838] DEBUG: resource.util.ResourceMetaStore getOrCreateAdHocResource for /less/epcm.less, creating resource as not found
[2012-10-03 09:54:17.838] DEBUG: plugin.resource.ResourceProcessor Legacy resource /less/epcm.less matched includes? true
[2012-10-03 09:54:17.839] DEBUG: plugin.resource.ResourceProcessor Legacy resource /less/epcm.less passed excludes? true
[2012-10-03 09:54:17.839] DEBUG: plugin.resource.ResourceProcessor Preparing resource /less/epcm.less (<org.grails.plugin.resource.ResourceMeta@16a1ac log=org.slf4j.impl.GrailsLog4jLoggerAdapter(org.grails.plugin.resource.ResourceMeta) id=null module=org.grails.plugin.resource.ResourceModule@3f4789bd workDir=C:\Users\thansen\.grails\2.0.1\projects\epcm\tomcat\work\Tomcat\localhost\epcm\grails-resources originalUrl=/less/epcm.less sourceUrl=/less/epcm.less sourceUrlExtension=less sourceUrlParamsAndFragment=null actualUrl=null linkOverride=null bundle=null contentType=null disposition=null excludedMappers=null attributes=[:] tagAttributes=[:] prePostWrapper=null delegate=null originalResource=null originalSize=null processedSize=null processedFile=null originalLastMod=0 requestProcessors=[] _linkUrl=null processed=false _resourceExists=null declaringResource=null contentLength=null originalContentLength=0>)
[2012-10-03 09:54:17.845] ERROR: plugin.resource.ResourceMeta Resource not found: /less/epcm.less
[2012-10-03 09:54:17.846] WARN : resource.util.ResourceMetaStore Cannot locate resource [/less/epcm.less]

I can see on the filesystem that epcm.less does exist, so I'm mildly confused.

The other issue relates to the reason I'm trying to use gsp-resources in the first place; I'm trying to make a LESS file that imports other LESS files from a Grails plugin. I brilliantly thought that putting a GSP resource tag in the LESS file to reference the plugin LESS files would work. The resources plugin is a bit too smart for me though, and the ${resource} tags in the GSP are themselves run through the resources pipeline and rendered to CSS by lesscss, which negates the whole purpose.

Is there any precedent for making these plugins work together, or am I doing something totally boneheaded and there's an easier way to reference plugin-supplied LESS files within my own LESS files?

timbonicus avatar Oct 03 '12 16:10 timbonicus