You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Kevin Burton <bu...@spinn3r.com> on 2015/04/07 05:18:30 UTC

Computing the maven dependency graph at runtime for unit tests?

I have a few modules that I want to lock down so that I can easily keep
track of dependencies over time.

This way if a developer adds a new dependency, the test will immediately
break and someone will have to approve the change.

Is this possible? Could I embed this in a unit test or does it have to be a
plugin?  ideally something easy…

-- 

Founder/CEO Spinn3r.com
Location: *San Francisco, CA*
blog: http://burtonator.wordpress.com
… or check out my Google+ profile
<https://plus.google.com/102718274791889610666/posts>
<http://spinn3r.com>

Re: Computing the maven dependency graph at runtime for unit tests?

Posted by Alexander Kriegisch <Al...@Kriegisch.name>.
Sorry for the monologue, but here is another idea: Run a regular Jenkins Job which does a 'diff' on a pre-recorded vs. live output of 'mvn dependency:tree' for the modules in question and fails the build based on the result, sending an e-mail to whoever needs to approve of the changes.
-- 
Alexander Kriegisch
http://scrum-master.de


> Am 07.04.2015 um 06:13 schrieb Alexander Kriegisch <Al...@Kriegisch.name>:
> 
> I forgot to mention that keeping this check in a unit test is probably not very reliable anyway if you have good developers in your team. A good developer refactors test code along with the production code. ;-)
> -- 
> Alexander Kriegisch
> 
> 
>> Am 07.04.2015 um 06:08 schrieb Alexander Kriegisch <Al...@Kriegisch.name>:
>> 
>> Quick and dirty? Keep a SHA-1 checksum of the pom in your unit test and compute it. You can also grep the dependencies section and normalise whitespace first. This would not be stable against change of order or refactoring using properties for version numbers etc., but you wanted something easy. ;-)
>> -- 
>> Alexander Kriegisch
>> 
>> 
>>> Am 07.04.2015 um 05:18 schrieb Kevin Burton <bu...@spinn3r.com>:
>>> 
>>> I have a few modules that I want to lock down so that I can easily keep
>>> track of dependencies over time.
>>> 
>>> This way if a developer adds a new dependency, the test will immediately
>>> break and someone will have to approve the change.
>>> 
>>> Is this possible? Could I embed this in a unit test or does it have to be a
>>> plugin?  ideally something easy…
>>> 
>>> -- 
>>> 
>>> Founder/CEO Spinn3r.com
>>> Location: *San Francisco, CA*
>>> blog: http://burtonator.wordpress.com
>>> … or check out my Google+ profile
>>> <https://plus.google.com/102718274791889610666/posts>
>>> <http://spinn3r.com>
>> 
>> ---------------------------------------------------------------------
>> 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

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


Re: Computing the maven dependency graph at runtime for unit tests?

Posted by Alexander Kriegisch <Al...@Kriegisch.name>.
I forgot to mention that keeping this check in a unit test is probably not very reliable anyway if you have good developers in your team. A good developer refactors test code along with the production code. ;-)
-- 
Alexander Kriegisch


> Am 07.04.2015 um 06:08 schrieb Alexander Kriegisch <Al...@Kriegisch.name>:
> 
> Quick and dirty? Keep a SHA-1 checksum of the pom in your unit test and compute it. You can also grep the dependencies section and normalise whitespace first. This would not be stable against change of order or refactoring using properties for version numbers etc., but you wanted something easy. ;-)
> -- 
> Alexander Kriegisch
> 
> 
>> Am 07.04.2015 um 05:18 schrieb Kevin Burton <bu...@spinn3r.com>:
>> 
>> I have a few modules that I want to lock down so that I can easily keep
>> track of dependencies over time.
>> 
>> This way if a developer adds a new dependency, the test will immediately
>> break and someone will have to approve the change.
>> 
>> Is this possible? Could I embed this in a unit test or does it have to be a
>> plugin?  ideally something easy…
>> 
>> -- 
>> 
>> Founder/CEO Spinn3r.com
>> Location: *San Francisco, CA*
>> blog: http://burtonator.wordpress.com
>> … or check out my Google+ profile
>> <https://plus.google.com/102718274791889610666/posts>
>> <http://spinn3r.com>
> 
> ---------------------------------------------------------------------
> 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: Computing the maven dependency graph at runtime for unit tests?

Posted by Alexander Kriegisch <Al...@Kriegisch.name>.
Quick and dirty? Keep a SHA-1 checksum of the pom in your unit test and compute it. You can also grep the dependencies section and normalise whitespace first. This would not be stable against change of order or refactoring using properties for version numbers etc., but you wanted something easy. ;-)
-- 
Alexander Kriegisch


> Am 07.04.2015 um 05:18 schrieb Kevin Burton <bu...@spinn3r.com>:
> 
> I have a few modules that I want to lock down so that I can easily keep
> track of dependencies over time.
> 
> This way if a developer adds a new dependency, the test will immediately
> break and someone will have to approve the change.
> 
> Is this possible? Could I embed this in a unit test or does it have to be a
> plugin?  ideally something easy…
> 
> -- 
> 
> Founder/CEO Spinn3r.com
> Location: *San Francisco, CA*
> blog: http://burtonator.wordpress.com
> … or check out my Google+ profile
> <https://plus.google.com/102718274791889610666/posts>
> <http://spinn3r.com>

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


Re: Computing the maven dependency graph at runtime for unit tests?

Posted by Ron Wheeler <rw...@artifact-software.com>.
http://blog.artifact-software.com/tech/?p=121 is how we deal with this.
At he beginning of each release cycle we review the versions of the 
third party libraries that we use and update the dependencies in our 
aggregation projects.

Our application modules depend on the current version of the aggregation 
projects so developers can not change the version of a third-party 
library without changing an aggregation project which they are not 
allowed to do without the project manager's approval.
If a new library has to be added to support a new feature, this requires 
a review by the project team.

This makes everyone's life a lot simpler.
Our application projects only have a few dependencies even if we use 
dozens of Apache product as well as a few from other providers.

This also makes testing and QA a lot easier since if something stops 
working, you can be sure that it is not a third-party library getting 
changed by another developer.

We have not had to automate the enforcement of this policy.
However, we do have an SCM with history and I would know who to beat on 
if someone did an unauthorized upgrade.

Ron

On 07/04/2015 2:26 AM, Karl Heinz Marbaise wrote:
> Hi Kevin,
>
> On 4/7/15 5:18 AM, Kevin Burton wrote:
>> I have a few modules that I want to lock down so that I can easily keep
>> track of dependencies over time.
>>
>> This way if a developer adds a new dependency, the test will immediately
>> break and someone will have to approve the change.
>
> Can you explain a little bit more what you like to achieve, cause i'm 
> a little bit puzzled that you have unit tests which checks 
> dependencies...?
>
>>
>> Is this possible? Could I embed this in a unit test or does it have 
>> to be a
>> plugin?  ideally something easy…
>>
>
>
> Kind regards
> Karl Heinz Marbaise
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Ron Wheeler
President
Artifact Software Inc
email: rwheeler@artifact-software.com
skype: ronaldmwheeler
phone: 866-970-2435, ext 102


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


Re: Computing the maven dependency graph at runtime for unit tests?

Posted by Jochen Wiedmann <jo...@gmail.com>.
I'd use dependency:list in conjunction with outputFile to create a
temporary file, which contains the list of dependencies. That
temporary file can be compared with a static file. If they have the
same contents, the test passes.

Jochen


On Tue, Apr 7, 2015 at 8:26 AM, Karl Heinz Marbaise <kh...@gmx.de> wrote:
> Hi Kevin,
>
> On 4/7/15 5:18 AM, Kevin Burton wrote:
>>
>> I have a few modules that I want to lock down so that I can easily keep
>> track of dependencies over time.
>>
>> This way if a developer adds a new dependency, the test will immediately
>> break and someone will have to approve the change.
>
>
> Can you explain a little bit more what you like to achieve, cause i'm a
> little bit puzzled that you have unit tests which checks dependencies...?
>
>>
>> Is this possible? Could I embed this in a unit test or does it have to be
>> a
>> plugin?  ideally something easy…
>>
>
>
> Kind regards
> Karl Heinz Marbaise
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>



-- 
Any world that can produce the Taj Mahal, William Shakespeare,
and Stripe toothpaste can't be all bad. (C.R. MacNamara, One Two Three)

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


Re: Computing the maven dependency graph at runtime for unit tests?

Posted by Karl Heinz Marbaise <kh...@gmx.de>.
Hi Kevin,

On 4/7/15 5:18 AM, Kevin Burton wrote:
> I have a few modules that I want to lock down so that I can easily keep
> track of dependencies over time.
>
> This way if a developer adds a new dependency, the test will immediately
> break and someone will have to approve the change.

Can you explain a little bit more what you like to achieve, cause i'm a 
little bit puzzled that you have unit tests which checks dependencies...?

>
> Is this possible? Could I embed this in a unit test or does it have to be a
> plugin?  ideally something easy…
>


Kind regards
Karl Heinz Marbaise

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