Skip to content

Commit

Permalink
Fixed #129
Browse files Browse the repository at this point in the history
 o Added processBoms option to dependency-update-report.
  • Loading branch information
khmarbaise committed Jun 17, 2017
1 parent 8215f10 commit 71903fe
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 2 deletions.
8 changes: 8 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## 2.5 (NOT YET RELEASED)

* [Fixed Issue 129][issue-129]

dependency-update-report now is able to
disable the processing of BOM (pom with scope import).
via processBoms. The default is true to
keep backward compatibillity.

* [Fixed Issue 166][issue-166]

Upgraded modello-maven-plugin to 1.9.1
Expand Down Expand Up @@ -47,6 +54,7 @@
[issue-37]: https://github.com/jenkinsci/java-client-api/issues/37
[issue-46]: https://github.com/jenkinsci/java-client-api/issues/46
[issue-94]: https://github.com/jenkinsci/java-client-api/issues/94
[issue-129]: https://github.com/jenkinsci/java-client-api/issues/129
[issue-162]: https://github.com/jenkinsci/java-client-api/issues/162
[issue-166]: https://github.com/jenkinsci/java-client-api/issues/166
[issue-167]: https://github.com/jenkinsci/java-client-api/issues/167
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.codehaus.mojo.versions;

import org.apache.commons.validator.GenericTypeValidator;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -23,6 +25,7 @@
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
Expand Down Expand Up @@ -58,6 +61,33 @@ public class DependencyUpdatesReport
@Parameter( property = "processDependencyManagement", defaultValue = "true" )
private boolean processDependencyManagement;

/**
* Whether to process the so called <b>BOM</b> (Bill Of Material) or not. These are dependencies in the
* dependencyManagement block with <code>&lt;type&gt;pom&lt;/type&gt;</code>and
* <code>&lt;scope&gt;import&lt;/scope&gt;</code>.
*
* <pre>
* &lt;dependencyManagement&gt;
* &lt;dependencies&gt;
* &lt;dependency&gt;
* &lt;groupId&gt;xxxxx&lt;/groupId&gt;
* &lt;artifactId&gt;yyyyy&lt;/artifactId&gt;
* &lt;version&gt;1.0.0&lt;/version&gt;
* &lt;type&gt;pom&lt;/type&gt;
* &lt;scope&gt;import&lt;/scope&gt;
* &lt;/dependency&gt;
* &lt;dependency&gt;
* ..
* &lt;/dependency&gt;
* &lt;/dependencies&gt;
* &lt;/dependencyManagement&gt;
* </pre>
*
* @since 2.5 Note: Currently in experimental state.
*/
@Parameter( property = "processBoms", defaultValue = "true" )
private boolean processBoms;

/**
* Report formats (html and/or xml). HTML by default.
*
Expand Down Expand Up @@ -94,8 +124,37 @@ protected void doGenerateReport( Locale locale, Sink sink )
dependencies.addAll( getProject().getDependencies() );

Set dependencyManagement = new TreeSet( new DependencyComparator() );
dependencyManagement.addAll( getProject().getDependencyManagement() == null ? Collections.emptySet()
: getProject().getDependencyManagement().getDependencies() );

if ( processBoms )
{
if ( getProject().getDependencyManagement() != null
&& getProject().getDependencyManagement().getDependencies() != null )
{
for ( Dependency dep : getProject().getDependencyManagement().getDependencies() )
{
getLog().debug( "Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getVersion()
+ ":" + dep.getType() + ":" + dep.getScope() );
}
dependencyManagement.addAll( getProject().getDependencyManagement().getDependencies() );
}
}
else
{
if ( getProject().getOriginalModel().getDependencyManagement() != null
&& getProject().getOriginalModel().getDependencyManagement().getDependencies() != null )
{
// Using the original model to get the original dependencyManagement entries and
// not the interpolated model.
// TODO: I'm not 100% sure if this will work correctly in all cases.
for ( Dependency dep : getProject().getOriginalModel().getDependencyManagement().getDependencies() )
{
getLog().debug( "Original Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":"
+ dep.getVersion() + ":" + dep.getType() + ":" + dep.getScope() );
}
dependencyManagement.addAll( getProject().getOriginalModel().getDependencyManagement().getDependencies() );

}
}

if ( processDependencyManagement )
{
Expand Down

0 comments on commit 71903fe

Please sign in to comment.