Author: rfscholte Date: Fri Aug 4 15:40:19 2017 New Revision: 1804137 URL: http://svn.apache.org/viewvc?rev=1804137&view=rev Log: [MDEP-578] Add message in case module name cannot be extracted from jar.
Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/invoker.properties maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/pom.xml maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/verify.groovy maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyStatusSets.java Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/invoker.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/invoker.properties?rev=1804137&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/invoker.properties (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/invoker.properties Fri Aug 4 15:40:19 2017 @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +invoker.java.version = 9+ +invoker.goals = dependency:resolve Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/pom.xml?rev=1804137&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/pom.xml (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/pom.xml Fri Aug 4 15:40:19 2017 @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>mdep-578</artifactId> + <version>1.0</version> + + <dependencies> + <dependency> + <groupId>jdom</groupId> + <artifactId>jdom</artifactId> + <version>1.0</version> + </dependency> + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-jta_1.1_spec</artifactId> + <version>1.1</version> + </dependency> + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-servlet_2.4_spec</artifactId> + <version>1.1.1</version> + </dependency> + </dependencies> +</project> Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/verify.groovy URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/verify.groovy?rev=1804137&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/verify.groovy (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-578_display-reason-invalid-module/verify.groovy Fri Aug 4 15:40:19 2017 @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +File file = new File( basedir, "build.log" ); +assert file.exists(); + +String buildLog = file.getText( "UTF-8" ); + +// Cause message is JDK specific and can change over time + +// JDOMAbout$Author.class found in top-level directory (unnamed package not allowed in module) +assert buildLog.contains( "Can't get module name from jdom-1.0.jar: " ); + +// geronimo.servlet.2.4.spec: Invalid module name: '2' is not a Java identifier +assert buildLog.contains( "Can't get module name from geronimo-servlet_2.4_spec-1.1.1.jar: " ); + +// geronimo.jta.1.1.spec: Invalid module name: '1' is not a Java identifier +assert buildLog.contains( "Can't get module name from geronimo-jta_1.1_spec-1.1.jar: " ); + +return true; Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java?rev=1804137&r1=1804136&r2=1804137&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java Fri Aug 4 15:40:19 2017 @@ -19,6 +19,8 @@ package org.apache.maven.plugins.depende * under the License. */ +import org.apache.maven.artifact.Artifact; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; import org.apache.maven.plugins.dependency.utils.DependencyUtil; @@ -30,7 +32,15 @@ import org.apache.maven.plugins.annotati import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; +import java.io.File; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; /** * Goal that resolves the project dependencies from the repository. @@ -88,7 +98,7 @@ public class ResolveDependenciesMojo // get sets of dependencies results = this.getDependencySets( false, includeParents ); - String output = results.getOutput( outputAbsoluteArtifactFilename, outputScope, sort ); + String output = getOutput( outputAbsoluteArtifactFilename, outputScope, sort ); try { if ( outputFile == null ) @@ -119,4 +129,178 @@ public class ResolveDependenciesMojo { return new ResolveFileFilter( new SourcesFileMarkerHandler( this.markersDirectory ) ); } + + public String getOutput( boolean outputAbsoluteArtifactFilename, boolean outputScope, boolean sort ) + { + StringBuilder sb = new StringBuilder(); + sb.append( "\n" ); + sb.append( "The following files have been resolved:\n" ); + if ( results.getResolvedDependencies() == null || results.getResolvedDependencies().isEmpty() ) + { + sb.append( " none\n" ); + } + else + { + sb.append( buildArtifactListOutput( results.getResolvedDependencies(), outputAbsoluteArtifactFilename, + outputScope, sort ) ); + } + + if ( results.getSkippedDependencies() != null && !results.getSkippedDependencies().isEmpty() ) + { + sb.append( "\n" ); + sb.append( "The following files were skipped:\n" ); + Set<Artifact> skippedDependencies = new LinkedHashSet<Artifact>(); + skippedDependencies.addAll( results.getSkippedDependencies() ); + sb.append( buildArtifactListOutput( skippedDependencies, outputAbsoluteArtifactFilename, + outputScope, sort ) ); + } + + if ( results.getUnResolvedDependencies() != null && !results.getUnResolvedDependencies().isEmpty() ) + { + sb.append( "\n" ); + sb.append( "The following files have NOT been resolved:\n" ); + Set<Artifact> unResolvedDependencies = new LinkedHashSet<Artifact>(); + unResolvedDependencies.addAll( results.getUnResolvedDependencies() ); + sb.append( buildArtifactListOutput( unResolvedDependencies, outputAbsoluteArtifactFilename, + outputScope, sort ) ); + } + sb.append( "\n" ); + + return sb.toString(); + } + + private StringBuilder buildArtifactListOutput( Set<Artifact> artifacts, boolean outputAbsoluteArtifactFilename, + boolean outputScope, boolean sort ) + { + StringBuilder sb = new StringBuilder(); + List<String> artifactStringList = new ArrayList<String>(); + for ( Artifact artifact : artifacts ) + { + String artifactFilename = null; + if ( outputAbsoluteArtifactFilename ) + { + try + { + // we want to print the absolute file name here + artifactFilename = artifact.getFile().getAbsoluteFile().getPath(); + } + catch ( NullPointerException e ) + { + // ignore the null pointer, we'll output a null string + artifactFilename = null; + } + } + + String id = outputScope ? artifact.toString() : artifact.getId(); + String optionalMarker = ""; + if ( outputScope && artifact.isOptional() ) + { + optionalMarker = " (optional) "; + } + + String moduleNameMarker = ""; + + // dependencies:collect won't download jars + if ( artifact.getFile() != null ) + { + ModuleDescriptor moduleDescriptor = getModuleDescriptor( artifact.getFile() ); + if ( moduleDescriptor != null ) + { + moduleNameMarker = " -- module " + moduleDescriptor.name; + + if ( moduleDescriptor.automatic ) + { + moduleNameMarker += " (auto)"; + } + } + } + + artifactStringList.add( " " + id + ( outputAbsoluteArtifactFilename ? ":" + artifactFilename : "" ) + + optionalMarker + + moduleNameMarker + + "\n" ); + } + if ( sort ) + { + Collections.sort( artifactStringList ); + } + for ( String artifactString : artifactStringList ) + { + sb.append( artifactString ); + } + return sb; + } + + private ModuleDescriptor getModuleDescriptor( File artifactFile ) + { + ModuleDescriptor moduleDescriptor = null; + try + { + // Use Java9 code to get moduleName, don't try to do it better with own implementation + Class<?> moduleFinderClass = Class.forName( "java.lang.module.ModuleFinder" ); + + java.nio.file.Path path = artifactFile.toPath(); + + Method ofMethod = moduleFinderClass.getMethod( "of", java.nio.file.Path[].class ); + Object moduleFinderInstance = ofMethod.invoke( null, new Object[] { new java.nio.file.Path[] { path } } ); + + Method findAllMethod = moduleFinderClass.getMethod( "findAll" ); + @SuppressWarnings( "unchecked" ) + Set<Object> moduleReferences = (Set<Object>) findAllMethod.invoke( moduleFinderInstance ); + + // moduleReferences can be empty when referring to target/classes without module-info.class + if ( !moduleReferences.isEmpty() ) + { + Object moduleReference = moduleReferences.iterator().next(); + Method descriptorMethod = moduleReference.getClass().getMethod( "descriptor" ); + Object moduleDescriptorInstance = descriptorMethod.invoke( moduleReference ); + + Method nameMethod = moduleDescriptorInstance.getClass().getMethod( "name" ); + String name = (String) nameMethod.invoke( moduleDescriptorInstance ); + + moduleDescriptor = new ModuleDescriptor(); + moduleDescriptor.name = name; + + Method isAutomaticMethod = moduleDescriptorInstance.getClass().getMethod( "isAutomatic" ); + moduleDescriptor.automatic = (Boolean) isAutomaticMethod.invoke( moduleDescriptorInstance ); + } + } + catch ( ClassNotFoundException e ) + { + // do nothing + } + catch ( NoSuchMethodException e ) + { + e.printStackTrace(); + } + catch ( SecurityException e ) + { + // do nothing + } + catch ( IllegalAccessException e ) + { + // do nothing + } + catch ( IllegalArgumentException e ) + { + // do nothing + } + catch ( InvocationTargetException e ) + { + Throwable cause = e.getCause(); + while ( cause.getCause() != null ) + { + cause = cause.getCause(); + } + getLog().info( "Can't extract module name from " + artifactFile.getName() + ": " + cause.getMessage() ); + } + return moduleDescriptor; + } + + private class ModuleDescriptor + { + String name; + + boolean automatic = true; + } } Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java?rev=1804137&r1=1804136&r2=1804137&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java Fri Aug 4 15:40:19 2017 @@ -19,18 +19,7 @@ package org.apache.maven.plugins.depende * under the License. */ -/** - * - */ - -import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import java.util.ArrayList; -import java.util.Collections; import java.util.LinkedHashSet; -import java.util.List; import java.util.Set; import org.apache.maven.artifact.Artifact; @@ -41,7 +30,6 @@ import org.apache.maven.artifact.Artifac */ public class DependencyStatusSets { - Set<Artifact> resolvedDependencies = null; Set<Artifact> unResolvedDependencies = null; @@ -140,184 +128,4 @@ public class DependencyStatusSets this.unResolvedDependencies = null; } } - - public String getOutput( boolean outputAbsoluteArtifactFilename ) - { - return getOutput( outputAbsoluteArtifactFilename, true ); - } - - public String getOutput( boolean outputAbsoluteArtifactFilename, boolean outputScope ) - { - return getOutput( outputAbsoluteArtifactFilename, outputScope, false ); - } - - public String getOutput( boolean outputAbsoluteArtifactFilename, boolean outputScope, boolean sort ) - { - StringBuilder sb = new StringBuilder(); - sb.append( "\n" ); - sb.append( "The following files have been resolved:\n" ); - if ( this.resolvedDependencies == null || this.resolvedDependencies.isEmpty() ) - { - sb.append( " none\n" ); - } - else - { - sb.append( buildArtifactListOutput( resolvedDependencies, outputAbsoluteArtifactFilename, - outputScope, sort ) ); - } - - if ( this.skippedDependencies != null && !this.skippedDependencies.isEmpty() ) - { - sb.append( "\n" ); - sb.append( "The following files were skipped:\n" ); - Set<Artifact> skippedDependencies = new LinkedHashSet<Artifact>(); - skippedDependencies.addAll( this.skippedDependencies ); - sb.append( buildArtifactListOutput( skippedDependencies, outputAbsoluteArtifactFilename, - outputScope, sort ) ); - } - - if ( this.unResolvedDependencies != null && !this.unResolvedDependencies.isEmpty() ) - { - sb.append( "\n" ); - sb.append( "The following files have NOT been resolved:\n" ); - Set<Artifact> unResolvedDependencies = new LinkedHashSet<Artifact>(); - unResolvedDependencies.addAll( this.unResolvedDependencies ); - sb.append( buildArtifactListOutput( unResolvedDependencies, outputAbsoluteArtifactFilename, - outputScope, sort ) ); - } - sb.append( "\n" ); - - return sb.toString(); - } - - private StringBuilder buildArtifactListOutput( Set<Artifact> artifacts, boolean outputAbsoluteArtifactFilename, - boolean outputScope, boolean sort ) - { - StringBuilder sb = new StringBuilder(); - List<String> artifactStringList = new ArrayList<String>(); - for ( Artifact artifact : artifacts ) - { - String artifactFilename = null; - if ( outputAbsoluteArtifactFilename ) - { - try - { - // we want to print the absolute file name here - artifactFilename = artifact.getFile().getAbsoluteFile().getPath(); - } - catch ( NullPointerException e ) - { - // ignore the null pointer, we'll output a null string - artifactFilename = null; - } - } - - String id = outputScope ? artifact.toString() : artifact.getId(); - String optionalMarker = ""; - if ( outputScope && artifact.isOptional() ) - { - optionalMarker = " (optional) "; - } - - String moduleNameMarker = ""; - - // dependencies:collect won't download jars - if ( artifact.getFile() != null ) - { - ModuleDescriptor moduleDescriptor = getModuleDescriptor( artifact.getFile() ); - if ( moduleDescriptor != null ) - { - moduleNameMarker = " -- module " + moduleDescriptor.name; - - if ( moduleDescriptor.automatic ) - { - moduleNameMarker += " (auto)"; - } - } - } - - artifactStringList.add( " " + id + ( outputAbsoluteArtifactFilename ? ":" + artifactFilename : "" ) - + optionalMarker - + moduleNameMarker - + "\n" ); - } - if ( sort ) - { - Collections.sort( artifactStringList ); - } - for ( String artifactString : artifactStringList ) - { - sb.append( artifactString ); - } - return sb; - } - - private ModuleDescriptor getModuleDescriptor( File artifactFile ) - { - ModuleDescriptor moduleDescriptor = null; - try - { - // Use Java9 code to get moduleName, don't try to do it better with own implementation - Class<?> moduleFinderClass = Class.forName( "java.lang.module.ModuleFinder" ); - - java.nio.file.Path path = artifactFile.toPath(); - - Method ofMethod = moduleFinderClass.getMethod( "of", java.nio.file.Path[].class ); - Object moduleFinderInstance = ofMethod.invoke( null, new Object[] { new java.nio.file.Path[] { path } } ); - - Method findAllMethod = moduleFinderClass.getMethod( "findAll" ); - @SuppressWarnings( "unchecked" ) - Set<Object> moduleReferences = (Set<Object>) findAllMethod.invoke( moduleFinderInstance ); - - // moduleReferences can be empty when referring to target/classes without module-info.class - if ( !moduleReferences.isEmpty() ) - { - Object moduleReference = moduleReferences.iterator().next(); - Method descriptorMethod = moduleReference.getClass().getMethod( "descriptor" ); - Object moduleDescriptorInstance = descriptorMethod.invoke( moduleReference ); - - Method nameMethod = moduleDescriptorInstance.getClass().getMethod( "name" ); - String name = (String) nameMethod.invoke( moduleDescriptorInstance ); - - moduleDescriptor = new ModuleDescriptor(); - moduleDescriptor.name = name; - - Method isAutomaticMethod = moduleDescriptorInstance.getClass().getMethod( "isAutomatic" ); - moduleDescriptor.automatic = (Boolean) isAutomaticMethod.invoke( moduleDescriptorInstance ); - } - } - catch ( ClassNotFoundException e ) - { - // do nothing - } - catch ( NoSuchMethodException e ) - { - e.printStackTrace(); - } - catch ( SecurityException e ) - { - // do nothing - } - catch ( IllegalAccessException e ) - { - // do nothing - } - catch ( IllegalArgumentException e ) - { - // do nothing - } - catch ( InvocationTargetException e ) - { - // do nothing - } - return moduleDescriptor; - } - - private class ModuleDescriptor - { - String name; - - boolean automatic = true; - } - } Added: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java?rev=1804137&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java Fri Aug 4 15:40:19 2017 @@ -0,0 +1,104 @@ +package org.apache.maven.plugins.dependency.resolvers; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; + +public class ResolveDependenciesMojoTest extends AbstractDependencyMojoTestCase +{ + protected void setUp() + throws Exception + { + // required for mojo lookups to work + super.setUp( "dss", true ); + } + + public void testDependencyStatusLog() + throws IOException + { + Set<Artifact> artifacts = this.stubFactory.getMixedArtifacts(); + doTestDependencyStatusLog( artifacts ); + } + + public void testDependencyStatusLogNullFiles() + throws IOException + { + this.stubFactory.setCreateFiles( false ); + Set<Artifact> artifacts = this.stubFactory.getMixedArtifacts(); + doTestDependencyStatusLog( artifacts ); + } + + public void testDependencyStatusEmptySet() + { + doTestDependencyStatusLog( new HashSet<Artifact>() ); + } + + public void doTestDependencyStatusLog( Set<Artifact> artifacts ) + { + // TODO: implement logger to check correct output + // this test is just looking for unexpected exceptions. + + ResolveDependenciesMojo mojo = newMojo( new DependencyStatusSets() ); + mojo.getOutput( false, true, false ); + mojo.getOutput( true, true, false ); + + mojo = newMojo( new DependencyStatusSets( artifacts, null, null ) ); + mojo.getOutput( false, true, false ); + mojo.getOutput( true, true, false ); + + mojo = newMojo( new DependencyStatusSets( null, artifacts, null ) ); + mojo.getOutput( false, true, false ); + mojo.getOutput( true, true, false ); + + mojo = newMojo( new DependencyStatusSets( null, null, artifacts ) ); + mojo.getOutput( false, true, false ); + mojo.getOutput( true, true, false ); + + mojo = newMojo( new DependencyStatusSets( artifacts, artifacts, null ) ); + mojo.getOutput( false, true, false ); + mojo.getOutput( true, true, false ); + + mojo = newMojo( new DependencyStatusSets( null, artifacts, artifacts ) ); + mojo.getOutput( false, true, false ); + mojo.getOutput( true, true, false ); + + mojo = newMojo( new DependencyStatusSets( artifacts, null, artifacts ) ); + mojo.getOutput( false, true, false ); + mojo.getOutput( true, true, false ); + + mojo = newMojo( new DependencyStatusSets( artifacts, artifacts, artifacts ) ); + mojo.getOutput( false, true, false ); + mojo.getOutput( true, true, false ); + mojo.getOutput( false, false, false ); + mojo.getOutput( true, false, false ); + } + + private ResolveDependenciesMojo newMojo( final DependencyStatusSets dss ) { + ResolveDependenciesMojo mojo = new ResolveDependenciesMojo(); + mojo.results = dss; + return mojo; + } +} Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyStatusSets.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyStatusSets.java?rev=1804137&r1=1804136&r2=1804137&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyStatusSets.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/utils/TestDependencyStatusSets.java Fri Aug 4 15:40:19 2017 @@ -19,11 +19,6 @@ package org.apache.maven.plugins.depende * under the License. */ -import java.io.IOException; -import java.util.HashSet; -import java.util.Set; - -import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; public class TestDependencyStatusSets @@ -57,67 +52,4 @@ public class TestDependencyStatusSets * dss.getUnResolvedDependencies() ); assertSame( s, dss.getSkippedDependencies() ); */ } - - public void testDependencyStatusLog() - throws IOException - { - Set<Artifact> artifacts = this.stubFactory.getMixedArtifacts(); - doTestDependencyStatusLog( artifacts ); - } - - public void testDependencyStatusLogNullFiles() - throws IOException - { - this.stubFactory.setCreateFiles( false ); - Set<Artifact> artifacts = this.stubFactory.getMixedArtifacts(); - doTestDependencyStatusLog( artifacts ); - } - - public void testDependencyStatusEmptySet() - { - doTestDependencyStatusLog( new HashSet<Artifact>() ); - } - - public void doTestDependencyStatusLog( Set<Artifact> artifacts ) - { - // TODO: implement logger to check correct output - // this test is just looking for unexpected exceptions. - - DependencyStatusSets dss = new DependencyStatusSets(); - dss.getOutput( false ); - dss.getOutput( true ); - - dss = new DependencyStatusSets( artifacts, null, null ); - dss.getOutput( false ); - dss.getOutput( true ); - - dss = new DependencyStatusSets( null, artifacts, null ); - dss.getOutput( false ); - dss.getOutput( true ); - - dss = new DependencyStatusSets( null, null, artifacts ); - dss.getOutput( false ); - dss.getOutput( true ); - - dss = new DependencyStatusSets( artifacts, artifacts, null ); - dss.getOutput( false ); - dss.getOutput( true ); - - dss = new DependencyStatusSets( null, artifacts, artifacts ); - dss.getOutput( false ); - dss.getOutput( true ); - - dss = new DependencyStatusSets( artifacts, null, artifacts ); - dss.getOutput( false ); - dss.getOutput( true ); - - dss = new DependencyStatusSets( artifacts, artifacts, artifacts ); - dss.getOutput( false ); - dss.getOutput( true ); - dss.getOutput( false, true ); - dss.getOutput( true, true ); - dss.getOutput( false, false ); - dss.getOutput( true, false ); - - } }