是否可以获取当前Mojo的artifactId?
@Mojo(...)
public class MyMojo extends AbstractMojo {
@Parameter(property = "project")
private MavenProject project;
@Parameter(property = "inputDirectory", defaultValue = "${project.basedir}/src/main/${artifact id of the plugin}")
private File inputDirectory;
...
我可以硬编码插件的工件ID,但我宁愿动态地获取它。
答案 0 :(得分:0)
BTW我想到的是你正在使用旧式注射
@Parameter(property = "project")
private MavenProject project;
@Parameter(property = "inputDirectory", defaultValue = "${project.basedir}/src/main/${artifact id of the plugin}")
private File inputDirectory;
defaultValue的表达式值在此处记录: http://maven.apache.org/ref/3.1.1/maven-core/apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html取决于您使用的Maven版本。
@Parameter(defaultValue = "${project}, required = true, readonly = true)
private MavenProject project;
@Parameter(defaultValue = "${project.basedir}/src/main/${artifact id of the plugin}", property = "inputDirectory", required = true)
private File inputDirectory;