简体   繁体   English

批处理文件在 mvn 命令后停止执行

[英]Batch file stops executing after mvn command

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,也不打印后续命令。

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?问题:关于 maven 有什么我不知道的会中断批处理吗? Does it not understand to execute the command with a lone number 1?用一个单独的数字1执行命令不明白吗?

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. 当通过原型从批处理文件调用Maven创建新项目时,您应该意识到执行的交互方式 ,即Maven将提示输入某些值或要求确认。

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 . 因此,您应该通过命令行传递generate目标和特定原型的一些选项 ,然后通过-B标准Maven选项或通过-DinteractiveMode=true以批处理模式运行。

From official documentation you should pass 官方文件您应该通过

  • The archetypeGroupId, archetypeArtifactId and archetypeVersion defines the archetype to use for project generation. archetypeGroupId,archetypeArtifactId和archetypeVersion定义了用于项目生成的原型。
  • The groupId, artifactId, version and package are the main properties to be set. groupId,artifactId,version和package是要设置的主要属性。 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 注意:添加\\为了提高可读性,您实际上并不需要它

try to execute that command like this.尝试像这样执行该命令。 Then next command will execute as expected然后下一个命令将按预期执行

CALL mvn <command>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM