Search code examples
javaspringspring-bootmaven-plugin

Execute mvn archetype:generate with User Input from Java Code


I am creating a project from a custom archetype in Spring Boot Here are the steps

  1. Created a Template Project

  2. Executed mvn archetype:create-from-project -Darchetype.properties=../myCustom.properties command from Java Code and created a custom archetype from template

  3. Installed custom archetype into Local maven Repo. cd target\generated-sources\archetype mvn clean install

  4. Create project from Custom Archetype (This is the problem area) mvn archetype:generate -DarchetypeGroupId=com.mycompany -DarchetypeArtifactId=myApp-template-archetype -DarchetypeVersion=1.0.0-SNAPSHOT -Ddomain="archetypeDomain"

So till point 3, I am able to execute commands from Java Project.

The maven command in #4., Java Code remains stuck and does not prompt user input. However, we execute the same command (mvn archetype:generate ) from Command Prompt, it asks user input (which is expected and desired).

Now, I am not getting any idea on why the Java application does not prompt for user input but in command prompt it does.

Thanks in Advance.. !


Solution

  • I managed to execute the command using following parameters

    mvn archetype:generate -DarchetypeGroupId=com.mycompany -DarchetypeArtifactId=myApp-template-archetype -DarchetypeVersion=1.0.0-SNAPSHOT -Ddomain="archetypeDomain" -DinteractiveMode=false

    By running the above command, I managed to took get it worked.