Java 如何在maven apt插件中使用配置选项?
如何在中使用“配置”选项Java 如何在maven apt插件中使用配置选项?,java,maven,Java,Maven,如何在中使用“配置”选项 我可以在选项中设置键值,还是仅表示允许的选项字符串?基于我发现的另一个stackoverflow问题: 我想试试这样的东西: <configuration> <outputDirectory>${project.build.directory}/classes</outputDirectory> <options> <option>web.content.root=${project.build
我可以在选项中设置键值,还是仅表示允许的选项字符串?基于我发现的另一个stackoverflow问题: 我想试试这样的东西:
<configuration>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<options>
<option>web.content.root=${project.build.directory}/classes</option>
</options>
</configuration>
${project.build.directory}/classes
web.content.root=${project.build.directory}/classes
其中web.content.root=${project.build.directory}/classes
似乎是定义属性的正确方法
更新:
其他人似乎也在使用它:
见:
然而,它们在父pom中引用:
可能是自定义补丁版本:1.0-alpha-4-redhat-1
另外,我在:上看到过,但是我没有找到版本
因此,我会确保您使用最新版本的插件:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.0-alpha-5</version>
</plugin>
org.codehaus.mojo
aptmaven插件
1.0-α-5
或者可能是之前的一个:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.0-alpha-4</version>
</plugin>
org.codehaus.mojo
aptmaven插件
1.0-α-4
公共注释处理器GetProcessor for(设置decls、注释处理器或环境环境){
26字符串页=空;
27文件输出=新文件(“扩展名points.wiki”);
28 for(字符串k:env.getOptions().keySet()){
29如果(k.startsWith(“-Apage=”))
30页=k.substring(“-Apage=“.length());
31如果(k.startsWith(“-atatarget=”))
32输出=新文件(k.substring(“-Atarget=“.length()));
33 }
34返回新的ExtensionPointLister(环境、页面、输出);
35 }
36}
true org.jvnet.hudson.tools.ExtensionPointListerFactory页面=扩展点目标=${project.basedir}/target/Extension-points.wiki
我尝试了:key=19,因此我在apt处理器中打印选项,它print-Akey=19=null,有什么问题吗?看我的更新答案,好像你已经问过同样的问题了。对不起,这里不是这样的。
public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> decls, AnnotationProcessorEnvironment env) {
26 String page = null;
27 File output = new File("extension-points.wiki");
28 for( String k : env.getOptions().keySet() ) {
29 if(k.startsWith("-Apage="))
30 page = k.substring("-Apage=".length());
31 if(k.startsWith("-Atarget="))
32 output = new File(k.substring("-Atarget=".length()));
33 }
34 return new ExtensionPointLister(env,page, output);
35 }
36}
<configuration> <force>true</force> <!-- disable staleness check --> <factory>org.jvnet.hudson.tools.ExtensionPointListerFactory</factory> <options> <option>page=Extension points</option> <option>target=${project.basedir}/target/extension-points.wiki</option> </options> </configuration>