changcheng / wro4j

Automatically exported from code.google.com/p/wro4j
0 stars 0 forks source link

Maven plugin generated resource location enhancement #518

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The purpose of this task is to automatically change the location of generated 
resources (when using wro4j-maven-plugin) when the name of the resources 
contains '/'. 

Use-case description:

In our current asset pipeline system, we can output a given group to a relative 
path of the default output directory. I was hoping I could use a custom naming 
strategy to provide this but it does not look like it would work out of the box.
I wonder if it would be possible to enhance slightly wro4j so that if the 
custom naming stragegy is return a path as the new name, it would recognize it.

for example, for a js file with a default jsOutputDir to d:\static\js and a 
default outdir to d:\static

name = "foo/bar" would produce d:\static\js\foo\bar.js
name = "/foo/bar" would produce d:\static\foo\bar.js

The use case for the above is that in our application, we provide a web bar 
that people can embed on their own website (like meebo bar for example) and the 
path to it as a business meaning as we have the language in it among a channel 
name (/en/bar.js vs /fr/bar.js)

Discussion extracted from mailing list: 
https://groups.google.com/forum/#!topic/wro4j/uUsdoBX5iFI

Original issue reported on code.google.com by alex.obj...@gmail.com on 12 Aug 2012 at 11:57

GoogleCodeExporter commented 9 years ago
I would prefer something that is declarative in the model so it's transparent 
to the method used (runtime vs build time) and I feel it belongs there anyhow. 
How about a package element ?
It would have 1 mandatory attribute (name) and one optional 
attribute(namespace). By default the namespace equals to the name

Example:

<groups>
  <group name="group1"/>
  ...
  <package name="foo">
     <group name="bar"/>
  </package>

  <package name="tools-en" namespace="tools/en">
    <group name="tooltip" />
  </package>  
</groups>

Runtime:

<script type="text/javascript" src="/wro/group1.js"></script>
<script type="text/javascript" src="/wro/foo/bar.js"></script>
<script type="text/javascript" src="/wro/tools/en/tooltip.js"></script>

Build Time:

d:\static\js\group1.js
d:\static\js\foo\bar.js
d:\static\js\tools\en\tooltip.js

What do you think ? The package notion would be totally optional and for most 
not needed but if some people need to package some js/css at a specific 
location, it would allow them to do so. From an aesthetic and organisation 
point of view, it could also be beneficial to the runtime in order to group 
resources that belong together in a logical namespace.

A group is already a package is someway so maybe we need another name than 
"package" to avoid any confusion.

Original comment by tlv...@gmail.com on 14 Aug 2012 at 1:27

GoogleCodeExporter commented 9 years ago
I'm not sure that adding the package concept into the model worth it. It adds 
extra complexity without solving any real issues. I would prefer keep things 
simple and choose the approach which require as little changes as possible in 
order to solve a problem. 

Since your use-case is to change the folder of the group (mostly for maven 
plugin), it can be achieved by other means. I'll let you know when I have more 
details.

Original comment by alex.obj...@gmail.com on 14 Aug 2012 at 10:06

GoogleCodeExporter commented 9 years ago
Thanks for the feedback on this Alex

Original comment by tlv...@gmail.com on 15 Aug 2012 at 7:08

GoogleCodeExporter commented 9 years ago
I have some progress on this issue. The fix will make it possible to generate 
resources located in a folder and this will be controlled by NamingStrategy. 

So, for instance, if the naming strategy says that a group named g1.js is 
renamed into parent/g1.js, then the maven plugin will create the required 
folder. 

Original comment by alex.obj...@gmail.com on 15 Aug 2012 at 1:00

GoogleCodeExporter commented 9 years ago
Fixed in branch 1.4.x

Original comment by alex.obj...@gmail.com on 15 Aug 2012 at 1:09

GoogleCodeExporter commented 9 years ago
Sorry Alex, been busy and just notice this, great, thank !

Original comment by tlv...@gmail.com on 20 Sep 2012 at 5:22