plugins - Is there a way to capture user input in maven and assign it to a maven property? -


  1. is there way pause maven execution flow provide command prompt user can input text.
  2. then provided text stored in maven properties.
  3. if user input masked bonus.

this useful avoid storing passwords in pom.

many

you can catch user input using maven-antrun-plugin. following example show how ask current user new project version.

    <profile>         <id>change-version</id>         <build>             <defaultgoal>validate</defaultgoal>             <plugins>                 <plugin>                     <groupid>org.apache.maven.plugins</groupid>                     <artifactid>maven-antrun-plugin</artifactid>                     <version>1.7</version>                     <executions>                         <execution>                             <id>catch-new-version</id>                             <goals>                                 <goal>run</goal>                             </goals>                             <phase>validate</phase>                             <configuration>                                 <target>                                     <!-- == catch new version in prompt == -->                                     <input                                         message="please enter new snapshot version (current '${project.version}'): "                                         addproperty="new-user-version" />                                 </target>                                 <exportantproperties>true</exportantproperties>                             </configuration>                         </execution>                     </executions>                     <dependencies>                         <dependency>                             <groupid>org.apache.ant</groupid>                             <artifactid>ant</artifactid>                             <version>1.8.4</version>                         </dependency>                     </dependencies>                 </plugin>                 <plugin>                     <groupid>org.codehaus.mojo</groupid>                     <artifactid>versions-maven-plugin</artifactid>                     <version>1.3.1</version>                     <executions>                         <execution>                             <id>set-new-version</id>                             <goals>                                 <goal>set</goal>                             </goals>                             <phase>validate</phase>                             <configuration>                                 <generatebackuppoms>false</generatebackuppoms>                                 <newversion>${new-user-version}</newversion>                             </configuration>                         </execution>                     </executions>                 </plugin>             </plugins>         </build>     </profile> </profiles> 

you can run feature calling :

mvn -n -p change-version 

some explanations :


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -