XZen
XZen

Reputation: 445

Maven, using property from property file to read another property file

I want to read property from property file and then use this value to get path to another property file to read it.

I use properties-maven-plugin, but it seems it cannot do this thing or I'm using it improperly.

I want something like that:

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>properties-maven-plugin</artifactId>
                    <version>1.0-alpha-2</version>
                    <executions>
                        <execution>
                            <phase>initialize</phase>
                            <goals>
                                <goal>read-project-properties</goal>
                            </goals>
                            <configuration>
                                <files>
                                    <file>${*value from another property file*}/prop.properties</file>
                                </files>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

Upvotes: 0

Views: 411

Answers (1)

wemu
wemu

Reputation: 8160

Maven by itself does not allow to use properties from external files within the pom.xml - that is why you already use the properties-maven-plugin. You put yourself in a Chicken-Egg situation where the plugin needs to run prior to itself.

What may works is that you put both properties files in the files list - with a bit of luck those are resolved.

The next attempt I would make would be to add the plugin twice (or with two executions) to load the first properties files and then let it work on the second one.

Upvotes: 1

Related Questions