我想制作一对文件,看起来像
<configuration>
<params>
<param>
<wsdl>${basedir}/File1.wsdl</wsdl>
<result>D:/file1</result>
</param>
<param>
<wsdl>${basedir}/File2.wsdl</wsdl>
<result>D:/file2</result>
</param>
</params>
</configuration>
这是代码
/**
*
* @goal merge
* @requiresProject true
*/
public class MavenPlugin extends AbstractMojo
{
/**
*
* @parameter
* @requared
*/
public List<TwoFiles> params;
public void execute() throws MojoExecutionException, MojoFailureException
{
if (params == null || params.isEmpty())
{
throw new IllegalArgumentException("params is requared");
}
....
public class TwoFiles
{
public File wsdl;
public File result;
}
效果不佳。
任何想法?
答案:
public class MainExecutor extends AbstractMojo
{
/**
* @parameter
*/
private List<Param> params;
...
public class Param
{
public File wsdl;
public File result;
}
效果很好....
答案 0 :(得分:2)
你有没有试过这样做:
<configuration>
<params>
<param>
<wsdl>${basedir}/File1.wsdl</wsdl>
<result>D:/file1</result>
</param>
<param>
<wsdl>${basedir}/File2.wsdl</wsdl>
<result>D:/file2</result>
</param>
</params>
</configuration>
答案 1 :(得分:1)
我建议你实际上也为<params/>
创建一个对象。它包含Set<TwoFiles> params
。我以前遇到过这个问题,这就是我解决问题的方法。