据我所知,这在命令行中是不可能的.值得注意的是,您可以定义用于在pom.xml中配置Compiler Plugin的(可选)参数
excludes和
includes,如下所示:
$mvn help:describe -Dcmd=compiler:compile -Ddetail
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'help'.
[INFO] ------------------------------------------------------------------------
[INFO] Building sandbox
[INFO] task-segment: [help:describe] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [help:describe {execution: default-cli}]
[INFO] 'compiler:compile' is a plugin goal (aka mojo).
Mojo: 'compiler:compile'
compiler:compile
Description: Compiles application sources
Deprecated. No reason given
Implementation: org.apache.maven.plugin.CompilerMojo
Language: java
Bound to phase: compile
Available parameters:
...
excludes
A list of exclusion filters for the compiler.
Deprecated. No reason given
...
includes
A list of inclusion filters for the compiler.
Deprecated. No reason given
...
所以实际上没有真正的方法可以长期做你想做的事.
但这导致了一个问题.由于Maven使用增量编译,即它只编译自上次构建以来在磁盘上更改的类,为什么还需要只编译一个类?你的用例是什么?