A maven plugin to add dynamically a repository at build time

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

A maven plugin to add dynamically a repository at build time

Nicolas Brasey
Hi,

In my continuous integration solution, I need to have a maven repository
which is calculated based on the git branch name. For example, I have a
naming convention which is used to calculate the maven repo URL, something
similar to this:

Branch name     -> Git Repo URL:
-------------------     ---------------------
develop         -> http://archiva/repositories/snapshot
feature/xxx     -> http://archiva/repositories/feature-xxx
staging/xxx     -> http://archiva/repositories/staging-xxx


I wrote a maven plugin that adds dynamically a repository in my project but
unfortunately, my plugin is not invoked before maven performs the
dependency resolution.

I googled it and tried some workaround proposed (like putting my plugin in
the pre-clean phase), but it still executes after the dependency resolution.

You guys ever tried this?

Thanks,
Nicolas
Reply | Threaded
Open this post in threaded view
|

RE: A maven plugin to add dynamically a repository at build time

Golan, Yaron
Hi,

Here is my proposal...

Inside your main/parent pom.xml, set the following:

<project>
        ...
        <properties>
                <repo.name>foo</repo.name>
                <repo.url>boo</repo.url>
        </properties>
       
        <repositories>
                <repository>
                        <id>${repo.name}</id>
                        <url>${repo.url}</url>
                </repository>
        </repositories>
        ...
</project>


And your maven command should like:
mvn <whatever phase> -Drepo.name=some.repo.name -Drepo.url=relevant.url


What do you say?

YG




-----Original Message-----
From: Nicolas Brasey [mailto:[hidden email]]
Sent: Monday, April 09, 2018 20:41
To: [hidden email]
Subject: A maven plugin to add dynamically a repository at build time

Hi,

In my continuous integration solution, I need to have a maven repository which is calculated based on the git branch name. For example, I have a naming convention which is used to calculate the maven repo URL, something similar to this:

Branch name     -> Git Repo URL:
-------------------     ---------------------
develop         -> https://urldefense.proofpoint.com/v2/url?u=http-3A__archiva_repositories_snapshot&d=DwIBaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=GYb_8qONFTPgVpTfZRT53aEptjaOm6sDrruaOwiowLQ&m=wYKDMhCmuL6gf7KPllHND78qrm6EwCIeSTQMt6cv268&s=YFvvW16iOsJQtkao0hwVmS33Rh07ba1sfucC1yHSwFI&e= 
feature/xxx     -> https://urldefense.proofpoint.com/v2/url?u=http-3A__archiva_repositories_feature-2Dxxx&d=DwIBaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=GYb_8qONFTPgVpTfZRT53aEptjaOm6sDrruaOwiowLQ&m=wYKDMhCmuL6gf7KPllHND78qrm6EwCIeSTQMt6cv268&s=tUqew2vcZMbgd3HbH8wWGoTp_v94pBrDATIHUCug8jw&e= 
staging/xxx     -> https://urldefense.proofpoint.com/v2/url?u=http-3A__archiva_repositories_staging-2Dxxx&d=DwIBaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=GYb_8qONFTPgVpTfZRT53aEptjaOm6sDrruaOwiowLQ&m=wYKDMhCmuL6gf7KPllHND78qrm6EwCIeSTQMt6cv268&s=KXqHxpLtHwoU86yY9ySm1QrSBtaoN7lsraCeF6DW9dw&e= 


I wrote a maven plugin that adds dynamically a repository in my project but unfortunately, my plugin is not invoked before maven performs the dependency resolution.

I googled it and tried some workaround proposed (like putting my plugin in the pre-clean phase), but it still executes after the dependency resolution.

You guys ever tried this?

Thanks,
Nicolas

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: A maven plugin to add dynamically a repository at build time

Nicolas Brasey
Hi Yolan,

Thanks for your input.

Yes, what you proposed is what I use at the moment as a workaround. But I
wanted to hide the branch selection logic from the build runner.

I suppose there is no real solution to hook code in maven before even the
dependencies resolution? Is there another API besides the maven plugin
API which allows me for example to extend the default MavenArtifact
resolver?

Nicolas






On Tue, Apr 10, 2018 at 7:22 AM, Golan, Yaron <[hidden email]> wrote:

> Hi,
>
> Here is my proposal...
>
> Inside your main/parent pom.xml, set the following:
>
> <project>
>         ...
>         <properties>
>                 <repo.name>foo</repo.name>
>                 <repo.url>boo</repo.url>
>         </properties>
>
>         <repositories>
>                 <repository>
>                         <id>${repo.name}</id>
>                         <url>${repo.url}</url>
>                 </repository>
>         </repositories>
>         ...
> </project>
>
>
> And your maven command should like:
> mvn <whatever phase> -Drepo.name=some.repo.name -Drepo.url=relevant.url
>
>
> What do you say?
>
> YG
>
>
>
>
> -----Original Message-----
> From: Nicolas Brasey [mailto:[hidden email]]
> Sent: Monday, April 09, 2018 20:41
> To: [hidden email]
> Subject: A maven plugin to add dynamically a repository at build time
>
> Hi,
>
> In my continuous integration solution, I need to have a maven repository
> which is calculated based on the git branch name. For example, I have a
> naming convention which is used to calculate the maven repo URL, something
> similar to this:
>
> Branch name     -> Git Repo URL:
> -------------------     ---------------------
> develop         -> https://urldefense.proofpoint.
> com/v2/url?u=http-3A__archiva_repositories_snapshot&d=DwIBaQ&c=LFYZ-o9_
> HUMeMTSQicvjIg&r=GYb_8qONFTPgVpTfZRT53aEptjaOm6sDrruaOwiowLQ&m=
> wYKDMhCmuL6gf7KPllHND78qrm6EwCIeSTQMt6cv268&s=
> YFvvW16iOsJQtkao0hwVmS33Rh07ba1sfucC1yHSwFI&e=
> feature/xxx     -> https://urldefense.proofpoint.
> com/v2/url?u=http-3A__archiva_repositories_feature-2Dxxx&d=
> DwIBaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=GYb_8qONFTPgVpTfZRT53aEptjaOm6sDrr
> uaOwiowLQ&m=wYKDMhCmuL6gf7KPllHND78qrm6EwCIeSTQMt6cv268&s=
> tUqew2vcZMbgd3HbH8wWGoTp_v94pBrDATIHUCug8jw&e=
> staging/xxx     -> https://urldefense.proofpoint.
> com/v2/url?u=http-3A__archiva_repositories_staging-2Dxxx&d=
> DwIBaQ&c=LFYZ-o9_HUMeMTSQicvjIg&r=GYb_8qONFTPgVpTfZRT53aEptjaOm6sDrr
> uaOwiowLQ&m=wYKDMhCmuL6gf7KPllHND78qrm6EwCIeSTQMt6cv268&s=
> KXqHxpLtHwoU86yY9ySm1QrSBtaoN7lsraCeF6DW9dw&e=
>
>
> I wrote a maven plugin that adds dynamically a repository in my project
> but unfortunately, my plugin is not invoked before maven performs the
> dependency resolution.
>
> I googled it and tried some workaround proposed (like putting my plugin in
> the pre-clean phase), but it still executes after the dependency resolution.
>
> You guys ever tried this?
>
> Thanks,
> Nicolas
>