java - Using property file in maven -


i don't quite understand how can used. there property defined in file. try use maven property plugin read , save. property used in liquibase plugin:

<plugin> <groupid>org.codehaus.mojo</groupid>   <artifactid>properties-maven-plugin</artifactid>   <version>1.0-alpha-1</version>   <executions>     <execution>       <phase>initialize</phase>       <goals>         <goal>read-project-properties</goal>       </goals>       <configuration>        <files>           <file>src/main/resources/properties/app.properties</file>         </files>       </configuration>     </execution>   </executions> </plugin> <plugin>     <groupid>org.liquibase</groupid>     <artifactid>liquibase-maven-plugin</artifactid>     <version>2.0.5</version>     <configuration>         <propertyfile>src/main/resources/db/config/${env}-data-access.properties</propertyfile>         <changelogfile>src/main/resources/db/changelog/db.changelog-master.xml</changelogfile>         <migrationsqloutputfile>src/main/resources/db/gen/migrate.sql</migrationsqloutputfile>         <!--<logging>debug</logging>-->         <logging>info</logging>         <promptonnonlocaldatabase>false</promptonnonlocaldatabase>         <!--<verbose>false</verbose>-->         <dropfirst>true</dropfirst>     </configuration> </plugin> 
  1. according documentation in order read property , save have run: mvn properties:read-project-properties. i'm getting following error in case:

    [error] failed execute goal org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:read-project-properties (default-cli) on project springwebflow: parameters 'files' goal org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:read-project-properties missing or invalid -> [help 1]

i've changed pom.xml, removed <execution> section , moved <configuration> section:

<groupid>org.codehaus.mojo</groupid>   <artifactid>properties-maven-plugin</artifactid>   <version>1.0-alpha-1</version>   <configuration>     <files>         <file>src/main/resources/properties/app.properties</file>     </files>   </configuration> 

ok. now, when run mvn properties:read-project-properties error disappeared. in case property saved? cause when start following maven goal:

mvn liquibase:update 

i can see ${env} property not defined. liquibase tries use src/main/resources/db/config/${env}-data-access.properties file.

what doing wrong? how read property file, accessible different maven plugins?

the problem "mvn liquibase:update" special plugin goal , not part of maven life cycle. never passes initialize phase , property plugin not executed.

the following work

mvn initialize liquibase:update 

one solution call liquibase:update in 1 of maven lifecylce phases compile, package ..., executed on every build.

or use maven-exec plugin call "initialize liquibase:update" maven. or create profile bind liquibase:update lifecylce phase initialize , udate executed when call

mvn initialize -pliquibase 

i not know better solution problem , not find suitable solution this.

for reference: maven lifecycle


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -