0

When using Maven Resources Plugin to filter resources is there a way to refer to currently processed resource file path?

For example if I have a YAML resource src/main/resources/config.yml with content:

app:
  location: ${filePath}

I'd like the ${filePath} token to be replaced with either relative or absolute resource file path resulting in:

app:
  location: src/main/resources/config.yml

Is there a Maven provided property that can be used to get the processed resource file path? I can't hardcode one path in Maven properties because there will be different resource that should be filtered with their own path.

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
  • You want to specify the path of config.yaml file in pom.xml ? – DAIRAV Apr 05 '18 at 10:02
  • @user2249207 No, because there could be multiple different `*.yml` files and each should use it's own path. Hardcoding one path is not an option. – Karol Dowbecki Apr 05 '18 at 10:03
  • 1
    For what purpose do you need those things? Is this a spring app ? Can you give more details ? Furthermore after filtering the path should never `src/main/...` cause those files are copied by default to `target/classes` ....and can be accessed by `getResourcesAs...()`... – khmarbaise Apr 05 '18 at 12:26
  • @khmarbaise It's not Spring specific question. I want to process the resources using Maven so they will have their relative path somewhere in them because a 3rd party library needs it. I'm happy to write custom code if I have to but it has to be done during build and not application startup with Spring. – Karol Dowbecki Apr 05 '18 at 13:07
  • To be honest seeing references to `src/main..` in a property file is from my point of view simply wrong...Apart from that if 3rd party libs needs it should be fixed to follow defaults/conventions (loading from classpath as usual)...unfortunately I'm currently not aware of a simple Maven based solution...maybe you can create a example project where i can take a look? – khmarbaise Apr 05 '18 at 18:39

0 Answers0