set homepath=%userprofile%
set a=%1
set b=%2
set c=%3
set uuid=%4
set zipDirectory=%5
set pluginDirectory=%6
cd %homepath%\%a%
mvn archetype:generate -DarchetypeCatalog=file://%homepath%/.m2/repository
Everything works up to here, then the command lines stop executing. It doesn't print the 1, nor subsequent commands.
1
c
b
c
%uuid%
Y
cd %homepath%\%a%\%b%
mvn clean install
cd %homepath%\%a%\%b%\%b%-plugin\target
jar -xvf %zipDirectory%
cd %homepath%\%a%\%b%\%b%-plugin\target\META-INF\maven\%c%\%b%-plugin
copy pom.xml + %pluginDirectory%
cd %pluginDirectory%
rename pom.xml %b%-plugin-1.0.0.pom
Question: Is there anything about maven I don't know about that interrupts a batch process? Does it not understand to execute the command with a lone number 1?
Add a pause statement to a batch file If you're creating a batch file and want the MS-DOS window to remain open, add PAUSE to the end of your batch file. This prompts the user to Press any key. Until the user presses any key, the window remains open instead of closing automatically.
Use these commands in batch file to run ur script. Keep your batch file where you pom. xml file is housed set ProjectPath=C:\TetonWorkSpace\PeriodicApplicationCheck cd %ProjectPath% mvn clean test -Dxmlfile=Smoke. xml pause To Create a Task in Task scheduler: 1.
Pressing "y" would use the goto command and go back to start and rerun the batch file. Pressing any other key would exit the batch file. The above code is for Windows 2000, XP, and later users if you're running earlier Windows 98 or earlier you'd need to use the choice command.
When invoking Maven from a batch file to create a new project via archetype you should be aware of the interactive mode of the execution, that is, Maven will prompt for certain values or ask for confirmation.
It seems in your case this is not the desired behavior. You should hence pass via command line some options of the generate
goal and the specific archetype and then run either in batch mode via the -B
standard Maven option or via -DinteractiveMode=true
.
From official documentation you should pass
- The archetypeGroupId, archetypeArtifactId and archetypeVersion defines the archetype to use for project generation.
- The groupId, artifactId, version and package are the main properties to be set. Each archetype require these properties. Some archetypes define other properties; refer to the appropriate archetype's documentation if needed
Hence in your case:
call mvn archetype:generate -DarchetypeCatalog=file://%homepath%/.m2/repository -B \
-DarchetypeGroupId=com.sample -DarchetypeArtifactId=artifact -DarchetypeVersion=1.0 \
-DgroupId=your.groupid -DartifactId=your.artifactId -Dversion=0.0.1-SNAPSHOT \
-Dsomething-else=value
Note: \
added for readability, you don't actually need it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With