/** * Gets the dependencies seen during the graph traversal. * * @param includeUnresolved Whether unresolved dependencies shall be included in the result or not. * @return The list of dependencies, never {@code null}. */ public List<Dependency> getDependencies( boolean includeUnresolved ) { List<Dependency> dependencies = new ArrayList<Dependency>( getNodes().size() ); for ( DependencyNode node : getNodes() ) { Dependency dependency = node.getDependency(); if ( dependency != null ) { if ( includeUnresolved || dependency.getArtifact().getFile() != null ) { dependencies.add( dependency ); } } } return dependencies; }
/** * Gets the files of resolved artifacts seen during the graph traversal. * * @return The list of artifact files, never {@code null}. */ public List<File> getFiles() { List<File> files = new ArrayList<File>( getNodes().size() ); for ( DependencyNode node : getNodes() ) { if ( node.getDependency() != null ) { File file = node.getDependency().getArtifact().getFile(); if ( file != null ) { files.add( file ); } } } return files; }
/** * Gets the artifacts associated with the list of dependency nodes generated during the graph traversal. * * @param includeUnresolved Whether unresolved artifacts shall be included in the result or not. * @return The list of artifacts, never {@code null}. */ public List<Artifact> getArtifacts( boolean includeUnresolved ) { List<Artifact> artifacts = new ArrayList<Artifact>( getNodes().size() ); for ( DependencyNode node : getNodes() ) { if ( node.getDependency() != null ) { Artifact artifact = node.getDependency().getArtifact(); if ( includeUnresolved || artifact.getFile() != null ) { artifacts.add( artifact ); } } } return artifacts; }
/** * Gets a class path by concatenating the artifact files of the visited dependency nodes. Nodes with unresolved * artifacts are automatically skipped. * * @return The class path, using the platform-specific path separator, never {@code null}. */ public String getClassPath() { StringBuilder buffer = new StringBuilder( 1024 ); for ( Iterator<DependencyNode> it = getNodes().iterator(); it.hasNext(); ) { DependencyNode node = it.next(); if ( node.getDependency() != null ) { Artifact artifact = node.getDependency().getArtifact(); if ( artifact.getFile() != null ) { buffer.append( artifact.getFile().getAbsolutePath() ); if ( it.hasNext() ) { buffer.append( File.pathSeparatorChar ); } } } } return buffer.toString(); }