By default, the resources:resources lifecycle automatically copies
everything in the resources folder over to the target/classes folder
when it builds the war or jar.

In order to avoid this, you need to move your property files to
another folder, or if that's not possible, configure the
resources:resources step to skip these files. I recommend that you
create another folder like src/main/properties and stick your property
files in there.

See 
<http://maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html>
for information on skipping packaging certain files in your jar/war.

You will also need the assembly plugin to package your war with your
properties files as maybe a zip or tarball. See
<http://maven.apache.org/plugins/maven-assembly-plugin/> for
information about the assembly plugin.

Assemblies took me a while to understand. Basically, you create (by
convention) a folder called src/main/assemblies, and you define your
assembly XML files in there. You could have multiple ways of
packaging. For example, you might have one that includes only the
files you install while another includes some documents or source
files.

Normally, you call the assembly XML bin.xml, and the final package
will be something like foo-1.3-bin.zip. That is, this is version 1.3
of artifact "foo", and this is a zip file built by the "bin" assembly.
You could have things like foo-1.3-src.zip, etc.

Then, in your pom.xml, you have to define where the assembly files are
located, and you might also want to modify the lifecycle, so that your
assemblies are built when you do the mvn package. Otherwise, you'll
have to run mvn assembly:assembly.

To give you a better idea, this is what I have in my project's pom.xml
file under the <plugins> section:

                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-assembly-plugin</artifactId>
                                <version>2.2-beta-3</version>
                                <configuration>
                                        <descriptors>

<descriptor>src/main/assemblies/bin.xml</descriptor>
                                        </descriptors>
                                </configuration>
                                <executions>
                                        <execution>
                                                <phase>package</phase>
                                                <goals>
                                                        <goal>single</goal>
                                                </goals>
                                        </execution>
                                </executions>
                        </plugin>
                </plugins>

The <descriptor> defines where my assembly file lives, and I could
have multiple descriptors.

The <executions> defines that my assembly should be built in the
package phase, so I don't have to remember to run "mvn
assembly:assembly" in order to build the assembly.

The assembly itself is pretty simple:

assembly>
        <id>bin</id>
        <formats>
                <format>tar.gz</format>
        </formats>
        <baseDirectory>${artifactId}-${version}</baseDirectory>
        <includeSiteDirectory>false</includeSiteDirectory>
        <dependencySets>
                <dependencySet>
                        <outputDirectory>lib</outputDirectory>
                        <unpack>false</unpack>
                        <scope>runtime</scope>
                </dependencySet>
        </dependencySets>
        <fileSets>
                <fileSet>
                        <directory>src/main/bin</directory>
                        <outputDirectory>bin</outputDirectory>
                        <lineEnding>lf</lineEnding>
                        <fileMode>0755</fileMode>
                        <includes>
                                <include>**</include>
                        </includes>
                </fileSet>
                <fileSet>
                        <directory>src/main/config</directory>

<outputDirectory>client/${client}/config</outputDirectory>
                        <lineEnding>lf</lineEnding>
                        <fileMode>0644</fileMode>
                        <includes>
                                <include>**</include>
                        </includes>
                </fileSet>
        </fileSets>
</assembly>

Hope this helps.

On Thu, Jun 25, 2009 at 4:19 PM, sundar
varadarajan<sundarva...@gmail.com> wrote:
> Hello,
>
> I m new to Maven and I m trying to place property and config.xml files
> outside the Jar files. Here is my current directory
>
> Src
>  main
>  java
>  resources
> test
>  java
>  resources
>
> under java, i have all the java class files and in resources folder i have
> the properties and springbatch xml files.
>
> when i package the application, the property files which are under
> src/main/resources is also getting included. I need to place this outside
> the jar file so that the application can pickup when ever i make any changes
> to the property. currently i need to package again whenever a small change
> is made.
>
> please help.
>
> Thanks,
> Sundar
>



-- 
David Weintraub
qazw...@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to