Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump mrm-maven-plugin from 1.2.0 to 1.5.0 #18

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ under the License.
</parent>

<artifactId>maven-dependency-plugin</artifactId>
<version>3.2.1-SNAPSHOT</version>
<version>3.2.1-disy-2</version>
<packaging>maven-plugin</packaging>

<name>Apache Maven Dependency Plugin</name>
Expand All @@ -40,12 +40,14 @@ under the License.
<maven>${mavenVersion}</maven>
</prerequisites>

<!--
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git</developerConnection>
<url>https://github.com/apache/maven-dependency-plugin/tree/${project.scm.tag}</url>
<tag>HEAD</tag>
</scm>
-->
<issueManagement>
<system>JIRA</system>
<url>https://issues.apache.org/jira/browse/MDEP</url>
Expand All @@ -54,12 +56,14 @@ under the License.
<system>Jenkins</system>
<url>https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-dependency-plugin/</url>
</ciManagement>
<!--
<distributionManagement>
<site>
<id>apache.website</id>
<url>scm:svn:https://svn.apache.org/repos/asf/maven/website/components/${maven.site.path}</url>
</site>
</distributionManagement>
-->

<contributors>
<contributor>
Expand Down Expand Up @@ -227,7 +231,7 @@ under the License.
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-dependency-analyzer</artifactId>
<version>1.11.3</version>
<version>1.12.0-disy-1</version>
<exclusions>
<exclusion>
<artifactId>maven-project</artifactId>
Expand Down Expand Up @@ -511,7 +515,7 @@ under the License.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>mrm-maven-plugin</artifactId>
<version>1.2.0</version>
<version>1.5.0</version>
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ public abstract class AbstractAnalyzeMojo
@Parameter( property = "outputXML", defaultValue = "false" )
private boolean outputXML;

/**
* Output the xml for the missing dependencies (used but not declared).
*/
@Parameter( property = "outputJSON", defaultValue = "false" )
private boolean outputJSON;

/**
* Output scriptable values for the missing dependencies (used but not declared).
*
Expand Down Expand Up @@ -222,6 +228,9 @@ public abstract class AbstractAnalyzeMojo
@Parameter
private String[] ignoredUnusedDeclaredDependencies = new String[0];

@Parameter
private String[] ignoredCompileScopedUsedOnlyInTestsDependencies = new String[0];

/**
* List of project packaging that will be ignored.
* <br/>
Expand Down Expand Up @@ -277,7 +286,7 @@ protected ProjectDependencyAnalyzer createProjectDependencyAnalyzer()
throws MojoExecutionException
{

final String role = ProjectDependencyAnalyzer.ROLE;
final String role = ProjectDependencyAnalyzer.class.getName();
final String roleHint = analyzer;

try
Expand Down Expand Up @@ -353,6 +362,8 @@ private boolean checkDependencies()
ignoredUnusedDeclared.addAll( filterDependencies( unusedDeclared, ignoredDependencies ) );
ignoredUnusedDeclared.addAll( filterDependencies( unusedDeclared, ignoredUnusedDeclaredDependencies ) );

filterDependencies( testArtifactsWithNonTestScope, ignoredCompileScopedUsedOnlyInTestsDependencies );

boolean reported = false;
boolean warning = false;

Expand Down Expand Up @@ -412,6 +423,11 @@ private boolean checkDependencies()
writeDependencyXML( usedUndeclared );
}

if ( outputJSON )
{
writeDependencyJSON( usedUndeclared, unusedDeclared, testArtifactsWithNonTestScope );
}

if ( scriptableOutput )
{
writeScriptableOutput( usedUndeclared );
Expand Down Expand Up @@ -500,6 +516,64 @@ private void writeDependencyXML( Set<Artifact> artifacts )
}
}

private String joinArtifacts( List<Artifact> artifacts )
{
StringBuffer sb = new StringBuffer();
for ( int i = 0; i < artifacts.size(); i++ )
{
if ( i != 0 )
{
sb.append( ", " );
}
Artifact artifact = artifacts.get( i );
sb.append( artifact.getGroupId() + ":" + artifact.getArtifactId() );
}
return sb.toString();
}

private void writeDependencyJSON(
Set<Artifact> usedUndeclared,
Set<Artifact> unusedDeclared,
Set<Artifact> testArtifactsWithNonTestScope
)
{
if ( !usedUndeclared.isEmpty() || !unusedDeclared.isEmpty() || !testArtifactsWithNonTestScope.isEmpty() )
{
StringBuilder buf = new StringBuilder();

buf.append( "{dependencyIssues:\"true\", " );
buf.append( "originModule: \"" + project.getGroupId() + ":" + project.getArtifactId() + "\", " );
if ( !usedUndeclared.isEmpty() )
{
buf.append( "usedUndeclared: [" );
buf.append( joinArtifacts( new ArrayList<>( usedUndeclared ) ) );
buf.append( "]" );
}
if ( !unusedDeclared.isEmpty() )
{
if ( !usedUndeclared.isEmpty() )
{
buf.append( ", " );
}
buf.append( "unusedDeclared: [" );
buf.append( joinArtifacts( new ArrayList<>( unusedDeclared ) ) );
buf.append( "]" );
}
if ( !testArtifactsWithNonTestScope.isEmpty() )
{
if ( !usedUndeclared.isEmpty() || !unusedDeclared.isEmpty() )
{
buf.append( ", " );
}
buf.append( "testOnlyWithNonTestScope: [" );
buf.append( joinArtifacts( new ArrayList<>( testArtifactsWithNonTestScope ) ) );
buf.append( "]" );
}
buf.append( "}" );
getLog().warn( buf.toString() );
}
}

private void writeScriptableOutput( Set<Artifact> artifacts )
{
if ( !artifacts.isEmpty() )
Expand Down