如何从“src/main/webapp”中清理 _svn 文件夹/文件maven2在netbeans 6.7中构建webapp项目时的文件夹?
我在 netbeans 6.7 中使用 maven2 原型创建了一个 web 应用程序。
当我进行简单构建(删除所有插件配置)时,它会复制所有必需的文件,包括“_svn”文件夹。但我不想要这些文件,如何从 *.war 文件和包含“src/main/webapp”文件夹内容的分解目标文件夹中清除 _svn 文件夹/文件?
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 文件,所有这些都可以完美地工作。但是对于战争,在测试阶段之后它会复制“src/main/webapp”文件夹的内容([war:war]),我似乎无法找到一种方法来找到哪个配置/命令执行此操作?这是网豆吗?这是我正在使用的任何插件吗? 这是我的 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 版本项目的向后不兼容问题..:)
I have created a webapp using maven2 archetype in netbeans 6.7.
when I do plain build(removing all the plugin configuration), it copies all the required files including the '_svn' folders. But I don't want those files, how can I clean _svn folders/files from the *.war file and from the exploded target folder which contains the 'src/main/webapp' folder's content?
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
I have managed to use resource filtering in pom.xml to filter out the _svn files, all that works perfectly if I am creating a jar file. But with war, after TEST-phase it copies the 'src/main/webapp' folder's content([war:war]), I can't seem to find a way to locate which config/command does this? is this netbeans? it is any of the plug-ins i am using?
Here is the build section of my pom.xml, help will be much appreciated!!
<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 - thanks a lot for the response.
I added 'maven-war-plugin' configuration and it started to do the packaging twice!!
[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
The pom file now has following configuration..
<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>
And I still see the _ svn folders in the war files!! However, after I have changed the _ svn folders to .svn folders, I didn't even need any resource filtering!!
It automatically ignores the '.svn' folders.
I would think there should be a settings somewhere to set the preference from '.svn' to '_svn'. Anyway, this does solve my initial problem, but introduces a backward incompatibility problem with my old .NET versioned projects.. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(编辑:我最初的答案是建议在
webResources
中使用excludes
,这是不正确的。我在下面提供了 maven-war-plugin 确实按照OP的要求排除了_svn
。这已经过测试并且可以工作。)但是,我强烈建议将您的乌龟客户端配置为使用
.svn
而不是_svn
。我找不到参考,但我相信 maven 在内部使用了相当于**/.svn
的东西。我对之前的说法有疑问。然而,事实是使用.svn
可以让您避免任何额外的配置,从而使事情变得更加简单。(EDIT: My initial answer was suggesting to use
excludes
inwebResources
which is not correct. I'm providing below an updated configuration of the maven-war-plugin that really excludes_svn
as requested by the OP. This has been tested and works.)But, I'd warmly suggest to configure your tortoise client to use
.svn
instead of_svn
. I can't find the reference but I believe that maven uses something equivalent to<exclude>**/.svn</exclude>
internally. I have a doubt about the previous statement. However, the fact is that using.svn
allows you to avoid any extra configuration and makes thus things a lot simpler.这对我很有用,有一个更正:
标签是
(在版本 2.1-alpha-1 中,它被错误地命名为 warSourceExcludes。)来源:http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html
This was useful to me, with one correction:
the tag is
<packagingExcludes>
(In version 2.1-alpha-1, this was incorrectly named warSourceExcludes.)source: http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html