org.apache.maven.project.ProjectDependenciesResolver Java Examples
The following examples show how to use
org.apache.maven.project.ProjectDependenciesResolver.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MutableMojo.java From java-specialagent with Apache License 2.0 | 6 votes |
static void resolveDependencies(final MavenSession session, final MojoExecution execution, final MojoExecutor executor, final ProjectDependenciesResolver projectDependenciesResolver) throws DependencyResolutionException, LifecycleExecutionException { // flushProjectArtifactsCache(executor); final MavenProject project = session.getCurrentProject(); final Set<Artifact> dependencyArtifacts = project.getDependencyArtifacts(); final Map<String,List<MojoExecution>> executions = new LinkedHashMap<>(execution.getForkedExecutions()); final ExecutionListener executionListener = session.getRequest().getExecutionListener(); try { project.setDependencyArtifacts(null); execution.getForkedExecutions().clear(); session.getRequest().setExecutionListener(null); executor.execute(session, Collections.singletonList(execution), new ProjectIndex(session.getProjects())); } finally { execution.getForkedExecutions().putAll(executions); session.getRequest().setExecutionListener(executionListener); project.setDependencyArtifacts(dependencyArtifacts); } projectDependenciesResolver.resolve(newDefaultDependencyResolutionRequest(session)); }
Example #2
Source File: AggregatingGraphFactoryTest.java From depgraph-maven-plugin with Apache License 2.0 | 6 votes |
@BeforeEach void before() throws Exception { this.globalFilter = mock(ArtifactFilter.class); ArtifactFilter transitiveIncludeExcludeFilter = mock(ArtifactFilter.class); ArtifactFilter targetFilter = mock(ArtifactFilter.class); when(this.globalFilter.include(any())).thenReturn(true); when(transitiveIncludeExcludeFilter.include(any())).thenReturn(true); when(targetFilter.include(any())).thenReturn(true); DependencyResolutionResult dependencyResolutionResult = mock(DependencyResolutionResult.class); org.eclipse.aether.graph.DependencyNode dependencyNode = mock(org.eclipse.aether.graph.DependencyNode.class); when(dependencyResolutionResult.getDependencyGraph()).thenReturn(dependencyNode); this.dependenciesResolver = mock(ProjectDependenciesResolver.class); when(this.dependenciesResolver.resolve(any(DependencyResolutionRequest.class))).thenReturn(dependencyResolutionResult); this.adapter = new MavenGraphAdapter(this.dependenciesResolver, transitiveIncludeExcludeFilter, targetFilter, EnumSet.of(INCLUDED)); this.graphBuilder = GraphBuilder.create(ToStringNodeIdRenderer.INSTANCE); }
Example #3
Source File: MavenGraphAdapterTest.java From depgraph-maven-plugin with Apache License 2.0 | 6 votes |
@BeforeEach void before() throws Exception { Artifact projectArtifact = mock(Artifact.class); this.mavenProject = new MavenProject(); this.mavenProject.setArtifact(projectArtifact); ProjectBuildingRequest projectBuildingRequest = mock(ProjectBuildingRequest.class); when(projectBuildingRequest.getRepositorySession()).thenReturn(mock(RepositorySystemSession.class)); //noinspection deprecation this.mavenProject.setProjectBuildingRequest(projectBuildingRequest); this.globalFilter = mock(ArtifactFilter.class); ArtifactFilter transitiveIncludeExcludeFilter = mock(ArtifactFilter.class); ArtifactFilter targetFilter = mock(ArtifactFilter.class); this.graphBuilder = GraphBuilder.create(ToStringNodeIdRenderer.INSTANCE); this.dependenciesResolver = mock(ProjectDependenciesResolver.class); DependencyResolutionResult dependencyResolutionResult = mock(DependencyResolutionResult.class); when(dependencyResolutionResult.getDependencyGraph()).thenReturn(mock(org.eclipse.aether.graph.DependencyNode.class)); when(this.dependenciesResolver.resolve(any(DependencyResolutionRequest.class))).thenReturn(dependencyResolutionResult); this.graphAdapter = new MavenGraphAdapter(this.dependenciesResolver, transitiveIncludeExcludeFilter, targetFilter, EnumSet.of(INCLUDED)); }
Example #4
Source File: LinkageCheckerRuleTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
private void setupMock() throws ExpressionEvaluationException, ComponentLookupException, DependencyResolutionException { mockProject = mock(MavenProject.class); mockMavenSession = mock(MavenSession.class); when(mockMavenSession.getRepositorySession()).thenReturn(repositorySystemSession); mockRuleHelper = mock(EnforcerRuleHelper.class); mockProjectDependenciesResolver = mock(ProjectDependenciesResolver.class); mockDependencyResolutionResult = mock(DependencyResolutionResult.class); mockLog = mock(Log.class); when(mockRuleHelper.getLog()).thenReturn(mockLog); when(mockRuleHelper.getComponent(ProjectDependenciesResolver.class)) .thenReturn(mockProjectDependenciesResolver); when(mockProjectDependenciesResolver.resolve(any(DependencyResolutionRequest.class))) .thenReturn(mockDependencyResolutionResult); when(mockRuleHelper.evaluate("${session}")).thenReturn(mockMavenSession); when(mockRuleHelper.evaluate("${project}")).thenReturn(mockProject); mockMojoExecution = mock(MojoExecution.class); when(mockMojoExecution.getLifecyclePhase()).thenReturn("verify"); when(mockRuleHelper.evaluate("${mojoExecution}")).thenReturn(mockMojoExecution); org.apache.maven.artifact.DefaultArtifact rootArtifact = new org.apache.maven.artifact.DefaultArtifact( "com.google.cloud", "linkage-checker-rule-test", "0.0.1", "compile", "jar", null, new DefaultArtifactHandler()); rootArtifact.setFile(new File("dummy.jar")); when(mockProject.getArtifact()).thenReturn(rootArtifact); }
Example #5
Source File: MavenGraphAdapter.java From depgraph-maven-plugin with Apache License 2.0 | 4 votes |
public MavenGraphAdapter(ProjectDependenciesResolver dependenciesResolver, ArtifactFilter transitiveIncludeExcludeFilter, ArtifactFilter targetFilter, Set<NodeResolution> includedResolutions) { this.dependenciesResolver = dependenciesResolver; this.transitiveIncludeExcludeFilter = transitiveIncludeExcludeFilter; this.targetFilter = targetFilter; this.includedResolutions = includedResolutions; }