Filtering WEB-INF files in Maven webapp

<build>
  <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
      <webResources>
        <resource>
           <directory>${basedir}/src/main/webapp/WEB-INF</directory>
           <filtering>true</filtering>
           <targetPath>WEB-INF</targetPath>
        </resource>
      </webResources>
    </configuration>
   </plugin>
 </plugins>
</build>
Advertisements

Create a multi module Maven archetype

It can be very helpful to dispose of a library of pre-configured projects. Here, we want to create a multi-module project composed of a core (Hibenate Dao) and a web (SpringMVC webapp) module.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.stephou</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent</name>
<url>http://maven.apache.org</url>

<modules>
 <module>core</module>
 <module>web</module>
</modules>
...

Use a mvn archetype:create-from-project to create the archetype project.
and in target/generated-sources/archetype/ use a mvn install.

In the end, into a new directory, the mvn archetype:generate -DarchetypeCatalog=local will allow you to use the project as a ready-to-code project 🙂

D:\documents\NetBeansProjects>%M2_HOME%\bin\mvn archetype:generate -DarchetypeCa
talog=local
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] org.apache.maven.plugins: checking for updates from central
[INFO] org.codehaus.mojo: checking for updates from central
[INFO] artifact org.apache.maven.plugins:maven-archetype-plugin: checking for up
dates from central
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus
.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] [archetype:generate {execution: default-cli}]
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.
archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: local -> parent-archetype (parent-archetype)
Choose a number:  (1): 1
Define value for groupId: : net.stephou
Define value for artifactId: : springmvc-mvn-webapp
Define value for version:  1.0-SNAPSHOT: :
Define value for package:  net.stephou: :
Confirm properties configuration:
groupId: net.stephou
artifactId: springmvc-mvn-webapp
version: 1.0-SNAPSHOT
package: net.stephou
 Y: : Y
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 15 seconds
[INFO] Finished at: Sun Feb 28 22:11:56 CET 2010
[INFO] Final Memory: 8M/14M
[INFO] ------------------------------------------------------------------------

A new folder named springmvc-mvn-webapp will appear in the selected folder. Just open it in your favourite IDE.

See also : http://maven.apache.org/plugins/maven-archetype-plugin/advanced-usage.html

How to restore Windows Vista icons from user directory

To get your icons back just replace desktop.ini in the folder with one of the corresponfing file. Log off to see the changes.

Contacts
[.ShellClassInfo]
LocalizedResourceName=@%CommonProgramFiles%\system\wab32res.dll,-10100
InfoTip=@%CommonProgramFiles%\system\wab32res.dll,-10200
IconResource=%SystemRoot%\system32\imageres.dll,-181

Desktop
[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21769
IconResource=%SystemRoot%\system32\imageres.dll,-183

Documents
[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21770
IconResource=%SystemRoot%\system32\imageres.dll,-112
IconFile=%SystemRoot%\system32\shell32.dll
IconIndex=-235
[RESTUNER]
Vector2=FFF4D0A4FFF4D092FFFEFFA063AC7E80

Downloads
[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21798
IconResource=%SystemRoot%\system32\imageres.dll,-184

Favorites
[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21796
IconResource=%SystemRoot%\system32\imageres.dll,-115
IconFile=%SystemRoot%\system32\shell32.dll
IconIndex=-173

Links
[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21810
IconResource=%SystemRoot%\system32\imageres.dll,-185
DefaultDropEffect=4
[LocalizedFileNames]
Public.lnk=@shell32.dll,-21816
Searches.lnk=@shell32.dll,-9031
Recently Changed.lnk=@shell32.dll,-32813
Music.lnk=@shell32.dll,-21790
Pictures.lnk=@shell32.dll,-21779
Documents.lnk=@shell32.dll,-21770

Music
[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21790
InfoTip=@%SystemRoot%\system32\shell32.dll,-12689
IconResource=%SystemRoot%\system32\imageres.dll,-108
IconFile=%SystemRoot%\system32\shell32.dll
IconIndex=-237
[LocalizedFileNames]
Sample Music.lnk=@%SystemRoot%\system32\shell32.dll,-21806

Pictures
[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21779
InfoTip=@%SystemRoot%\system32\shell32.dll,-12688
IconResource=%SystemRoot%\system32\imageres.dll,-113
IconFile=%SystemRoot%\system32\shell32.dll
IconIndex=-236
[LocalizedFileNames]
Sample Pictures.lnk=@%SystemRoot%\system32\shell32.dll,-21805

Saved Games
[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21814
IconResource=%SystemRoot%\system32\imageres.dll,-186

Searches
[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-9031
IconResource=%SystemRoot%\system32\imageres.dll,-18
[LocalizedFileNames]
Indexed Locations.search-ms=@shell32.dll,-32811
Everywhere.search-ms=@shell32.dll,-32814
Shared By Me.search-ms=@shell32.dll,-32802
Recent Music.search-ms=@shell32.dll,-32803
Recent Documents.search-ms=@shell32.dll,-32804
Recent Pictures and Videos.search-ms=@shell32.dll,-32806
Recent E-mail.search-ms=@shell32.dll,-32807
Recently Changed.search-ms=@shell32.dll,-32813

Videos
[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21791
InfoTip=@%SystemRoot%\system32\shell32.dll,-12690
IconResource=%SystemRoot%\system32\imageres.dll,-189
IconFile=%SystemRoot%\system32\shell32.dll
IconIndex=-238
[LocalizedFileNames]
Sample Videos.lnk=@%SystemRoot%\system32\shell32.dll,-21807