google-code-export / wro4j

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

Using a wildcard in a classpath does not match resources #627

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Specify a path with wildcard in a groovy file e.g. 
classpath:sass/scss/ArticleBundle/*.scss
2. Run a build time compilation with maven
3. See errors:
0    WARN DefaultWildcardStreamLocator - No resource found for wildcard: **
2    WARN DefaultWildcardStreamLocator - No resource found for wildcard: *.scss

Specifying the path to an individual file without a wildcard will produce the 
desired output i.e. compiled CSS

What is the expected output? What do you see instead?
Expect to see SASS processed CSS, see nothing instead.

What version of the product are you using? On what operating system?
Using 1.6.1, on OSX Mountain Lion, Maven 3, JDK 1.6._37

Please provide any additional information below.

Original issue reported on code.google.com by richard....@ft.com on 6 Dec 2012 at 9:33

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 21 Mar 2013 at 9:41

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 28 May 2013 at 8:10

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 8 Jun 2013 at 9:50

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 13 Sep 2013 at 3:55

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 5 Nov 2013 at 1:54

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 8 Jan 2014 at 3:13

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 21 Mar 2014 at 9:20

GoogleCodeExporter commented 9 years ago
Actually this works, but the problem is probably related to what maven 
considers part of the classpath. For instance, if the resources are located in 
a jar which is added as a dependency to your project, the resources are 
successfully located. 

I've noticed that when adding resources to a folder like src/main/resources is 
not picked up. But at least, you have a workaround: build your resources in a 
separate module and add those as a dependency. 

Please provide more details about the location of your resources when the 
problem can be reproduce.

Original comment by alex.obj...@gmail.com on 8 Apr 2014 at 8:04

GoogleCodeExporter commented 9 years ago
Issue 680 has been merged into this issue.

Original comment by alex.obj...@gmail.com on 8 Apr 2014 at 8:05

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 8 Apr 2014 at 9:55

GoogleCodeExporter commented 9 years ago
I also have this problem. I even moved resources to standalone maven module and 
added it as a dependency, but it doesn't prevent the problem. Non-wildcard 
resources are found, but wildcard resources are not.

Original comment by pavel.ar...@loutka.cz on 10 Jun 2014 at 1:08

GoogleCodeExporter commented 9 years ago
Could you enable DEBUG log level and attach the logs?

Original comment by alex.obj...@gmail.com on 10 Jun 2014 at 1:14

GoogleCodeExporter commented 9 years ago
Log is included. Resources are located in "webassets" jar - shouldn't 
JarWildcardStreamLocator inspect it? It looks like that it inspects only 
"wro4j-core" jar.

Original comment by pavel.ar...@loutka.cz on 10 Jun 2014 at 1:56

Attachments:

GoogleCodeExporter commented 9 years ago
Alex, will you have time for this? Can I help you somehow?

Original comment by pavel.ar...@loutka.cz on 13 Jun 2014 at 12:13

GoogleCodeExporter commented 9 years ago
I'm quite busy right now. Trying to release a new version containing some of 
the issues I've been working on recently. 
If you could contribute, it would be very useful. Any kind of contribution is 
appreciated: debugging, investigation, development...

Original comment by alex.obj...@gmail.com on 13 Jun 2014 at 12:20

GoogleCodeExporter commented 9 years ago
Build output and dependencies are not path of plugin's classpath:

"Please note that the plugin classloader does neither contain the dependencies 
of the current project nor its build output. Instead, plugins can query the 
project's compile, runtime and test class path from the MavenProject in 
combination with the mojo annotation requiresDependencyResolution from the Mojo 
API Specification. For instance, flagging a mojo with 
@requiresDependencyResolution runtime enables it to query the runtime class 
path of the current project from which it could create further classloaders." 
(http://maven.apache.org/guides/mini/guide-maven-classloading.html)

At stackoverflow 
(http://stackoverflow.com/questions/2659048/add-maven-build-classpath-to-plugin-
execution-classpath) I found two solutions:

1) http://stackoverflow.com/a/16263482 - delegate URLClassLoader with URLs 
acquired from MavenProject#getRuntimeClasspathElements method - suggested 
solution there uses thread's context classloader, maybe this can influence 
other plugins as well?; cleaner solution would be probably to simply pass 
delegate classloader to ClasspathUriLocator, somehow

2) http://stackoverflow.com/a/2659324 - custom maven ComponentConfigurator 
which adds runtimeClasspathElements to classpath; it's quite a magic but it 
works; I don't know if it can influence other maven plugins, probably not

In both cases, I must replace:

final String fullPath = "/" + FilenameUtils.getFullPathNoEndSeparator(location);

with:

final String fullPath = FilenameUtils.getFullPath(location);

because in URLClassLoader directories must end with /; why the slash mustn't be 
at the beginning, I don't know, but it doesn't work with it

Original comment by pavel.ar...@loutka.cz on 13 Jun 2014 at 6:36

GoogleCodeExporter commented 9 years ago
Thanks for such detailed description. It will definitely help.

Original comment by alex.obj...@gmail.com on 13 Jun 2014 at 7:08