You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Enrico Olivelli <eo...@gmail.com> on 2019/10/03 15:13:37 UTC

Hooks on mvn release:prepare

Hello,
I am going to propose a new release procedure in Apache ZooKeeper project
in the direction of using the Maven Release Plugin.
Usually with the Maven Release Plugin you are performing to tasks:

mvn release:prepare -> change version + create tag
mvn release:perform  -> create final artifacts and deploy

in the specific case of Apache ZooKeeper we have a C-client that  contains
C sources under a mavenized project, so in src/c or something like that,
not so important.

The important fact is that I have the 'version' in pom.xml and in the C
client (make/configure based build).
I would like to introduce an hook that during "release:prepare" while
changing the version in all of the pom.xml files it changes the version
inside the C project.
I just need a way to invoke a bash script with a 'sed' command that has the
new VERSION variable in a shell environment.
I can also write some java code or whatever else....

But I need some "hook" during release:prepare.

I can't find any documentation about this feature other then
"prepationGoals" but it is not documented and there is no good example on
the Internet
https://maven.apache.org/maven-release/maven-release-plugin/examples/run-goals-before-commit.html

Any idea or working example ?

Thanks
Enrico

Re: Hooks on mvn release:prepare

Posted by Robert Scholte <rf...@apache.org>.
It looks a bit like MRELEASE-798[1] and MRELEASE-962[2]
For the 3.0.0 already a lot of refactoring has been done, so it should be  
easier to add such a feature.
I haven't thought about the implementation details, only that some hook or  
extension should be able to become part of the release process.

Robert

[1] https://issues.apache.org/jira/browse/MRELEASE-798
[2] https://issues.apache.org/jira/browse/MRELEASE-962

On Thu, 03 Oct 2019 18:59:57 +0200, Enrico Olivelli <eo...@gmail.com>  
wrote:

> Il gio 3 ott 2019, 17:53 Anthony Whitford <an...@whitford.com> ha  
> scritto:
>
>> Wouldn’t it make more sense to hook into the generate-sources or
>> process-sources phase?
>>
>
> In this case I can't because C sources must be buildable even without  
> maven
>
>
> Enrico
>
>
>> I would also think that the need to do that token replacement to set the
>> version applies for any build — not just the release process.
>>
>>
>> > On Oct 3, 2019, at 8:13 AM, Enrico Olivelli <eo...@gmail.com>  
>> wrote:
>> >
>> > Hello,
>> > I am going to propose a new release procedure in Apache ZooKeeper  
>> project
>> > in the direction of using the Maven Release Plugin.
>> > Usually with the Maven Release Plugin you are performing to tasks:
>> >
>> > mvn release:prepare -> change version + create tag
>> > mvn release:perform  -> create final artifacts and deploy
>> >
>> > in the specific case of Apache ZooKeeper we have a C-client that
>> contains
>> > C sources under a mavenized project, so in src/c or something like  
>> that,
>> > not so important.
>> >
>> > The important fact is that I have the 'version' in pom.xml and in the  
>> C
>> > client (make/configure based build).
>> > I would like to introduce an hook that during "release:prepare" while
>> > changing the version in all of the pom.xml files it changes the  
>> version
>> > inside the C project.
>> > I just need a way to invoke a bash script with a 'sed' command that  
>> has
>> the
>> > new VERSION variable in a shell environment.
>> > I can also write some java code or whatever else....
>> >
>> > But I need some "hook" during release:prepare.
>> >
>> > I can't find any documentation about this feature other then
>> > "prepationGoals" but it is not documented and there is no good  
>> example on
>> > the Internet
>> >
>> https://maven.apache.org/maven-release/maven-release-plugin/examples/run-goals-before-commit.html
>> >
>> > Any idea or working example ?
>> >
>> > Thanks
>> > Enrico
>>
>>
>> ---------------------------------------------------------------------
>> 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: Hooks on mvn release:prepare

Posted by Enrico Olivelli <eo...@gmail.com>.
Il gio 3 ott 2019, 17:53 Anthony Whitford <an...@whitford.com> ha scritto:

> Wouldn’t it make more sense to hook into the generate-sources or
> process-sources phase?
>

In this case I can't because C sources must be buildable even without maven


Enrico


> I would also think that the need to do that token replacement to set the
> version applies for any build — not just the release process.
>
>
> > On Oct 3, 2019, at 8:13 AM, Enrico Olivelli <eo...@gmail.com> wrote:
> >
> > Hello,
> > I am going to propose a new release procedure in Apache ZooKeeper project
> > in the direction of using the Maven Release Plugin.
> > Usually with the Maven Release Plugin you are performing to tasks:
> >
> > mvn release:prepare -> change version + create tag
> > mvn release:perform  -> create final artifacts and deploy
> >
> > in the specific case of Apache ZooKeeper we have a C-client that
> contains
> > C sources under a mavenized project, so in src/c or something like that,
> > not so important.
> >
> > The important fact is that I have the 'version' in pom.xml and in the C
> > client (make/configure based build).
> > I would like to introduce an hook that during "release:prepare" while
> > changing the version in all of the pom.xml files it changes the version
> > inside the C project.
> > I just need a way to invoke a bash script with a 'sed' command that has
> the
> > new VERSION variable in a shell environment.
> > I can also write some java code or whatever else....
> >
> > But I need some "hook" during release:prepare.
> >
> > I can't find any documentation about this feature other then
> > "prepationGoals" but it is not documented and there is no good example on
> > the Internet
> >
> https://maven.apache.org/maven-release/maven-release-plugin/examples/run-goals-before-commit.html
> >
> > Any idea or working example ?
> >
> > Thanks
> > Enrico
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Hooks on mvn release:prepare

Posted by Anthony Whitford <an...@whitford.com>.
Wouldn’t it make more sense to hook into the generate-sources or process-sources phase?

I would also think that the need to do that token replacement to set the version applies for any build — not just the release process.


> On Oct 3, 2019, at 8:13 AM, Enrico Olivelli <eo...@gmail.com> wrote:
> 
> Hello,
> I am going to propose a new release procedure in Apache ZooKeeper project
> in the direction of using the Maven Release Plugin.
> Usually with the Maven Release Plugin you are performing to tasks:
> 
> mvn release:prepare -> change version + create tag
> mvn release:perform  -> create final artifacts and deploy
> 
> in the specific case of Apache ZooKeeper we have a C-client that  contains
> C sources under a mavenized project, so in src/c or something like that,
> not so important.
> 
> The important fact is that I have the 'version' in pom.xml and in the C
> client (make/configure based build).
> I would like to introduce an hook that during "release:prepare" while
> changing the version in all of the pom.xml files it changes the version
> inside the C project.
> I just need a way to invoke a bash script with a 'sed' command that has the
> new VERSION variable in a shell environment.
> I can also write some java code or whatever else....
> 
> But I need some "hook" during release:prepare.
> 
> I can't find any documentation about this feature other then
> "prepationGoals" but it is not documented and there is no good example on
> the Internet
> https://maven.apache.org/maven-release/maven-release-plugin/examples/run-goals-before-commit.html
> 
> Any idea or working example ?
> 
> Thanks
> Enrico


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


Re: Hooks on mvn release:prepare

Posted by Enrico Olivelli <eo...@gmail.com>.
Thank you Stephen,
I will try and check which of the two ideas works better

Enrico

Il giorno sab 2 nov 2019 alle ore 11:03 Stephen Connolly <
stephen.alan.connolly@gmail.com> ha scritto:

> Less hacky.
>
> Could you use an #include directory search order that puts a
> target/generated-sources/c first.
>
> If you build without Maven, that dir will be empty and version.h will be
> found from the regular source sir and say “a snapshot”
>
> If you build with Maven, Maven will populate the generated source with a
> concrete version.h that gets found first and presto!
>
> On Sat 2 Nov 2019 at 09:59, Stephen Connolly <
> stephen.alan.connolly@gmail.com> wrote:
>
> >
> >
> > On Thu 3 Oct 2019 at 16:13, Enrico Olivelli <eo...@gmail.com> wrote:
> >
> >> Hello,
> >> I am going to propose a new release procedure in Apache ZooKeeper
> project
> >> in the direction of using the Maven Release Plugin.
> >> Usually with the Maven Release Plugin you are performing to tasks:
> >>
> >> mvn release:prepare -> change version + create tag
> >> mvn release:perform  -> create final artifacts and deploy
> >>
> >> in the specific case of Apache ZooKeeper we have a C-client that
> contains
> >> C sources under a mavenized project, so in src/c or something like that,
> >> not so important.
> >>
> >> The important fact is that I have the 'version' in pom.xml and in the C
> >> client (make/configure based build).
> >> I would like to introduce an hook that during "release:prepare" while
> >> changing the version in all of the pom.xml files it changes the version
> >> inside the C project.
> >> I just need a way to invoke a bash script with a 'sed' command that has
> >> the
> >> new VERSION variable in a shell environment.
> >> I can also write some java code or whatever else....
> >>
> >> But I need some "hook" during release:prepare.
> >>
> >> I can't find any documentation about this feature other then
> >> "prepationGoals" but it is not documented and there is no good example
> on
> >> the Internet
> >>
> >>
> https://maven.apache.org/maven-release/maven-release-plugin/examples/run-goals-before-commit.html
> >>
> >> Any idea or working example ?
> >
> >
> > So if you are using GIT as your SCM, as long as you do `git add
> > name-of-file` after changing the file inside preparationGoals then it
> will
> > get committed with the pom.xml changes.
> >
> > A bit hacky, but works. My only use of it is closed source so cannot
> share
> >
> >
> >>
> >> Thanks
> >> Enrico
> >
> >
> >> --
> > Sent from my phone
> >
> --
> Sent from my phone
>

Re: Hooks on mvn release:prepare

Posted by Stephen Connolly <st...@gmail.com>.
Less hacky.

Could you use an #include directory search order that puts a
target/generated-sources/c first.

If you build without Maven, that dir will be empty and version.h will be
found from the regular source sir and say “a snapshot”

If you build with Maven, Maven will populate the generated source with a
concrete version.h that gets found first and presto!

On Sat 2 Nov 2019 at 09:59, Stephen Connolly <
stephen.alan.connolly@gmail.com> wrote:

>
>
> On Thu 3 Oct 2019 at 16:13, Enrico Olivelli <eo...@gmail.com> wrote:
>
>> Hello,
>> I am going to propose a new release procedure in Apache ZooKeeper project
>> in the direction of using the Maven Release Plugin.
>> Usually with the Maven Release Plugin you are performing to tasks:
>>
>> mvn release:prepare -> change version + create tag
>> mvn release:perform  -> create final artifacts and deploy
>>
>> in the specific case of Apache ZooKeeper we have a C-client that  contains
>> C sources under a mavenized project, so in src/c or something like that,
>> not so important.
>>
>> The important fact is that I have the 'version' in pom.xml and in the C
>> client (make/configure based build).
>> I would like to introduce an hook that during "release:prepare" while
>> changing the version in all of the pom.xml files it changes the version
>> inside the C project.
>> I just need a way to invoke a bash script with a 'sed' command that has
>> the
>> new VERSION variable in a shell environment.
>> I can also write some java code or whatever else....
>>
>> But I need some "hook" during release:prepare.
>>
>> I can't find any documentation about this feature other then
>> "prepationGoals" but it is not documented and there is no good example on
>> the Internet
>>
>> https://maven.apache.org/maven-release/maven-release-plugin/examples/run-goals-before-commit.html
>>
>> Any idea or working example ?
>
>
> So if you are using GIT as your SCM, as long as you do `git add
> name-of-file` after changing the file inside preparationGoals then it will
> get committed with the pom.xml changes.
>
> A bit hacky, but works. My only use of it is closed source so cannot share
>
>
>>
>> Thanks
>> Enrico
>
>
>> --
> Sent from my phone
>
-- 
Sent from my phone

Re: Hooks on mvn release:prepare

Posted by Enrico Olivelli <eo...@gmail.com>.
Hello,
this is my final working example, it is using preparationGoals and
completionGoals in order to alter files and the commit them.

https://github.com/eolivelli/testreleaseplugin

@Stephen Connolly <st...@gmail.com> I confirm you that a
'git commit' is really needed, "git add" is not enough, but using the Maven
SCM Plugin it very easy.

I feel that the Maven Release Plugin has already got all that is needed.

I will apply this practice to some real project then I will update the
Maven Release Plugin documentation with this example

Thank you so much !
Enrico

Il giorno sab 23 nov 2019 alle ore 17:32 Stephen Connolly <
stephen.alan.connolly@gmail.com> ha scritto:

> On Sat 23 Nov 2019 at 14:53, Enrico Olivelli <eo...@gmail.com> wrote:
>
> > Stephen
> >
> > Il sab 2 nov 2019, 11:00 Stephen Connolly <
> stephen.alan.connolly@gmail.com
> > >
> > ha scritto:
> >
> > > On Thu 3 Oct 2019 at 16:13, Enrico Olivelli <eo...@gmail.com>
> wrote:
> > >
> > > > Hello,
> > > > I am going to propose a new release procedure in Apache ZooKeeper
> > project
> > > > in the direction of using the Maven Release Plugin.
> > > > Usually with the Maven Release Plugin you are performing to tasks:
> > > >
> > > > mvn release:prepare -> change version + create tag
> > > > mvn release:perform  -> create final artifacts and deploy
> > > >
> > > > in the specific case of Apache ZooKeeper we have a C-client that
> > > contains
> > > > C sources under a mavenized project, so in src/c or something like
> > that,
> > > > not so important.
> > > >
> > > > The important fact is that I have the 'version' in pom.xml and in
> the C
> > > > client (make/configure based build).
> > > > I would like to introduce an hook that during "release:prepare" while
> > > > changing the version in all of the pom.xml files it changes the
> version
> > > > inside the C project.
> > > > I just need a way to invoke a bash script with a 'sed' command that
> has
> > > the
> > > > new VERSION variable in a shell environment.
> > > > I can also write some java code or whatever else....
> > > >
> > > > But I need some "hook" during release:prepare.
> > > >
> > > > I can't find any documentation about this feature other then
> > > > "prepationGoals" but it is not documented and there is no good
> example
> > on
> > > > the Internet
> > > >
> > > >
> > >
> >
> https://maven.apache.org/maven-release/maven-release-plugin/examples/run-goals-before-commit.html
> > > >
> > > > Any idea or working example ?
> > >
> > >
> > > So if you are using GIT as your SCM, as long as you do `git add
> > > name-of-file` after changing the file inside preparationGoals then it
> > will
> > > get committed with the pom.xml changes.
> > >
> >
> >
> > This approach actually works
> > This is a sample project
> > https://gitbub.com/eolivelli/testreleaseplugin
> >
> > The only remaining problem is the 'preparationGoals' come into play only
> > while preparing the release and not while bumping the version to the new
> > one
>
>
> I believe I added completionGoals for that purpose :-D
>
>
> >
> >
> > Thank you
> >
> > Enrico
> >
> >
> > > A bit hacky, but works. My only use of it is closed source so cannot
> > share
> > >
> > >
> > > >
> > > > Thanks
> > > > Enrico
> > > >
> > > --
> > > Sent from my phone
> > >
> >
> --
> Sent from my phone
>

Re: Hooks on mvn release:prepare

Posted by Stephen Connolly <st...@gmail.com>.
On Sat 23 Nov 2019 at 14:53, Enrico Olivelli <eo...@gmail.com> wrote:

> Stephen
>
> Il sab 2 nov 2019, 11:00 Stephen Connolly <stephen.alan.connolly@gmail.com
> >
> ha scritto:
>
> > On Thu 3 Oct 2019 at 16:13, Enrico Olivelli <eo...@gmail.com> wrote:
> >
> > > Hello,
> > > I am going to propose a new release procedure in Apache ZooKeeper
> project
> > > in the direction of using the Maven Release Plugin.
> > > Usually with the Maven Release Plugin you are performing to tasks:
> > >
> > > mvn release:prepare -> change version + create tag
> > > mvn release:perform  -> create final artifacts and deploy
> > >
> > > in the specific case of Apache ZooKeeper we have a C-client that
> > contains
> > > C sources under a mavenized project, so in src/c or something like
> that,
> > > not so important.
> > >
> > > The important fact is that I have the 'version' in pom.xml and in the C
> > > client (make/configure based build).
> > > I would like to introduce an hook that during "release:prepare" while
> > > changing the version in all of the pom.xml files it changes the version
> > > inside the C project.
> > > I just need a way to invoke a bash script with a 'sed' command that has
> > the
> > > new VERSION variable in a shell environment.
> > > I can also write some java code or whatever else....
> > >
> > > But I need some "hook" during release:prepare.
> > >
> > > I can't find any documentation about this feature other then
> > > "prepationGoals" but it is not documented and there is no good example
> on
> > > the Internet
> > >
> > >
> >
> https://maven.apache.org/maven-release/maven-release-plugin/examples/run-goals-before-commit.html
> > >
> > > Any idea or working example ?
> >
> >
> > So if you are using GIT as your SCM, as long as you do `git add
> > name-of-file` after changing the file inside preparationGoals then it
> will
> > get committed with the pom.xml changes.
> >
>
>
> This approach actually works
> This is a sample project
> https://gitbub.com/eolivelli/testreleaseplugin
>
> The only remaining problem is the 'preparationGoals' come into play only
> while preparing the release and not while bumping the version to the new
> one


I believe I added completionGoals for that purpose :-D


>
>
> Thank you
>
> Enrico
>
>
> > A bit hacky, but works. My only use of it is closed source so cannot
> share
> >
> >
> > >
> > > Thanks
> > > Enrico
> > >
> > --
> > Sent from my phone
> >
>
-- 
Sent from my phone

Re: Hooks on mvn release:prepare

Posted by Enrico Olivelli <eo...@gmail.com>.
Stephen

Il sab 2 nov 2019, 11:00 Stephen Connolly <st...@gmail.com>
ha scritto:

> On Thu 3 Oct 2019 at 16:13, Enrico Olivelli <eo...@gmail.com> wrote:
>
> > Hello,
> > I am going to propose a new release procedure in Apache ZooKeeper project
> > in the direction of using the Maven Release Plugin.
> > Usually with the Maven Release Plugin you are performing to tasks:
> >
> > mvn release:prepare -> change version + create tag
> > mvn release:perform  -> create final artifacts and deploy
> >
> > in the specific case of Apache ZooKeeper we have a C-client that
> contains
> > C sources under a mavenized project, so in src/c or something like that,
> > not so important.
> >
> > The important fact is that I have the 'version' in pom.xml and in the C
> > client (make/configure based build).
> > I would like to introduce an hook that during "release:prepare" while
> > changing the version in all of the pom.xml files it changes the version
> > inside the C project.
> > I just need a way to invoke a bash script with a 'sed' command that has
> the
> > new VERSION variable in a shell environment.
> > I can also write some java code or whatever else....
> >
> > But I need some "hook" during release:prepare.
> >
> > I can't find any documentation about this feature other then
> > "prepationGoals" but it is not documented and there is no good example on
> > the Internet
> >
> >
> https://maven.apache.org/maven-release/maven-release-plugin/examples/run-goals-before-commit.html
> >
> > Any idea or working example ?
>
>
> So if you are using GIT as your SCM, as long as you do `git add
> name-of-file` after changing the file inside preparationGoals then it will
> get committed with the pom.xml changes.
>


This approach actually works
This is a sample project
https://gitbub.com/eolivelli/testreleaseplugin

The only remaining problem is the 'preparationGoals' come into play only
while preparing the release and not while bumping the version to the next
one


Thank you

Enrico


> A bit hacky, but works. My only use of it is closed source so cannot share
>
>
> >
> > Thanks
> > Enrico
> >
> --
> Sent from my phone
>

Re: Hooks on mvn release:prepare

Posted by Stephen Connolly <st...@gmail.com>.
On Thu 3 Oct 2019 at 16:13, Enrico Olivelli <eo...@gmail.com> wrote:

> Hello,
> I am going to propose a new release procedure in Apache ZooKeeper project
> in the direction of using the Maven Release Plugin.
> Usually with the Maven Release Plugin you are performing to tasks:
>
> mvn release:prepare -> change version + create tag
> mvn release:perform  -> create final artifacts and deploy
>
> in the specific case of Apache ZooKeeper we have a C-client that  contains
> C sources under a mavenized project, so in src/c or something like that,
> not so important.
>
> The important fact is that I have the 'version' in pom.xml and in the C
> client (make/configure based build).
> I would like to introduce an hook that during "release:prepare" while
> changing the version in all of the pom.xml files it changes the version
> inside the C project.
> I just need a way to invoke a bash script with a 'sed' command that has the
> new VERSION variable in a shell environment.
> I can also write some java code or whatever else....
>
> But I need some "hook" during release:prepare.
>
> I can't find any documentation about this feature other then
> "prepationGoals" but it is not documented and there is no good example on
> the Internet
>
> https://maven.apache.org/maven-release/maven-release-plugin/examples/run-goals-before-commit.html
>
> Any idea or working example ?


So if you are using GIT as your SCM, as long as you do `git add
name-of-file` after changing the file inside preparationGoals then it will
get committed with the pom.xml changes.

A bit hacky, but works. My only use of it is closed source so cannot share


>
> Thanks
> Enrico
>
-- 
Sent from my phone