Java Maven中的交互模式和批处理模式有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25896081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between interactive and batch mode in Maven?
提问by Maulik Patel
I have created a Java application with the help of Maven plugin for using following maven goal:
我在 Maven 插件的帮助下创建了一个 Java 应用程序,用于使用以下 Maven 目标:
mvn archetype:generate -DgroupId=net.javabeat
-DartifactId=SampleJavaProject
-DarchetypeArtifactId=maven-archetype-quick-start
-DinteractiveMode=false
When -DinteractiveMode=false
, then project is created in batch mode, and when -DinteractiveMode=true
, then project is created in interactive mode.
I'm confused with interactive mode and batch mode. What are those?
当-DinteractiveMode=false
,则以批处理模式创建项目,而当-DinteractiveMode=true
,则以交互模式创建项目。
我对交互模式和批处理模式感到困惑。那些是什么?
回答by khmarbaise
The batch-mode will automatically use default values instead of asking you via prompt for those values. The batch-mode can also be activated via --batch-mode
or -B
on command line.
批处理模式将自动使用默认值,而不是通过提示询问您这些值。批处理模式也可以通过命令行--batch-mode
或-B
在命令行上激活。
回答by Adam Burley
Batch mode causes Maven to not display "Progress: 125/150kB" style lines when running. If you are running Maven on some server and then checking the logs afterwards, these progress lines take up 90% of the log and make it basically impossible to find the stuff that matters. Setting batch mode prevents this. Apart from that, I don't know any other use for batch mode. As others have said, I have never seen Maven prompt for anything during a build, regardless of whether interactive or batch mode is set.
批处理模式导致 Maven 在运行时不显示“Progress: 125/150kB”样式的行。如果你在某台服务器上运行 Maven,然后检查日志,这些进度行占据了日志的 90%,基本上不可能找到重要的东西。设置批处理模式可以防止这种情况。除此之外,我不知道批处理模式有任何其他用途。正如其他人所说,我从未在构建过程中看到 Maven 提示任何内容,无论是否设置了交互或批处理模式。
回答by Guillaume Husta
A common use case for --batch-mode
is when using Maven on a Continuous Integration server, like said in this doc : Running Maven in Batch Mode.
一个常见的用例--batch-mode
是在持续集成服务器上使用 Maven 时,如本文档中所述:以批处理模式运行 Maven。
So it will for example suppress upload messages to avoid polluting the console log.
因此,它将例如抑制上传消息以避免污染控制台日志。
For example, when you create a new file on GitLab through the template .gitlab-ci.yml
for Maven, you will have the following in the variables :
例如,当您通过.gitlab-ci.yml
Maven模板在 GitLab 上创建一个新文件时,您将在变量中包含以下内容:
variables:
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
You can see that --batch-mode
is enabled by default.
您可以看到--batch-mode
默认情况下已启用。