gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 16:06:12 24 4
gpt4 key购买 nike

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

一切正常,然后命令行停止执行。它不打印 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

问题 :有什么关于maven的我不知道会中断批处理吗?用一个单独的数字 1 执行命令是不是不明白?

最佳答案

从批处理文件调用 Maven 以通过原型(prototype)创建新项目时,您应该注意 interactive mode的执行,即Maven会提示某些值或要求确认。

在您的情况下,这似乎不是所需的行为。因此,您应该通过命令行传递一些 optionsgenerate目标和特定原型(prototype),然后通过 -B 以批处理模式运行标准 Maven 选项或通过 -DinteractiveMode=true .

来自 official documentation你应该通过

  • 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


因此,在您的情况下:
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

注: \为了可读性而添加的,您实际上并不需要它

关于shell - 批处理文件在 mvn 命令后停止执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37658559/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com