我在netbeans 6.7中使用maven2原型创建了一个webapp。
当我进行普通构建(删除所有插件配置)时,它会复制所有必需的文件,包括'_svn'文件夹。但是我不想要那些文件,如何清除* .war文件中的_svn文件夹/文件以及包含'src / main / webapp'文件夹内容的爆炸目标文件夹?
T E S T S
-------------------------------------------------------
Running com.project.project.taglib.SSTest
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[war:war]
Packaging webapp
Assembling webapp[project-servlets] in
[C:\ROOT\1utils\project\project-servlets\trunk\target\project-servlets]
Processing war project
Copying webapp resources[C:\ROOT\1utils\project\project-servlets\trunk\src\main\webapp]
Webapp assembled in[735 msecs]
Building war: C:\ROOT\1utils\project\project-servlets\trunk\target\project-servlets.war
[install:install]
Installing C:\ROOT\1utils\project\project-servlets\trunk\target\project-servlets.war
to C:\LOCALREPO\.m2\com\project\project-servlets\1.0.0\project-servlets-1.0.0.war
我已经设法在pom.xml中使用资源过滤来过滤掉_svn文件,如果我正在创建一个jar文件,这一切都能正常工作。但是对于战争,在TEST阶段之后它会复制'src / main / webapp'文件夹的内容([war:war]),我似乎无法找到找到哪个配置/命令的方法呢?这是netbeans?它是我正在使用的任何插件? 这是我的pom.xml的构建部分,非常感谢帮助!!
<project>
.. ...
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>_svn/**/*</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>_svn/**/*</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/project-servlets/WEB-INF</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>_svn/**/*</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<verbose>true</verbose>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
<finalName>project-servlets</finalName>
</build>
..
..
</project>
@Pascal Thivent - 非常感谢您的回复。 我添加了'maven-war-plugin'配置,它开始做两次包装!!
[war:war] Packaging webapp
Assembling webapp[project-servlets] in [C:\ROOT\1utils\frg\project-servlets\trunk\target\project-servlets]
Processing war project
Copying webapp resources[C:\ROOT\1utils\frg\project-servlets\trunk\src\main\webapp]
Webapp assembled in[391 msecs]
Building war: C:\ROOT\1utils\frg\project-servlets\trunk\target\project-servlets.war [war:war]
Packaging webapp
Assembling webapp[project-servlets] in [C:\ROOT\1utils\frg\project-servlets\trunk\target\project-servlets]
Dependency[Dependency {groupId=log4j, artifactId=log4j, version=1.2.8, type=jar}] has changed (was Dependency {groupId=log4j, artifactId=log4j, version=1.2.8, type=jar}).
Dependency[Dependency {groupId=com.frg, artifactId=project, version=1.1.7, type=jar}] has changed (was Dependency {groupId=com.frg, artifactId=project, version=1.1.7, type=jar}).
Dependency[Dependency {groupId=com.frg, artifactId=commons, version=1.0.3, type=jar}] has changed (was Dependency {groupId=com.frg, artifactId=commons, version=1.0.3, type=jar}).
Dependency[Dependency {groupId=net.sourceforge.jtds, artifactId=jtds, version=1.2.2, type=jar}] has changed (was Dependency {groupId=net.sourceforge.jtds, artifactId=jtds, version=1.2.2, type=jar}).
Processing war project
pom文件现在有以下配置..
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>war</id>
<phase>package</phase>
<goals><goal>war</goal></goals>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<excludes>
<exclude>_svn/**/*</exclude>
<exclude>**/_svn/**</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</execution>
</executions>
</plugin>
我仍然在war文件中看到_svn文件夹!!但是,在我将_svn文件夹更改为.svn文件夹后,我甚至不需要任何资源过滤! 它会自动忽略'.svn'文件夹。 我认为应该有一个设置来设置从'.svn'到'_svn'的偏好。无论如何,这确实解决了我的初始问题,但是引入了我的旧.NET版本项目的向后不兼容问题.. :)
答案 0 :(得分:2)
(编辑:我的初步答案是建议在excludes
使用webResources
这是不正确的。我在下面提供了maven-war-plugin的更新配置,其中真正排除{{1}根据OP的要求。这已经过测试并且有效。)
_svn
但是,我热烈建议您将您的乌龟客户端配置为使用...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceExcludes>
**/_svn/**
</warSourceExcludes>
</configuration>
</plugin>
...
</plugins>
而不是.svn
。我找不到引用,但我相信maven在内部使用等同于_svn
的东西。我对之前的陈述有疑问。但是,事实是使用<exclude>**/.svn</exclude>
可以避免任何额外的配置,从而使事情变得更加简单。
答案 1 :(得分:0)
这对我有用,只有一个更正:
标记为<packagingExcludes>
(在版本2.1-alpha-1中,这被错误地命名为warSourceExcludes。)
来源:http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html