<?xml version="1.0" encoding="iso-8859-1"?>

<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  xmlns:admin="http://webns.net/mvcb/"
  xmlns:cc="http://web.resource.org/cc/"
  xmlns="http://purl.org/rss/1.0/">

<channel rdf:about="http://blogs.codehaus.org/people/trygvis//archives/maven.html">
<title><![CDATA[Trygve Laugst&oslash;l]]> - Maven</title>
<link>http://blogs.codehaus.org/people/trygvis//archives/maven.html</link>
<description></description>
<dc:language>en-us</dc:language>
<dc:creator></dc:creator>
<dc:date>2006-01-01T15:12:35+01:00</dc:date>
<admin:generatorAgent rdf:resource="http://www.movabletype.org/?v=2.661" />

<items>
<rdf:Seq><rdf:li rdf:resource="http://blogs.codehaus.org/people/trygvis/archives/001296_building_for_different_environments_with_maven_2.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/trygvis/archives/001172_my_javazone_2005_slides.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/trygvis/archives/001172_my_javazone_2005_slides.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/trygvis/archives/001150_maven_2_runs_on_a_free_runtime.html" />
<rdf:li rdf:resource="http://blogs.codehaus.org/people/trygvis/archives/001040_hell_just_froze_over.html" />
</rdf:Seq>
</items>

</channel>

<item rdf:about="http://blogs.codehaus.org/people/trygvis/archives/001296_building_for_different_environments_with_maven_2.html">
<title>Building For Different Environments with Maven 2</title>
<link>http://blogs.codehaus.org/people/trygvis/archives/001296_building_for_different_environments_with_maven_2.html</link>
<description><![CDATA[<p>
Building the same artifact for different environments has always been an
annoyance. You have multiple environments, for instance test and production
servers or, maybe a set of servers that run the same application with different
configurations. In this guide I'll explain how you can use <it>profiles</it> to
build and package artifacts configured for specific environments. See [1] for a
more in-depth explanation of the profile concept.
</p>

<p>
<i>Note:</i>
<ul>
<li>This guide assume that you have basic Maven 2 knowledge.</li>
<li>It will show a way to configure Maven to solve simple configuration set-ups
only. By simple configuration set-up I mean cases where you only have a single
file or a small set of files that vary for each environment. There are other
and better ways to handle two and many-dimensional configuration issues.
</ul>
</p>

<p>
This example assume the use of the Standard Directory Layout[2]. A
fully-working example project can be found at [3].
<pre>
pom.xml
src/
  main/
    java/
    resources/
  test/
    java/
</pre>
</p>

<p>
Under <code>src/main/resources</code> there are three files:
<ul>
  <li><code>environment.properties</code> - This is the default configuration and will be packaged in the artifact by default.</li>
  <li><code>environment.test.properties</code> - This is the variant for the test environment.</li>
  <li><code>environment.prod.properties</code> - This is basically the same as the test variant and will be used in the production environment.</li>
</ul>
</p>

<p>
In the project descriptor, you need to configure the different profiles. Only
the test profile is showed here, see the accompanying source code[3] for the
full pom.xml.
<pre>
&lt;profiles&gt;
  &lt;profile&gt;
    &lt;id&gt;test&lt;/id&gt;
    &lt;build&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;mavenltantrunltplugin&lt;/artifactId&gt;
          &lt;executions&gt;
            &lt;execution&gt;
              &lt;phase&gt;test&lt;/phase&gt;
              &lt;goals&gt;
                &lt;goal&gt;run&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                &lt;tasks&gt;
                  &lt;delete file="${project.build.outputDirectory}/environment.properties"/&gt;
                  &lt;copy file="src/main/resources/environment.test.properties" tofile="${project.build.outputDirectory}/environment.properties"/&gt;
                &lt;/tasks&gt;
              &lt;/configuration&gt;
            &lt;/execution&gt;
          &lt;/executions&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;mavenltsurefireltplugin&lt;/artifactId&gt;
          &lt;configuration&gt;
            &lt;skip&gt;true&lt;/skip&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;mavenltjarltplugin&lt;/artifactId&gt;
          &lt;executions&gt;
            &lt;execution&gt;
              &lt;phase&gt;package&lt;/phase&gt;
              &lt;goals&gt;
                &lt;goal&gt;jar&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                &lt;classifier&gt;test&lt;/classifier&gt;
              &lt;/configuration&gt;
            &lt;/execution&gt;
          &lt;/executions&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  &lt;/profile&gt;

  .. Other profiles goes here ..

&lt;/profiles&gt;
</pre>
</p>

<p>
Three things are configured in this snippet:
<ol>
<li>It configures the <code>antrun</code> plugin to execute the
<code>run</code> goal in the test phase where it will copy the
<code>environment.test.properties</code> file to
<code>environment.properties</code>.</li>
<li>It will configure the test plugin to skip all tests when building the test
and production artifacts. This is useful as you probably don't want to run
tests against the production system</li>
<li>It configures the JAR plugin to create an "attached" JAR with the "test"
classifier.</li>
</ol>
To activate this profile execute <code>mvn -Ptest install</code> and maven will
execute the steps in the profile in addition to the normal steps. From this
build you will get two artifacts, "foo-1.0.jar" and "foo-1.0-test.jar". These
two jars will identical.
</p>

<h2>Caveats</h2>
<ul>
<li>
Currently Maven 2 doesn't allow a project build to only produce attached
artifacts. (i.e. it has to produce a "main" artifact as well) This results in
two equal JARs beeing packaged and installed. The JAR plugin probably should
also get improved support for this use case to that two different output
directories will be used as the basis for building the JAR.
</li>
<li>
The usage of the delete task might seem a bit odd but is required to make sure
that the copy task actually will copy the file. The copy task will look at the
timestamps of the source and destination files, only when copying the files it
won't know that the actualy source file might be different than the last time
it was executed.
</li>
<li>
After the build the test configuration will be in target/classes and won't be
overridden because the resources plugin uses the same timestamp checking, so
you should always do a clean after executing Maven with a profile.
</li>
<li>
For the reasons given above it's imperative that you only build an artifact for
a single environment in a single execution at a time and that you execute "mvn
clean" whenever you change the profile switches. If not, you might get
artifacts with a mixed set of configuration files.
</li>
</ul>

<h2>Resources</h2>
<ol>
<li><a href="http://maven.apache.org/guides/introduction/introduction-to-profiles.html">Introduction to Build Profiles</a></li>
<li><a href="http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html">Introduction to the Standard Directory Layout</a></li>
<li><a href="http://www.codehaus.org/~trygvis/static/2006/simpleenvironment.tar.gz">The accompanying source code</a></li>
</ol>
]]></description>
<dc:subject>Maven</dc:subject>
<dc:creator>trygvis</dc:creator>
<dc:date>2006-01-01T15:12:35+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/trygvis/archives/001172_my_javazone_2005_slides.html">
<title>My JavaZone 2005 Slides</title>
<link>http://blogs.codehaus.org/people/trygvis/archives/001172_my_javazone_2005_slides.html</link>
<description><![CDATA[<p>So <a href="http://www.javazone.no">javaZone</a> is over again and I'm as exhausted as one can be. Just as <a href="http://blogs.codehaus.org/people/vmassol/">Vincent</a>, I had a talk about <a href="http://maven.apache.org/maven2">Maven 2</a>, you can find my slides <a href="http://people.apache.org/~trygvis/maven2/maven2-javaZone-2005.pdf">here</a>. It might be fun comparing them to the talk I gave last year on <a href="http://people.apache.org/~trygvis/maven2/maven2_and_continuum-javaZone-2004.pdf">Maven 2 & Continuum</a>. If you have any questions about the content feel free to email me or ask questions on <a href="mailto:dev@maven.apache.org">the Maven users list</a>.</p>

<p>As I said in the talk <a href="http://blogs.codehaus.org/people/brett/archives/001173_maven_20_beta_1_released.html">the beta 1 release of Maven 2 is released</a>.</p>]]></description>
<dc:subject>Maven</dc:subject>
<dc:creator>trygvis</dc:creator>
<dc:date>2005-09-16T17:35:37+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/trygvis/archives/001172_my_javazone_2005_slides.html">
<title>My JavaZone 2005 Slides</title>
<link>http://blogs.codehaus.org/people/trygvis/archives/001172_my_javazone_2005_slides.html</link>
<description><![CDATA[<p>So <a href="http://www.javazone.no">javaZone</a> is over again and I'm as exhausted as one can be. Just as <a href="http://blogs.codehaus.org/people/vmassol/">Vincent</a>, I had a talk about <a href="http://maven.apache.org/maven2">Maven 2</a>, you can find my slides <a href="http://people.apache.org/~trygvis/maven2/maven2-javaZone-2005.pdf">here</a>. It might be fun comparing them to the talk I gave last year on <a href="http://people.apache.org/~trygvis/maven2/maven2_and_continuum-javaZone-2004.pdf">Maven 2 & Continuum</a>. If you have any questions about the content feel free to email me or ask questions on <a href="mailto:dev@maven.apache.org">the Maven users list</a>.</p>

<p>As I said in the talk <a href="http://blogs.codehaus.org/people/brett/archives/001173_maven_20_beta_1_released.html">the beta 1 release of Maven 2 is released</a>.</p>]]></description>
<dc:subject>Maven</dc:subject>
<dc:creator>trygvis</dc:creator>
<dc:date>2005-09-16T17:35:37+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/trygvis/archives/001150_maven_2_runs_on_a_free_runtime.html">
<title>Maven 2 runs on a free runtime!</title>
<link>http://blogs.codehaus.org/people/trygvis/archives/001150_maven_2_runs_on_a_free_runtime.html</link>
<description><![CDATA[<p>
Beeing a fan of open and free source and all I want to make sure that Maven will run properly on at least one of all the free runtimes that's out there. So here the other day with a few moments to spare I took it for a spin.
</p>
<p>
The first snag I ran into was that of course Sun's javac won't run on a non-Sun JVM so I had to brush the dust off of our old Eclipse compiler. The Eclipse compiler is a Java compiler written in Java with out any dependencies. So after adding this to the root POM:
<pre><![CDATA[<build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <compilerId>eclipse</compilerId>
        </configuration>
      </plugin>
    </plugins>
  </build>]]&gt;</pre>to select the Eclipse compiler and after that it all worked (as expected)!
</p>
<p>
Now this is there I'm supposed to include some summary and performance comparisons between the diffrent free VMs but of course I've lot the file with all my notes so I'll update the entry later next time I get some spare time.
</p>
<p>
I used <a href="http://jamvm.sourceforge.net/">JamVM</a> as the virtual machine and executed Maven 2 with this command:
<pre>JAVACMD=`which jamvm` m2 clean:clean install</pre>
</p>
<p>
I've already looked into what's requred for getting Maven 2 into at least <a href="http://www.debian.org">Debian</a>, it beeing my personal distro of choice. I've gotten almost all of the dependencies either packaged as a normal Java Debian packages or building as a part of my "m2-bootstrap" package so hopefully with either more spare time or more volunteers (<a href="http://www.jumpstation.ca/recroom/comedy/python/nudge.html">wink wink, nudge nudge</a>) Maven 2 should be available as a Debian package ... sometime.
</p>]]></description>
<dc:subject>Maven</dc:subject>
<dc:creator>trygvis</dc:creator>
<dc:date>2005-08-09T03:16:54+01:00</dc:date>
</item>
<item rdf:about="http://blogs.codehaus.org/people/trygvis/archives/001040_hell_just_froze_over.html">
<title>Hell just froze over!</title>
<link>http://blogs.codehaus.org/people/trygvis/archives/001040_hell_just_froze_over.html</link>
<description><![CDATA[<p>The Maven team just released a technology preview of Maven 2.</p>

<p>Check out the release blog entry at <a href="http://blogs.codehaus.org/people/brett/archives/001038_maven_20_technology_preview_release.html">Brett's blog</a> or go directly to <a href="http://maven.apache.org/maven2">start</a>.</p>

<p>For more Maven news make sure you check out the <a href="http://mavenblogs.com/">Maven blogs site</a>.</p>]]></description>
<dc:subject>Maven</dc:subject>
<dc:creator>trygvis</dc:creator>
<dc:date>2005-04-09T12:17:37+01:00</dc:date>
</item>


</rdf:RDF>
