Author: michaelo Date: Mon Dec 28 22:49:48 2015 New Revision: 1722021 URL: http://svn.apache.org/viewvc?rev=1722021&view=rev Log: [MPIR-251] Artifact ###### has no file error regression
DependenciesRederer#hasSealed() implicitly resolved artifact to files and stopped at the first sealed artifact. Subsequent artifacts had no files attached. hasSealed() has been reduced to test for sealed only and a new method resolveArtifacts() has been extracted from the previous source. Added an IT with a sealed JAR dependency from Maven Central which verifies that all dependencies are properly resolved. IT contributed by: Hervé Boutemy <hbout...@apache.org> Added: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/MPIR-251/ - copied from r1722019, maven/plugins/branches/MPIR-251/src/it/MPIR-251/ Modified: maven/plugins/trunk/maven-project-info-reports-plugin/ (props changed) maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Mon Dec 28 22:49:48 2015 @@ -1 +1,2 @@ +/maven/plugins/branches/MPIR-251:1721764-1722019 /maven/plugins/branches/MPIR-279:1636164-1639524 Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java?rev=1722021&r1=1722020&r2=1722021&view=diff ============================================================================== --- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java (original) +++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java Mon Dec 28 22:49:48 2015 @@ -504,6 +504,8 @@ public class DependenciesRenderer List<Artifact> alldeps = dependencies.getAllDependencies(); Collections.sort( alldeps, getArtifactComparator() ); + resolveAtrifacts( alldeps ); + // i18n String filename = getI18nString( "file.details.column.file" ); String size = getI18nString( "file.details.column.size" ); @@ -557,8 +559,8 @@ public class DependenciesRenderer { if ( artifact.getFile() == null ) { - log.warn( "Artifact " + artifact.getId() + " has no file," - + " won't be listed in dependency files details." ); + log.warn( "Artifact " + artifact.getId() + " has no file" + + " and won't be listed in dependency files details." ); continue; } @@ -1245,6 +1247,57 @@ public class DependenciesRenderer endTable(); } + /** + * Resolves all given artifacts with {@link RepositoryUtils}. + * + ** @param artifacts not null + */ + private void resolveAtrifacts( List<Artifact> artifacts ) + { + for ( Artifact artifact : artifacts ) + { + // TODO site:run Why do we need to resolve this... + if ( artifact.getFile() == null ) + { + if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) ) + { + // can not resolve system scope artifact file + continue; + } + + try + { + repoUtils.resolve( artifact ); + } + catch ( ArtifactResolutionException e ) + { + log.error( "Artifact " + artifact.getId() + " can't be resolved.", e ); + continue; + } + catch ( ArtifactNotFoundException e ) + { + if ( ( dependencies.getProject().getGroupId().equals( artifact.getGroupId() ) ) + && ( dependencies.getProject().getArtifactId().equals( artifact.getArtifactId() ) ) + && ( dependencies.getProject().getVersion().equals( artifact.getVersion() ) ) ) + { + log.warn( "The artifact of this project has never been deployed." ); + } + else + { + log.error( "Artifact " + artifact.getId() + " not found.", e ); + } + + continue; + } + + if ( artifact.getFile() == null ) + { + log.error( "Artifact " + artifact.getId() + " has no file, even after resolution." ); + } + } + } + } + private Object invoke( Object object, String method ) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { @@ -1472,48 +1525,7 @@ public class DependenciesRenderer { for ( Artifact artifact : artifacts ) { - // TODO site:run Why do we need to resolve this... - if ( artifact.getFile() == null ) - { - if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) ) - { - // can not resolve system scope artifact file - continue; - } - - try - { - repoUtils.resolve( artifact ); - } - catch ( ArtifactResolutionException e ) - { - log.error( "Artifact " + artifact.getId() + " can't be resolved.", e ); - continue; - } - catch ( ArtifactNotFoundException e ) - { - if ( ( dependencies.getProject().getGroupId().equals( artifact.getGroupId() ) ) - && ( dependencies.getProject().getArtifactId().equals( artifact.getArtifactId() ) ) - && ( dependencies.getProject().getVersion().equals( artifact.getVersion() ) ) ) - { - log.warn( "The artifact of this project has never been deployed." ); - } - else - { - log.error( "Artifact " + artifact.getId() + " not found.", e ); - } - - continue; - } - - if ( artifact.getFile() == null ) - { - log.error( "Artifact " + artifact.getId() + " has no file, even after resolution." ); - continue; - } - } - - if ( JAR_SUBTYPE.contains( artifact.getType().toLowerCase() ) ) + if ( artifact.getFile() != null && JAR_SUBTYPE.contains( artifact.getType().toLowerCase() ) ) { try { @@ -1525,7 +1537,7 @@ public class DependenciesRenderer } catch ( IOException e ) { - log.error( "Artifact: " + artifact.getId() + " caused IOException: " + e.getMessage(), e ); + log.error( "Artifact " + artifact.getId() + " caused IOException: " + e.getMessage(), e ); } } }