我在Maven插件的帮助下创建了一个Java应用程序,用于使用以下maven目标:
mvn archetype:generate -DgroupId=net.javabeat
-DartifactId=SampleJavaProject
-DarchetypeArtifactId=maven-archetype-quick-start
-DinteractiveMode=false
Run Code Online (Sandbox Code Playgroud)
何时-DinteractiveMode=false,然后以批处理模式创建项目,何时-DinteractiveMode=true,以交互模式创建项目.
我对交互模式和批处理模式感到困惑.那些是什么?
khm*_*ise 53
批处理模式将自动使用默认值,而不是通过提示输入这些值.批处理模式也可以通过--batch-mode或-B在命令行上激活.
Kid*_*rla 40
批处理模式使Maven在运行时不显示"Progress:125/150kB"样式行.如果您在某个服务器上运行Maven,然后再检查日志,这些进度行占用了日志的90%,并且基本上无法找到重要的内容.设置批处理模式会阻止此操 除此之外,我不知道批处理模式的任何其他用途.正如其他人所说,无论是否设置了交互模式或批处理模式,我都没有在构建过程中看到Maven提示任何内容.
常见的用例--batch-mode是在持续集成服务器上使用Maven时,如本文档中所述:在批处理模式下运行Maven。
因此,它将例如禁止上传消息,以避免污染控制台日志。
例如,当您通过.gitlab-ci.ymlMaven 模板在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"
Run Code Online (Sandbox Code Playgroud)
您可以看到--batch-mode默认情况下已启用。
| 归档时间: |
|
| 查看次数: |
25877 次 |
| 最近记录: |