You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Bent André Solheim <be...@gmail.com> on 2006/02/19 19:16:10 UTC

"Tagging" a deployed artifact based on profile used to create it

Hi all.

I have a web app that I need to build for deployment on different
tomcat instances (production and test). To achieve this I use
profiles; I use different properties files depending on the profile
that was used for building. This works great.

Now, the problem I have is that in addition to deploying to a tomcat
instance, I also would like to deploy the generated war file to our
artifact repository;

mvn -Pprod deploy

This also works great, but a new requirement is that we want one
artifact in the repository for the test environment and one for
production. This is where the problem arises. Although I am able to
use the <finalName> property in each profile to set the name of the
war file that ends up in the target folder, this does not affect the
name that is used on the artifact when it is deployed using "mvn
-Pprod deploy". The effect is that we are not able to distinguish the
artifacts in the repository that was built using the test profile from
those built using the production profile.

And now for the question; is it possible to alter the name of the
artifact that ends up in the repository based on the profile that was
used when deploying it? If not, does anybody have a tip to how I can
go about achieving what we want in other ways? I though about using
different repositories for test and production, but this seems
sub-optimal.

Any help would be greatly appreciated!

Regards, Bent.

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


Re: "Tagging" a deployed artifact based on profile used to create it

Posted by Lester Ecarma <le...@exist.com>.
Hi,

Why don't you try something like

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>your.group</groupId>
  <artifactId>yourArtifactId</artifactId>
  <version>1.0${pversion}</version>
  <packaging>war</packaging>
  ...
  <profiles>
    <profile>
      <id>test</id>
      <properties>
        <pversion>-test</pversion>
      </properties>
    </profile>
  <profiles>
  <properties>
    <pversion/>
  </properties>
<project>

In which case, the version created by the build will depend on which 
profile you're executing it with. Thus, if you build your app with
    mvn -Ptest install
you should end up with the artifact 
your/group/yourArtifactId/1.0-test/yourArtifactId-1.0-test.war installed 
in your local repository.

You could designate the default build (no profile id) as your production 
environment version, but you can also add appropriate profiles for other 
sub-versions (of the main version which is 1.0 in the example) as you want.

Hope this helps.

-lester


Bent André Solheim wrote:

>Hi all.
>
>I have a web app that I need to build for deployment on different
>tomcat instances (production and test). To achieve this I use
>profiles; I use different properties files depending on the profile
>that was used for building. This works great.
>
>Now, the problem I have is that in addition to deploying to a tomcat
>instance, I also would like to deploy the generated war file to our
>artifact repository;
>
>mvn -Pprod deploy
>
>This also works great, but a new requirement is that we want one
>artifact in the repository for the test environment and one for
>production. This is where the problem arises. Although I am able to
>use the <finalName> property in each profile to set the name of the
>war file that ends up in the target folder, this does not affect the
>name that is used on the artifact when it is deployed using "mvn
>-Pprod deploy". The effect is that we are not able to distinguish the
>artifacts in the repository that was built using the test profile from
>those built using the production profile.
>
>And now for the question; is it possible to alter the name of the
>artifact that ends up in the repository based on the profile that was
>used when deploying it? If not, does anybody have a tip to how I can
>go about achieving what we want in other ways? I though about using
>different repositories for test and production, but this seems
>sub-optimal.
>
>Any help would be greatly appreciated!
>
>Regards, Bent.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>For additional commands, e-mail: users-help@maven.apache.org
>
>
>  
>


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