You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by James Green <ja...@gmail.com> on 2014/05/09 16:02:10 UTC

Sharing of values across dependant projects?

I have two projects - A and B. B depends on A.

A is built with a number (call it a build number). B needs to which number
is in A at the time B builds.

Any ideas how to achieve this without any human intervention?

FWIW the use case here is that A is software distributed by B (a WAR
archive). A queries B for an updated build number, thus implementing
"automatic updates". I'm trying to automate the setting of this number
across the two projects but I've drawn a blank inside Jenkins for the
moment.

James

Re: Sharing of values across dependant projects?

Posted by Bernd Eckenfels <ec...@zusammenkunft.net>.
Is A released after each built-number change or is it a snapshot? In the snapshot case you can add a snapshot dependency and then see the number in the classpath. Maven will find the latest updates. If you make a release I guess it is easier to use a built parameter passed by Jenkins to both projects in a Pipeline. (Or to actually commit changes to version control, hard to say without details).

You could also use the versions-plugin to programmatically bump the dependency version in project B and then run a second maven invocation to build it.

Gruss
Bernd

> Am 09.05.2014 um 16:02 schrieb James Green <ja...@gmail.com>:
> 
> I have two projects - A and B. B depends on A.
> 
> A is built with a number (call it a build number). B needs to which number
> is in A at the time B builds.
> 
> Any ideas how to achieve this without any human intervention?
> 
> FWIW the use case here is that A is software distributed by B (a WAR
> archive). A queries B for an updated build number, thus implementing
> "automatic updates". I'm trying to automate the setting of this number
> across the two projects but I've drawn a blank inside Jenkins for the
> moment.
> 
> James

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


Re: Sharing of values across dependant projects?

Posted by Curtis Rueden <ct...@wisc.edu>.
Hi James,

> I have two projects - A and B. B depends on A.
>
> A is built with a number (call it a build number). B needs to which number
> is in A at the time B builds.
>
> Any ideas how to achieve this without any human intervention?

For B to query A at *runtime* of B: embed your build numbers in the JAR
manifest.

With the buildnumber-maven-plugin, it's something like this:
https://github.com/scijava/pom-scijava/blob/69b3520e486b2a3d65636833efe230b00f3ea78f/pom.xml#L680
And this:
https://github.com/scijava/pom-scijava/blob/69b3520e486b2a3d65636833efe230b00f3ea78f/pom.xml#L567

Then you can extract the version information out the manifest using Java's
built-in API:
http://docs.oracle.com/javase/7/docs/api/java/util/jar/JarFile.html#getManifest()
http://docs.oracle.com/javase/7/docs/api/index.html?java/util/jar/Manifest.html

To query A at B's *build* time as you request -- i.e., for your Jenkins job
that builds B to query the version of A, to decide whether to even build --
you could use the Jenkins Groovy plugin with the "Poll with a Groovy
script" ScriptTrigger that checks whether the build number changed since
the last build, using the above approach...

But is there some reason it's not good enough to simply have B's build be a
downstream job of A's build?

Regards,
Curtis


On Fri, May 9, 2014 at 9:02 AM, James Green <ja...@gmail.com>wrote:

> I have two projects - A and B. B depends on A.
>
> A is built with a number (call it a build number). B needs to which number
> is in A at the time B builds.
>
> Any ideas how to achieve this without any human intervention?
>
> FWIW the use case here is that A is software distributed by B (a WAR
> archive). A queries B for an updated build number, thus implementing
> "automatic updates". I'm trying to automate the setting of this number
> across the two projects but I've drawn a blank inside Jenkins for the
> moment.
>
> James
>

Re: Sharing of values across dependant projects?

Posted by Paul Benedict <pb...@apache.org>.
SNAPSHOTS are built for this use case. As long as B is in SNAPSHOT mode, A
can continue pulling the latest.


Cheers,
Paul


On Fri, May 9, 2014 at 9:02 AM, James Green <ja...@gmail.com>wrote:

> I have two projects - A and B. B depends on A.
>
> A is built with a number (call it a build number). B needs to which number
> is in A at the time B builds.
>
> Any ideas how to achieve this without any human intervention?
>
> FWIW the use case here is that A is software distributed by B (a WAR
> archive). A queries B for an updated build number, thus implementing
> "automatic updates". I'm trying to automate the setting of this number
> across the two projects but I've drawn a blank inside Jenkins for the
> moment.
>
> James
>

Re: Sharing of values across dependant projects?

Posted by Dan Tran <da...@gmail.com>.
possible ideas:

1. use templating-maven-plugin to copy resource across

2. place the resource into a file and deploy/install as a classifier to be
consumed by B using maven-dependency-plugin

-D


On Fri, May 9, 2014 at 7:02 AM, James Green <ja...@gmail.com>wrote:

> I have two projects - A and B. B depends on A.
>
> A is built with a number (call it a build number). B needs to which number
> is in A at the time B builds.
>
> Any ideas how to achieve this without any human intervention?
>
> FWIW the use case here is that A is software distributed by B (a WAR
> archive). A queries B for an updated build number, thus implementing
> "automatic updates". I'm trying to automate the setting of this number
> across the two projects but I've drawn a blank inside Jenkins for the
> moment.
>
> James
>