webjar and maven static build

230 views
Skip to first unread message

ph...@riand.com

unread,
May 16, 2015, 6:24:12 PM5/16/15
to wr...@googlegroups.com
Hello Alex,

I'm wondering if the maven plug-in can be used to optimize resources coming from a webjar. To minimize the size of the application, which is important for mobile, I don't want the full webjar to be added as a dependency. I just want its content be consumed by wro4j to generate the needed js/css

I tried with your example:
<js>webjar:jquery.js</js>

With the following dependency:
<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>jquery</artifactId>
    <version>2.1.4</version>
</dependency>

I cannot get that to work. Is it something that is valid?

That leads to other problems as well, as some resources (fonts, images...) have to be copied as well, but I think there are ways to do that.

alex.o...@gmail.com

unread,
May 16, 2015, 6:28:34 PM5/16/15
to wr...@googlegroups.com, wr...@googlegroups.com
The webjars is supported, howether there are some known issues with cssUrlRewriting processor which doesn't work well when rewriting resources referenced in webjars.

What exactly is the problem that you have?


Sent from Mailbox


--
You received this message because you are subscribed to the Google Groups "wro4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wro4j+un...@googlegroups.com.
To post to this group, send email to wr...@googlegroups.com.
Visit this group at http://groups.google.com/group/wro4j.
For more options, visit https://groups.google.com/d/optout.

ph...@riand.com

unread,
May 17, 2015, 9:41:26 AM5/17/15
to wr...@googlegroups.com
It actually does not find the file from webjar. Here is my wro.xml:
  <group name="explorer.min">
        <js minimize="true">/explorer/js/app.js</js>
        <js>webjar:jquery.js</js>
  </group>
and my dependencies in pom.xml:
<dependency>
   <groupId>org.webjars</groupId>
   <artifactId>jquery</artifactId>
   <version>2.1.4</version>
</dependency>

When building using maven, I'm getting the following error (after setting ignoreMissingResources to false):
[ERROR] Cannot ignore missing resource:  ro.isdc.wro.model.resource.Resource@12f3cc5[JS,webjar:jquery.js,true]
[ERROR] Exception while merging resources: No webjar with uri: webjar:jquery.js available.
[ERROR] Exception occured while processing: ro.isdc.wro.WroRuntimeException: Exception while merging resources: No webjar with uri: webjar:jquery.js available., class: ro.isdc.wro.WroRuntimeException,caused by: java.io.IOException
ro.isdc.wro.WroRuntimeException: Exception while merging resources: No webjar with uri: webjar:jquery.js available.
at ro.isdc.wro.model.group.processor.GroupsProcessor.process(GroupsProcessor.java:86)
Caused by: java.io.IOException: No webjar with uri: webjar:jquery.js available.
at ro.isdc.wro.extensions.locator.WebjarUriLocator.locate(WebjarUriLocator.java:72)
Caused by: org.webjars.MultipleMatchesException: Multiple matches found for jquery.js. Please provide a more specific path, for example by including a version number.
at org.webjars.WebJarAssetLocator.getFullPath(WebJarAssetLocator.java:222)

I tried many path to jquery.js but none worked for me. I also tried both the bower and classic webjar.

Phil.

alex.o...@gmail.com

unread,
May 17, 2015, 11:14:33 AM5/17/15
to wr...@googlegroups.com, wr...@googlegroups.com
Could you open an issue. I will try to reproduce and will keep you updated with my findings. In the meantime, try using classpath uri to locate webjar resiurces.

Thanks,
Alex


Sent from Mailbox

Alex Objelean

unread,
May 18, 2015, 3:54:10 AM5/18/15
to wr...@googlegroups.com, ph...@riand.com, ph...@riand.com
I've noticed that the actual cause of the problem is the following:

"Caused by: org.webjars.MultipleMatchesException: Multiple matches found for jquery.js"

I'm not yet sure where the second jquery.js resource is coming from, but you could fix this adding the version to the webjar uri:

webjar:2.1.4/jquery.js

I will continue to investigate the problem. It could be either a bug in webjar locator or there are actually two resources in the classpath with the same name.

Cheers,
Alex
Reply all
Reply to author
Forward
0 new messages