如何在Maven中为生成的源创建文件夹? [英] How to create folder for generated sources in Maven?
问题描述
我必须使用wsimport生成源,并且我假设它应该转到/target/generation-sources/wsimport而不是/src/main/java.
I have to generate sources using wsimport and i assume that it should go to /target/generated-sources/wsimport rather than /src/main/java.
问题是wsimport需要在执行之前创建目标文件夹,并且失败.我可以先使用任何Maven插件创建该目录吗?我可以使用ant来做到这一点,但我更喜欢将其保存在POM中.
The problem is that wsimport needs target folder created before execution and it fails. Can I create that dir first using any maven plugin. I can do it using ant but i prefer to keep it in POM.
推荐答案
我必须使用wsimport生成源,并且我假设它应该转到/target/generation-sources/wsimport而不是/src/main/java.
I have to generate sources using wsimport and i assume that it should go to /target/generated-sources/wsimport rather than /src/main/java.
这是一个正确的假设.
问题是wsimport需要在执行之前创建目标文件夹,并且失败.我可以先使用任何Maven插件创建该目录吗?我可以使用ant来做到这一点,但我更喜欢将其保存在POM中.
The problem is that wsimport needs target folder created before execution and it fails. Can I create that dir first using any maven plugin. I can do it using ant but i prefer to keep it in POM.
我从来没有注意到这个问题(并且将其视为一个错误,插件必须负责处理此类问题).
I never noticed this problem (and would consider it as a bug, a plugin has to take care of such things).
怪异的部分是 File#mkdirs()
:>
public void execute()
throws MojoExecutionException
{
// Need to build a URLClassloader since Maven removed it form the chain
ClassLoader parent = this.getClass().getClassLoader();
String originalSystemClasspath = this.initClassLoader( parent );
try
{
sourceDestDir.mkdirs();
getDestDir().mkdirs();
File[] wsdls = getWSDLFiles();
if(wsdls.length == 0 && (wsdlUrls == null || wsdlUrls.size() ==0)){
getLog().info( "No WSDLs are found to process, Specify atleast one of the following parameters: wsdlFiles, wsdlDirectory or wsdlUrls.");
return;
}
...
}
...
}
您能展示一下如何调用插件及其配置吗?
Could you show how you invoke the plugin and its configuration?
这篇关于如何在Maven中为生成的源创建文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!