You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mike Lenner <mi...@gmail.com> on 2010/12/16 01:03:22 UTC

Changing Project Version During Build

I'd like to write a plugin that allows me to change the version of the
current project during the build.  Is this considered bad form?  Is it
even possible?

My use case is that I'd like to replicate what release:prepare is
doing but w/o tagging and w/o checking out new source and running the
build on that source.  I'd like to run mvn deploy -P release and in
doing so have my -SNAPSHOT version replaced with the release version
and then have my build progress as normal.

I've tried using MavenProject.setVersion() but that seemed to have no
effect.  I next tried MavenProject.getArtifact().setVersion().  This
seemed to work better however the assembly plugin used later in my
build started to fail with a NPE.  Haven't tracked down exactly what
the connection is yet but thought I'd send an email out to see if
anyone else has done this and/or if this is a bad idea.

Thanks,
Mike

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


Re: Changing Project Version During Build

Posted by Mike Lenner <mi...@gmail.com>.
Thanks for the reply.

Had been trying to avoid that but seems I cannot.  Especially since
moving to the next SNAPSHOT version gets you to:

mvn <update-versioin-to-release-plugin> && mvn clean install && mvn
<update-version-to-next-snapshot-plugin>

On Wed, Dec 15, 2010 at 7:36 PM, Justin Edelson
<ju...@justinedelson.com> wrote:
> Yes, this is considered bad form. It might be possible to change some POJO
> properties, but that won't really do it, as you're finding. You can do
> something along these lines with multiple executions of Maven. I think there
> are some examples of this with the versions plugin. Something like:
>
> mvn versions:update-parent && mvn clean package
>
> Justin
>
> On Wed, Dec 15, 2010 at 7:03 PM, Mike Lenner <mi...@gmail.com> wrote:
>
>> I'd like to write a plugin that allows me to change the version of the
>> current project during the build.  Is this considered bad form?  Is it
>> even possible?
>>
>> My use case is that I'd like to replicate what release:prepare is
>> doing but w/o tagging and w/o checking out new source and running the
>> build on that source.  I'd like to run mvn deploy -P release and in
>> doing so have my -SNAPSHOT version replaced with the release version
>> and then have my build progress as normal.
>>
>> I've tried using MavenProject.setVersion() but that seemed to have no
>> effect.  I next tried MavenProject.getArtifact().setVersion().  This
>> seemed to work better however the assembly plugin used later in my
>> build started to fail with a NPE.  Haven't tracked down exactly what
>> the connection is yet but thought I'd send an email out to see if
>> anyone else has done this and/or if this is a bad idea.
>>
>> Thanks,
>> Mike
>>
>> ---------------------------------------------------------------------
>> 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


Re: Changing Project Version During Build

Posted by Justin Edelson <ju...@justinedelson.com>.
Yes, this is considered bad form. It might be possible to change some POJO
properties, but that won't really do it, as you're finding. You can do
something along these lines with multiple executions of Maven. I think there
are some examples of this with the versions plugin. Something like:

mvn versions:update-parent && mvn clean package

Justin

On Wed, Dec 15, 2010 at 7:03 PM, Mike Lenner <mi...@gmail.com> wrote:

> I'd like to write a plugin that allows me to change the version of the
> current project during the build.  Is this considered bad form?  Is it
> even possible?
>
> My use case is that I'd like to replicate what release:prepare is
> doing but w/o tagging and w/o checking out new source and running the
> build on that source.  I'd like to run mvn deploy -P release and in
> doing so have my -SNAPSHOT version replaced with the release version
> and then have my build progress as normal.
>
> I've tried using MavenProject.setVersion() but that seemed to have no
> effect.  I next tried MavenProject.getArtifact().setVersion().  This
> seemed to work better however the assembly plugin used later in my
> build started to fail with a NPE.  Haven't tracked down exactly what
> the connection is yet but thought I'd send an email out to see if
> anyone else has done this and/or if this is a bad idea.
>
> Thanks,
> Mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>