2010-05-18 38 views
1

我有一个使用maven构建的web应用程序(即maven-war-plugin)的情况。对于每个代码修改,我们必须手动启动maven并重新启动应用程序服务器。现在,为了减少构建周期开销,我想使用WTP来发布webapp。用m2eclipse和WTP一起构建WAR(处理webResources)

现在,我们使用Maven进行资源处理,并且在构建webapp时,我们在POM中定义了一些额外的Maven任务。因此m2eclipse似乎是一个自然的解决方案。

我已经得到足够多,Maven构建器正在运行这些任务并正确过滤资源。但是,当我选择“在服务器上运行”时,WAR文件看起来并不像我在Maven中构建它时那样。

我是猜测这是因为WTP实际上构建的是WAR,而不是m2eclipse构建器。所以即使我们在我们的POM中配置了maven-war-plugin,这些设置也不会被使用。

下面是我们的maven-war-plugin配置的一个片段。什么是在“webResources”不拿起配置,看来:

<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-war-plugin</artifactId> 
<version>2.1-alpha-2</version> 
<configuration> 
<outputDirectory>${project.build.directory}</outputDirectory> 
<workDirectory>${project.build.directory}/work</workDirectory> 
<webappDirectory>${project.build.webappDirectory}</webappDirectory> 
<cacheFile>${project.build.webappDirectory}/webapp-cache.xml</cacheFile> 
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors> 
<nonFilteredFileExtensions> 
    <nonFilteredFileExtension>pdf</nonFilteredFileExtension> 
    <nonFilteredFileExtension>png</nonFilteredFileExtension> 
    <nonFilteredFileExtension>gif</nonFilteredFileExtension> 
    <nonFilteredFileExtension>jsp</nonFilteredFileExtension> 
</nonFilteredFileExtensions> 
<webResources> 
<!-- Add generated WSDL:s and XSD:s for the web service api. --> 
    <resource> 
    <directory>${project.build.directory}/jaxws/wsgen/wsdl</directory> 
    <targetPath>WEB-INF/wsdl</targetPath> 
    <filtering>false</filtering> 
    <includes> 
    <include>**/*</include> 
    </includes> 
</resource>    
</webResources> 
</configuration> 

我是否需要重新配置这些资源在其他地方处理,或者是有没有更好的解决办法?

回答

1

我不确定(过滤)网络资源是否受支持,请参阅MNGECLIPSE-1149。这个问题有一个补丁(和一个解决方法),可以为你工作。也看看从this thread破解。

+0

谢谢!在这种情况下,我最终使用了线程中的hack。 – waxwing 2010-05-18 13:58:01

2

要回答我自己的问题填写,如果别人遇到了同样的问题,我最终加入以下到我的webapp项目:

<resource> 
    <directory>${project.build.directory}/jaxws/wsgen/wsdl</directory> 
    <filtering>true</filtering> 
    <targetPath>${project.basedir}/src/main/webapp/WEB-INF/wsdl</targetPath> 
    <includes> 
    <include>**/*</include> 
    </includes> 
</resource> 

(在resources元素中下build)。

它工作正常,因为我的WSDL文件生成在generate-resources阶段,并将它们放在target/jaxws/wsgen/wsdl。然后将这些文件移动到src/main/webapp/WEB-INF/wsdl中,WTP构建器在构建WAR文件时选择它们。

注意:我应该提一下,我现在在Maven的eclipse插件(即mvn eclipse:eclipse)中遇到了一些问题,因为显然你不允许在targetPath中拥有绝对路径。尚未找到令人满意的解决方法...