Resource Classpath Order Is Not Respected

I am having a problem where I am extending a third party application that uses spring.
I have marked the spring files from the third party application as resources and have my own spring files marked as resources but higher up the classpath.
Due to the way the third party app is inflexible with its use of spring I have to have an xml file with the same name as the original.
This should be fine since mine is higher up the classpath, however, I often see the original file in my out directory.

How does IDEAs Make Project work with respect to resources?
Does it copy each resource directory, wait for it to finish then copy the next or does it copy them all at the same time in multiple threads?

The latter would explain how sometimes I have the wrong file in my classpath when debugging.

2 comments

> Does it copy each resource directory, wait for it to finish then copy the next or does it copy them all at the same time in multiple threads?

This depends on whether the "build in parallel" option is turned on. While modules are built in the order that is implied by dependencies between them, there is no such "natural ordireng" criterion for resources. Because of this, no matter whether the "parallel" build is on, the order in which resources are processed is not defined. The only thing that is guaranteed, is that when compilation of module's sources starts, the resources for this module are already copied to the output directory.


In your project it looks like the original resource file should not be processed at all, so excluding it from compilation should help.

0

That works as workaround.
However, I would expect that the order that I list the resources to work like listing them in that order in a batch file.
i.e. the classpath order would be respected.

One other thing is that if you are using eclipse storage format only the .ide/compiler.xml file is updated when you exclude the resources from compile.
The .classpath file should also be updated with something like

     <classpathentry excluding="duplicated.xml" kind="src" path="third-party/resources/"/>

0

Please sign in to leave a comment.