Reputation: 2983
i have a maven multi-modular project (model,service,util,webapp). I have a few profiles defined in the pom.xml of the webapp project.
<profile>
<id>Dev</id>
<properties>
<db.driverClass>..</db.driverClass>
<db.connectionURL>..</db.connectionURL>
<db.username>..</db.username>
<db.password>..</db.password>
<pathFile>myFolder/myFirstPath/</pathFile>
</properties>
</profile>
<profile>
<id>Prod</id>
<properties>
<db.driverClass>..</db.driverClass>
<db.connectionURL>..</db.connectionURL>
<db.username>..</db.username>
<db.password>..</db.password>
<pathFile>myFolder/mySecondPath/</pathFile>
</properties>
</profile>
I'm trying to change dynamically the property path that is located in my util project. This is the skeleton of my modular project
|-- parent
`-- pom.xml
|-- model
| `-- pom.xml
|-- util
|--src
|--main
|--resources
|--props
props.properties
| `-- pom.xml
|-- webapp
` -- pom.xml
In the pom.xml of the util project i enabled the resource filtering
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
And finally i wrote
pathToChange=${pathFile}
in the props.properties file. But when i run
mvn jetty:run -P Dev
the value of pathToChange property doesn't change. Where am i doing wrong?
Upvotes: 2
Views: 64
Reputation: 32617
You've defined the profiles in the wrong project. You have them in webapp
, instead of util
. These project properties only relate to the project they're defined in, unless this is a parent pom. Properties defined in one pom cannot (otherwise) be used in another pom.
Upvotes: 2