views:

462

answers:

1

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.. :)

+1  A: 

(EDIT: My initial answer was suggesting to use excludes in webResources 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.)

...
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
      <warSourceExcludes>
        **/_svn/**
      </warSourceExcludes>
    </configuration>
  </plugin>
  ...
</plugins>

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.

Pascal Thivent
I have changed the _ svn folders to .svn folders, I didn't even need any resource filtering!! It automatically ignores the '.svn' folders.
Indeed, that was my point (and suggestion). Actually, I didn't even know some tools where using something else than `.svn`...
Pascal Thivent
by default svn is configured to use .svn but our VS2003 edition projects was having issues, so we switched over from .svn to _ svn.