Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
067e3c5
wip
elharo Jul 5, 2020
ec5ebbf
wip
elharo Jul 6, 2020
9572ecb
compile
elharo Jul 6, 2020
57b0a1d
minimal test case for debugging
elharo Jul 6, 2020
621a3b1
minimal test case for debugging
elharo Jul 6, 2020
8c44089
wip
elharo Jul 6, 2020
12e3257
merge
elharo Jul 6, 2020
0309a76
update wagon
elharo Jul 6, 2020
09d162b
don't use guava
elharo Jul 6, 2020
82865f2
wip
elharo Jul 6, 2020
747dae9
fixTestBuildClasspathMojo
elharo Jul 6, 2020
d2cf738
fix TestListClassesMojo
elharo Jul 6, 2020
797923d
fix TestClassifierTypeTranslator
elharo Jul 6, 2020
c9141e7
fix TestUnpackDependenciesMojo
elharo Jul 6, 2020
26f40b6
fix most of TestCopyDependenciesMojo2
elharo Jul 6, 2020
0d0dea2
fix TestUnpackMojo
elharo Jul 6, 2020
f1e217f
fix TestCopyMojo
elharo Jul 6, 2020
345bd62
fix TestIncludeExcludeUnpackMojo
elharo Jul 6, 2020
447d25a
fix testCopeDependenciesMojo2
elharo Jul 6, 2020
8bba1e4
remove TestLookupMojo
elharo Jul 6, 2020
c5a9923
remove excess setUp code
elharo Jul 6, 2020
3c16a63
fix testRepositoryLayout
elharo Jul 7, 2020
57f47f1
wor on getting rid of old asm
elharo Jul 7, 2020
2ec5575
added nonTestScopeTestArtifact logic, trying to add integration test
ian-lavallee Jul 10, 2020
176b974
integration test for analyze-report, needs improvement to make it les…
ian-lavallee Jul 10, 2020
29b2864
integration test not working due to class not found for jsoup Documen…
ian-lavallee Jul 13, 2020
3918a7a
commit to switch to new workspace
ian-lavallee Jul 13, 2020
865bcbf
fixed integration test for over-scoped test dependency
ian-lavallee Jul 14, 2020
969ac1e
Merge branch '31compat' of https://github.com/apache/maven-dependency…
ian-lavallee Jul 14, 2020
69870e5
trying to fix integration test failures with shading
ian-lavallee Jul 15, 2020
31d2cd6
Merge branch 'master' into 31compat
ian-lavallee Jul 23, 2020
46974ff
testing if maven-resolver-impl breaks tests
ian-lavallee Jul 23, 2020
44dbad7
Merge branch 'master' into 31compat
elharo Jul 24, 2020
cf013f6
use Maven 3.1.1
elharo Jul 24, 2020
5b06f5f
Merge remote-tracking branch 'upstream/31compat' into 31compat
ian-lavallee Jul 24, 2020
04b114e
dependencies added, tests passing
ian-lavallee Jul 24, 2020
304a498
need to do dependency management checks before the error checks
ian-lavallee Jul 28, 2020
fda1398
trying to add dependencyManagement
ian-lavallee Jul 29, 2020
e0f62b9
Dependency Management working, minor issues still need to be resolved
ian-lavallee Jul 29, 2020
a06d066
Tests passing
ian-lavallee Jul 30, 2020
22e648a
moving dependencyManagement logic from serializer to graph builder
ian-lavallee Jul 30, 2020
8c73eb7
dependencyManagement in builder
ian-lavallee Jul 31, 2020
92fe5c5
add google copyright
ian-lavallee Jul 31, 2020
06ca32e
Merge branch 'master' into verboseTreeBuilder
ian-lavallee Jul 31, 2020
6308b77
serializer tests added
ian-lavallee Jul 31, 2020
777c3f6
remove pom comment
ian-lavallee Jul 31, 2020
4206e78
remove comments in pom
ian-lavallee Aug 4, 2020
cce6db5
remove maven2 comments in analyze ITs
ian-lavallee Aug 4, 2020
a3315f4
remove empty hello.class for dependency analyzer nonTestScopedTestDep
ian-lavallee Aug 4, 2020
74e4b79
remove blank line after javadoc in verboseDependencyGraphBuilder:
ian-lavallee Aug 4, 2020
e246e0d
improve RepositoryUtility javaDoc
ian-lavallee Aug 4, 2020
54d4d5b
test comments clarified
ian-lavallee Aug 4, 2020
9e16f36
fix grammar in comment
ian-lavallee Aug 4, 2020
01c859a
remove maven exception type
ian-lavallee Aug 4, 2020
15cadb8
attempting to remove RepositoryUtility
ian-lavallee Aug 5, 2020
2e920db
Trying to remove repoUtility, breaking tests, committed to pair progr…
ian-lavallee Aug 5, 2020
f2ccea7
repositoryUtilty code added back in
ian-lavallee Aug 5, 2020
7824f00
change / to \ in pomExclude in invoker plugin
ian-lavallee Aug 5, 2020
eb20d76
better error messages for failing verbose tests
ian-lavallee Aug 5, 2020
76fd872
remove small verbose test from pom exclude
ian-lavallee Aug 5, 2020
23bc851
remove machine specific path in test
ian-lavallee Aug 5, 2020
67894e4
Merge branch 'master' into verboseTreeBuilder
ian-lavallee Aug 5, 2020
ccaf3ab
modify verify groovy for debugging
ian-lavallee Aug 5, 2020
19bbcf9
remove resolver dependencies, use previously included ones
ian-lavallee Aug 6, 2020
36d55e7
PR comments, change access modifiers of repositoryUtility class
ian-lavallee Aug 6, 2020
2fca2a1
PR comment changes
ian-lavallee Aug 6, 2020
d453763
remove unused import and clarify RepositoryUtility comment
ian-lavallee Aug 7, 2020
2c80ab5
not working yet
ian-lavallee Aug 7, 2020
13fe69c
halfway to changing, investigating new session on different branch
ian-lavallee Aug 7, 2020
2462d5c
working with projectDependencyResolver
ian-lavallee Aug 7, 2020
5909e88
passing tests
ian-lavallee Aug 7, 2020
f426383
merge conflicts fixed
ian-lavallee Aug 7, 2020
e03c707
switch to more standard maven way of resolving dependencies
ian-lavallee Aug 7, 2020
865751c
PR comments addressed
ian-lavallee Aug 7, 2020
1971266
PR comment changes
ian-lavallee Aug 10, 2020
3219c3d
Change DependencyResolutionException handling
ian-lavallee Aug 10, 2020
fd5e504
adding different format serializer support
ian-lavallee Aug 12, 2020
b989034
working dot test
ian-lavallee Aug 13, 2020
f0b6878
tgf and dot passing tests
ian-lavallee Aug 13, 2020
8159bb6
passing graphml, dot, tgf tests
ian-lavallee Aug 14, 2020
308c03b
fixed checkstyle errors
ian-lavallee Aug 14, 2020
a2e4799
merge master
ian-lavallee Aug 14, 2020
fa88f8e
replace system.lineseparator with \n
ian-lavallee Aug 14, 2020
75e9590
created abstract class for different verbose serializers
ian-lavallee Aug 14, 2020
2c7a080
rename stringbuilder variable
ian-lavallee Aug 14, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,45 +33,17 @@
import java.util.Set;

/**
* Parses dependency graph and outputs in text format for end user to review.
* Base class for verbose Serializers
*/
final class VerboseGraphSerializer
abstract class AbstractVerboseGraphSerializer
{
private static final String LINE_START_LAST_CHILD = "\\- ", LINE_START_CHILD = "+- ";
private static final String PRE_MANAGED_SCOPE = "preManagedScope", PRE_MANAGED_VERSION = "preManagedVersion",
protected static final String LINE_START_LAST_CHILD = "\\- ", LINE_START_CHILD = "+- ";
protected static final String PRE_MANAGED_SCOPE = "preManagedScope", PRE_MANAGED_VERSION = "preManagedVersion",
MANAGED_SCOPE = "managedScope";

public String serialize( DependencyNode root )
{
Set<String> coordinateStrings = new HashSet<>();
Map<String, String> coordinateVersionMap = new HashMap<>();
StringBuilder builder = new StringBuilder();

// Use BFS to mirror how Maven resolves dependencies and use DFS to print the tree easily
Map<DependencyNode, String> nodeErrors = getNodeConflictMessagesBfs( root, coordinateStrings,
coordinateVersionMap );

// deal with root first
Artifact rootArtifact = root.getArtifact();
builder.append( rootArtifact.getGroupId() ).append( ":" ).append( rootArtifact.getArtifactId() ).append( ":" )
.append( rootArtifact.getExtension() ).append( ":" ).append( rootArtifact.getVersion() ).append(
System.lineSeparator() );
public abstract String serialize( DependencyNode root );

for ( int i = 0; i < root.getChildren().size(); i++ )
{
if ( i == root.getChildren().size() - 1 )
{
dfsPrint( root.getChildren().get( i ), LINE_START_LAST_CHILD, false, builder, nodeErrors );
}
else
{
dfsPrint( root.getChildren().get( i ), LINE_START_CHILD, false, builder, nodeErrors );
}
}
return builder.toString();
}

private static String getDependencyCoordinate( DependencyNode node )
protected static String getDependencyCoordinate( DependencyNode node )
{
Artifact artifact = node.getArtifact();

Expand Down Expand Up @@ -140,7 +112,7 @@ private static String scopeConflict( DependencyNode node, Set<String> coordinate
return null;
}

private Map<DependencyNode, String> getNodeConflictMessagesBfs( DependencyNode root, Set<String> coordinateStrings
protected Map<DependencyNode, String> getNodeConflictMessagesBfs( DependencyNode root, Set<String> coordinateStrings
, Map<String, String> coordinateVersionMap )
{
Map<DependencyNode, String> nodeErrors = new HashMap<>();
Expand All @@ -166,8 +138,11 @@ private Map<DependencyNode, String> getNodeConflictMessagesBfs( DependencyNode r
}
else if ( scopeConflict( node, coordinateStrings ) != null )
{
nodeErrors.put( node, "omitted for conflict with "
+ scopeConflict( node, coordinateStrings ) );
nodeErrors.put( node, "omitted for conflict with " + scopeConflict( node, coordinateStrings ) );
}
else if ( versionConflict( node, coordinateVersionMap ) != null )
{
nodeErrors.put( node, "omitted for conflict with " + versionConflict( node, coordinateVersionMap ) );
}
else if ( versionConflict( node, coordinateVersionMap ) != null )
{
Expand Down Expand Up @@ -219,106 +194,4 @@ else if ( node.getDependency() != null && node.getDependency().isOptional() )
}
return nodeErrors;
}

private void dfsPrint( DependencyNode node, String start, boolean transitive, StringBuilder builder,
Map<DependencyNode, String> nodeErrors )
{
builder.append( start );
if ( node.getArtifact() == null )
{
// Should never hit this condition with a proper graph sent in
builder.append( "Null Artifact Node" ).append( System.lineSeparator() );
callDfsPrint( node, start, builder, nodeErrors );
}

String coordString = "";
boolean messageAdded = false;

if ( transitive && node.getArtifact().getProperties().containsKey( PRE_MANAGED_VERSION ) )
{
coordString = coordString.concat( " - version managed from "
+ node.getArtifact().getProperties().get( PRE_MANAGED_VERSION ) );
messageAdded = true;
}

if ( transitive && node.getArtifact().getProperties().containsKey( PRE_MANAGED_SCOPE ) )
{
if ( messageAdded )
{
coordString = coordString.concat( "; " );
}
else
{
coordString = coordString.concat( " - " );
messageAdded = true;
}
coordString = coordString.concat( "scope managed from "
+ node.getArtifact().getProperties().get( PRE_MANAGED_SCOPE ) );
}

coordString = getDependencyCoordinate( node ) + coordString;

if ( !( node.getDependency().getScope().equals( "test" ) && transitive ) )
{
if ( node.getArtifact().getProperties().containsKey( "Cycle" ) )
{
if ( messageAdded )
{
coordString = coordString.concat( "; " );
}
else
{
coordString = coordString.concat( " - " );
}
coordString = coordString.concat( "omitted for cycle" );
builder.append( "(" ).append( coordString ).append( ")" ).append( System.lineSeparator() );
}
else if ( nodeErrors.get( node ) != null )
{
builder.append( "(" );
if ( messageAdded )
{
builder.append( coordString ).append( "; " ).append( nodeErrors.get( node ) );
}
else
{
builder.append( coordString ).append( " - " ).append( nodeErrors.get( node ) );
}
builder.append( ")" );
builder.append( System.lineSeparator() );
}
else
{
builder.append( coordString ).append( System.lineSeparator() );
callDfsPrint( node, start, builder, nodeErrors );
}
}
}

private void callDfsPrint( DependencyNode node, String start, StringBuilder builder,
Map<DependencyNode, String> nodeErrors )
{
for ( int i = 0; i < node.getChildren().size(); i++ )
{
if ( start.endsWith( LINE_START_CHILD ) )
{
start = start.replace( LINE_START_CHILD, "| " );
}
else if ( start.endsWith( LINE_START_LAST_CHILD ) )
{
start = start.replace( LINE_START_LAST_CHILD, " " );
}

if ( i == node.getChildren().size() - 1 )
{
dfsPrint( node.getChildren().get( i ), start.concat( LINE_START_LAST_CHILD ), true, builder,
nodeErrors );
}
else
{
dfsPrint( node.getChildren().get( i ), start.concat( LINE_START_CHILD ), true, builder,
nodeErrors );
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public void execute()
// verboseGraphBuilder needs MavenProject project, RepositorySystemSession session,
// ProjectDependenciesResolver resolver
VerboseDependencyGraphBuilder builder = new VerboseDependencyGraphBuilder();
VerboseGraphSerializer serializer = new VerboseGraphSerializer();
AbstractVerboseGraphSerializer serializer = getSerializer();

org.eclipse.aether.graph.DependencyNode verboseRootNode = builder.buildVerboseGraph(
project, resolver, repoSession );
Expand Down Expand Up @@ -350,6 +350,25 @@ public void setSkip( boolean skip )

// private methods --------------------------------------------------------

private AbstractVerboseGraphSerializer getSerializer( )
{
if ( "graphml".equals( outputType ) )
{
return new VerboseGraphGraphmlSerializer();
}
else if ( "tgf".equals( outputType ) )
{
return new VerboseGraphTgfSerializer();
}
else if ( "dot".equals( outputType ) )
{
return new VerboseGraphDotSerializer();
}
else
{
return new VerboseGraphTextSerializer();
}
}

private DependencyNode convertToCustomDependencyNode( org.eclipse.aether.graph.DependencyNode node )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class VerboseDependencyGraphBuilder
MANAGED_SCOPE = "managedScope";

public DependencyNode buildVerboseGraph( MavenProject project, ProjectDependenciesResolver resolver,
RepositorySystemSession repositorySystemSession )
RepositorySystemSession repositorySystemSession )
throws DependencyResolutionException
{
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
Expand All @@ -66,13 +66,12 @@ public DependencyNode buildVerboseGraph( MavenProject project, ProjectDependenci
DependencySelector dependencySelector = new AndDependencySelector(
// ScopeDependencySelector takes exclusions. 'Provided' scope is not here to avoid
// false positive in LinkageChecker.
new ScopeDependencySelector(),
new ExclusionDependencySelector() );
new ScopeDependencySelector(), new ExclusionDependencySelector() );

session.setDependencySelector( dependencySelector );
session.setDependencyGraphTransformer( new ChainedDependencyGraphTransformer(
new CycleBreakerGraphTransformer(), // Avoids StackOverflowError
new JavaDependencyContextRefiner() ) );
session.setDependencyGraphTransformer(
new ChainedDependencyGraphTransformer( new CycleBreakerGraphTransformer(), // Avoids StackOverflowError
new JavaDependencyContextRefiner() ) );
session.setDependencyManager( null );

DependencyResolutionRequest request = new DefaultDependencyResolutionRequest();
Expand Down Expand Up @@ -152,26 +151,26 @@ private static Map<String, org.apache.maven.model.Dependency> createDependencyMa

private static String getDependencyManagementCoordinate( org.apache.maven.model.Dependency dependency )
{
StringBuilder string = new StringBuilder();
string.append( dependency.getGroupId() ).append( ":" ).append( dependency.getArtifactId() )
.append( ":" ).append( dependency.getType() );
StringBuilder builder = new StringBuilder();
builder.append( dependency.getGroupId() ).append( ":" ).append( dependency.getArtifactId() ).append( ":" )
.append( dependency.getType() );
if ( dependency.getClassifier() != null && !dependency.getClassifier().equals( "" ) )
{
string.append( ":" ).append( dependency.getClassifier() );
builder.append( ":" ).append( dependency.getClassifier() );
}
return string.toString();
return builder.toString();
}

private static String getDependencyManagementCoordinate( Artifact artifact )
{
StringBuilder string = new StringBuilder();
string.append( artifact.getGroupId() ).append( ":" ).append( artifact.getArtifactId() ).append( ":" )
.append( artifact.getExtension() );
StringBuilder builder = new StringBuilder();
builder.append( artifact.getGroupId() ).append( ":" ).append( artifact.getArtifactId() ).append( ":" ).append(
artifact.getExtension() );
if ( artifact.getClassifier() != null && !artifact.getClassifier().equals( "" ) )
{
string.append( ":" ).append( artifact.getClassifier() );
builder.append( ":" ).append( artifact.getClassifier() );
}
return string.toString();
return builder.toString();
}

private Dependency getProjectDependency( MavenProject project )
Expand Down Expand Up @@ -199,7 +198,7 @@ private DependencyNode pruneTransitiveTestDependencies( DependencyNode rootNode,
return newRoot;
}

private void pruneTransitiveTestDependenciesDfs( DependencyNode node , Set<DependencyNode> visitedNodes )
private void pruneTransitiveTestDependenciesDfs( DependencyNode node, Set<DependencyNode> visitedNodes )
{
if ( !visitedNodes.contains( node ) )
{
Expand Down
Loading