我必须使用 wsimport 生成源,并且我假设它应该转到 /target/generated-sources/wsimport 而不是 /src/main/java。
问题是 wsimport 需要在执行之前创建目标文件夹并且它失败了。我可以先使用任何 maven 插件创建该目录吗?我可以使用 ant 来完成,但我更喜欢将其保存在 POM 中。
尝试使用构建助手插件add source
的目标:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/target/generated/src/wsimport</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
我必须使用 wsimport 生成源,并且我假设它应该转到 /target/generated-sources/wsimport 而不是 /src/main/java。
这是一个正确的假设。
问题是 wsimport 需要在执行之前创建目标文件夹并且它失败了。我可以先使用任何 maven 插件创建该目录吗?我可以使用 ant 来完成,但我更喜欢将其保存在 POM 中。
我从来没有注意到这个问题(并且会认为它是一个错误,插件必须处理这些事情)。
奇怪的部分是它WsImportMojo
似乎通过调用来做必须做的事情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;
}
...
}
...
}
你能展示你如何调用插件及其配置吗?