org.apache.maven.execution.MavenExecutionRequest Java Examples
The following examples show how to use
org.apache.maven.execution.MavenExecutionRequest.
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: MavenProjectConfigCollector.java From helidon-build-tools with Apache License 2.0 | 6 votes |
@Override public void afterProjectsRead(MavenSession session) { if (ENABLED) { // Init state supportedProjectDir = null; projectConfig = null; debug("collector enabled"); try { // Ensure that we support this project supportedProjectDir = assertSupportedProject(session); // Install our listener so we can know if compilation occurred and succeeded final MavenExecutionRequest request = session.getRequest(); request.setExecutionListener(new EventListener(request.getExecutionListener())); } catch (IllegalStateException e) { supportedProjectDir = null; } } else { debug("collector disabled"); } }
Example #2
Source File: UnchangedProjectsRemover.java From gitflow-incremental-builder with MIT License | 6 votes |
private void handleNoChangesDetected(Set<MavenProject> selected) { Configuration cfg = configProvider.get(); if (!selected.isEmpty()) { // note: need to check make behaviour additionally because downstream projects will only be present for -pl when also -amd is set if (cfg.buildDownstream && Configuration.isMakeBehaviourActive(MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM, mavenSession)) { logger.info("No changed artifacts detected: Building explicitly selected projects and their dependents."); mavenSession.setProjects(selected.stream() .flatMap(this::streamProjectWithDownstreamProjects) .distinct() .collect(Collectors.toList())); } else { logger.info("No changed artifacts detected: Building just explicitly selected projects."); mavenSession.setProjects(new ArrayList<>(selected)); } } else if (cfg.buildAllIfNoChanges) { logger.info("No changed artifacts detected: Building all modules in buildAll mode."); logger.info("- skip tests: {}", cfg.skipTestsForUpstreamModules); logger.info("- additional args: {}", cfg.argsForUpstreamModules); mavenSession.getProjects().stream().forEach(this::applyUpstreamModuleArgs); } else { logger.info("No changed artifacts detected: Executing validate goal on current project only, skipping all submodules."); mavenSession.setProjects(Collections.singletonList(mavenSession.getCurrentProject())); mavenSession.getGoals().clear(); mavenSession.getGoals().add("validate"); } }
Example #3
Source File: UnchangedProjectsRemoverSelectedProjectsTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void nothingChanged_makeDownstream() throws GitAPIException, IOException { MavenProject moduleB = addModuleMock(AID_MODULE_B, false); MavenProject moduleC = addModuleMock(AID_MODULE_C, false); setUpstreamProjects(moduleC, moduleB, moduleA); setDownstreamProjects(moduleB, moduleC); setDownstreamProjects(moduleA, moduleB, moduleC); setProjectSelections(moduleB); overrideProjects(moduleB, moduleC); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM); underTest.act(); assertEquals(Collections.emptyList(), mavenSessionMock.getGoals(), "Unexpected goals"); verify(mavenSessionMock).setProjects(Arrays.asList(moduleB, moduleC)); assertProjectPropertiesEqual(moduleB, Collections.emptyMap()); assertProjectPropertiesEqual(moduleC, Collections.emptyMap()); }
Example #4
Source File: UnchangedProjectsRemoverSelectedProjectsTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void nothingChanged_makeDownstream_buildDownstreamDisabled() throws GitAPIException, IOException { MavenProject moduleB = addModuleMock(AID_MODULE_B, false); MavenProject moduleC = addModuleMock(AID_MODULE_C, false); setUpstreamProjects(moduleC, moduleB, moduleA); setDownstreamProjects(moduleB, moduleC); setDownstreamProjects(moduleA, moduleB, moduleC); setProjectSelections(moduleB); overrideProjects(moduleB, moduleC); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM); addGibProperty(Property.buildDownstream, "false"); underTest.act(); assertEquals(Collections.emptyList(), mavenSessionMock.getGoals(), "Unexpected goals"); verify(mavenSessionMock).setProjects(Collections.singletonList(moduleB)); assertProjectPropertiesEqual(moduleB, Collections.emptyMap()); }
Example #5
Source File: UnchangedProjectsRemoverSelectedProjectsTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void nothingChanged_makeBoth() throws GitAPIException, IOException { MavenProject moduleB = addModuleMock(AID_MODULE_B, false); MavenProject moduleC = addModuleMock(AID_MODULE_C, false); setUpstreamProjects(moduleC, moduleB, moduleA); setDownstreamProjects(moduleB, moduleC); setDownstreamProjects(moduleA, moduleB, moduleC); setProjectSelections(moduleB); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_BOTH); underTest.act(); assertEquals(Collections.emptyList(), mavenSessionMock.getGoals(), "Unexpected goals"); verify(mavenSessionMock).setProjects(Arrays.asList(moduleB, moduleC)); assertProjectPropertiesEqual(moduleB, Collections.emptyMap()); assertProjectPropertiesEqual(moduleC, Collections.emptyMap()); }
Example #6
Source File: UnchangedProjectsRemoverSelectedProjectsTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void moduleBChanged_makeBoth() throws GitAPIException, IOException { MavenProject moduleB = addModuleMock(AID_MODULE_B, true); MavenProject moduleC = addModuleMock(AID_MODULE_C, false); setUpstreamProjects(moduleC, moduleB, moduleA); setDownstreamProjects(moduleB, moduleC); setDownstreamProjects(moduleA, moduleB, moduleC); setProjectSelections(moduleB); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_BOTH); underTest.act(); verify(mavenSessionMock).setProjects(Arrays.asList(moduleB, moduleC)); assertProjectPropertiesEqual(moduleB, Collections.emptyMap()); assertProjectPropertiesEqual(moduleC, Collections.emptyMap()); }
Example #7
Source File: UnchangedProjectsRemoverSelectedProjectsTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void moduleAChanged_makeUpstream_moduleCSelected() throws GitAPIException, IOException { MavenProject moduleB = addModuleMock(AID_MODULE_B, false); MavenProject moduleC = addModuleMock(AID_MODULE_C, false); setDownstreamProjects(moduleB, moduleC); setUpstreamProjects(moduleC, moduleA, moduleB); setProjectSelections(moduleC); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM); changedProjects.add(moduleA); underTest.act(); // upstream B was not changed but its upstream A, so B must be built as well verify(mavenSessionMock).setProjects(Arrays.asList(moduleA, moduleB, moduleC)); assertProjectPropertiesEqual(moduleA, ImmutableMap.of("maven.test.skip", "true")); assertProjectPropertiesEqual(moduleB, ImmutableMap.of("maven.test.skip", "true")); assertProjectPropertiesEqual(moduleC, Collections.emptyMap()); }
Example #8
Source File: UnchangedProjectsRemoverTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void singleChanged_buildUpstream_skipTestsForUpstreamModules_jarGoal() throws GitAPIException, IOException { MavenProject changedModuleMock = addModuleMock(AID_MODULE_B, true); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM); addGibProperty(Property.skipTestsForUpstreamModules, "true"); Plugin pluginMock = mock(Plugin.class); PluginExecution execMock = mock(PluginExecution.class); when(execMock.getGoals()).thenReturn(Collections.singletonList("test-jar")); when(pluginMock.getExecutions()).thenReturn(Collections.singletonList(execMock)); when(moduleA.getBuildPlugins()).thenReturn(Collections.singletonList(pluginMock)); underTest.act(); verify(mavenSessionMock).setProjects(Arrays.asList(moduleA, changedModuleMock)); assertProjectPropertiesEqual(moduleA, ImmutableMap.of("skipTests", "true")); assertProjectPropertiesEqual(changedModuleMock, Collections.emptyMap()); }
Example #9
Source File: UnchangedProjectsRemoverSelectedProjectsTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void moduleAChanged_makeBoth() throws GitAPIException, IOException { MavenProject moduleB = addModuleMock(AID_MODULE_B, false); MavenProject moduleC = addModuleMock(AID_MODULE_C, false); setUpstreamProjects(moduleC, moduleB, moduleA); setDownstreamProjects(moduleB, moduleC); setDownstreamProjects(moduleA, moduleB, moduleC); setProjectSelections(moduleB); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_BOTH); changedProjects.add(moduleA); underTest.act(); verify(mavenSessionMock).setProjects(Arrays.asList(moduleA, moduleB, moduleC)); assertProjectPropertiesEqual(moduleA, ImmutableMap.of("maven.test.skip", "true")); assertProjectPropertiesEqual(moduleB, Collections.emptyMap()); assertProjectPropertiesEqual(moduleC, Collections.emptyMap()); }
Example #10
Source File: UnchangedProjectsRemoverTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void singleChanged_buildUpstream_modeChanged() throws GitAPIException, IOException { MavenProject changedModuleMock = addModuleMock(AID_MODULE_B, true); MavenProject unchangedModuleMock = addModuleMock("unchanged-module", false); MavenProject dependsOnBothModuleMock = addModuleMock("changed-and-unchanged-dependent", false); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM); setUpAndDownstreamsForBuildUpstreamModeTests(changedModuleMock, unchangedModuleMock, dependsOnBothModuleMock); addGibProperty(Property.buildUpstreamMode, "changed"); underTest.act(); verify(mavenSessionMock).setProjects(Arrays.asList(moduleA, changedModuleMock, dependsOnBothModuleMock)); assertProjectPropertiesEqual(moduleA, Collections.emptyMap()); assertProjectPropertiesEqual(changedModuleMock, Collections.emptyMap()); assertProjectPropertiesEqual(unchangedModuleMock, Collections.emptyMap()); assertProjectPropertiesEqual(dependsOnBothModuleMock, Collections.emptyMap()); }
Example #11
Source File: UnchangedProjectsRemoverTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void singleChanged_buildUpstream_modeChanged_argsForUpstreamModules() throws GitAPIException, IOException { MavenProject changedModuleMock = addModuleMock(AID_MODULE_B, true); MavenProject unchangedModuleMock = addModuleMock("unchanged-module", false); MavenProject dependsOnBothModuleMock = addModuleMock("changed-and-unchanged-dependent", false); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM); setUpAndDownstreamsForBuildUpstreamModeTests(changedModuleMock, unchangedModuleMock, dependsOnBothModuleMock); addGibProperty(Property.buildUpstreamMode, "changed"); addGibProperty(Property.argsForUpstreamModules, "foo=bar"); underTest.act(); verify(mavenSessionMock).setProjects(Arrays.asList(moduleA, changedModuleMock, dependsOnBothModuleMock)); assertProjectPropertiesEqual(moduleA, ImmutableMap.of("foo", "bar")); assertProjectPropertiesEqual(changedModuleMock, Collections.emptyMap()); assertProjectPropertiesEqual(unchangedModuleMock, Collections.emptyMap()); assertProjectPropertiesEqual(dependsOnBothModuleMock, Collections.emptyMap()); }
Example #12
Source File: UnchangedProjectsRemoverTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void singleChanged_buildUpstream_modeChanged_argsForUpstreamModules_linear() throws GitAPIException, IOException { MavenProject changedModuleMock = addModuleMock(AID_MODULE_B, true); MavenProject unchangedIntermediateModuleMock = addModuleMock("module-C", false); MavenProject dependsOnIntermediateModuleMock = addModuleMock("module-D", true); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM); setUpstreamProjects(dependsOnIntermediateModuleMock, unchangedIntermediateModuleMock, changedModuleMock, moduleA); setDownstreamProjects(changedModuleMock, unchangedIntermediateModuleMock, dependsOnIntermediateModuleMock); setDownstreamProjects(unchangedIntermediateModuleMock, dependsOnIntermediateModuleMock); addGibProperty(Property.buildUpstreamMode, "changed"); addGibProperty(Property.argsForUpstreamModules, "foo=bar"); underTest.act(); verify(mavenSessionMock).setProjects( Arrays.asList(moduleA, changedModuleMock, unchangedIntermediateModuleMock, dependsOnIntermediateModuleMock)); assertProjectPropertiesEqual(moduleA, ImmutableMap.of("foo", "bar")); assertProjectPropertiesEqual(changedModuleMock, Collections.emptyMap()); assertProjectPropertiesEqual(unchangedIntermediateModuleMock, Collections.emptyMap()); assertProjectPropertiesEqual(dependsOnIntermediateModuleMock, Collections.emptyMap()); }
Example #13
Source File: UnchangedProjectsRemoverTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void singleChanged_buildUpstream_modeImpacted() throws GitAPIException, IOException { MavenProject changedModuleMock = addModuleMock(AID_MODULE_B, true); MavenProject unchangedModuleMock = addModuleMock("unchanged-module", false); MavenProject dependsOnBothModuleMock = addModuleMock("changed-and-unchanged-dependent", false); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM); setUpAndDownstreamsForBuildUpstreamModeTests(changedModuleMock, unchangedModuleMock, dependsOnBothModuleMock); addGibProperty(Property.buildUpstreamMode, "impacted"); underTest.act(); verify(mavenSessionMock).setProjects(Arrays.asList(moduleA, changedModuleMock, unchangedModuleMock, dependsOnBothModuleMock)); assertProjectPropertiesEqual(moduleA, Collections.emptyMap()); assertProjectPropertiesEqual(changedModuleMock, Collections.emptyMap()); assertProjectPropertiesEqual(unchangedModuleMock, Collections.emptyMap()); assertProjectPropertiesEqual(dependsOnBothModuleMock, Collections.emptyMap()); }
Example #14
Source File: MavenEmbedder.java From netbeans with Apache License 2.0 | 6 votes |
public MavenExecutionResult readProjectWithDependencies(MavenExecutionRequest req, boolean useWorkspaceResolution) { if (useWorkspaceResolution) { req.setWorkspaceReader(new NbWorkspaceReader()); } File pomFile = req.getPom(); MavenExecutionResult result = new DefaultMavenExecutionResult(); try { ProjectBuildingRequest configuration = req.getProjectBuildingRequest(); configuration.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL); configuration.setResolveDependencies(true); configuration.setRepositorySession(maven.newRepositorySession(req)); ProjectBuildingResult projectBuildingResult = projectBuilder.build(pomFile, configuration); result.setProject(projectBuildingResult.getProject()); result.setDependencyResolutionResult(projectBuildingResult.getDependencyResolutionResult()); } catch (ProjectBuildingException ex) { //don't add the exception here. this should come out as a build marker, not fill //the error logs with msgs return result.addException(ex); } normalizePaths(result.getProject()); return result; }
Example #15
Source File: PropertiesUtilsTest.java From pom-manipulation-ext with Apache License 2.0 | 6 votes |
@SuppressWarnings( "deprecation" ) private ManipulationSession createUpdateSession() throws Exception { ManipulationSession session = new ManipulationSession(); session.setState( new DependencyState( p ) ); session.setState( new VersioningState( p ) ); session.setState( new CommonState( p ) ); final MavenExecutionRequest req = new DefaultMavenExecutionRequest().setUserProperties( p ).setRemoteRepositories( Collections.emptyList() ); final PlexusContainer container = new DefaultPlexusContainer(); final MavenSession mavenSession = new MavenSession( container, null, req, new DefaultMavenExecutionResult() ); session.setMavenSession( mavenSession ); return session; }
Example #16
Source File: ProjectComparatorTest.java From pom-manipulation-ext with Apache License 2.0 | 6 votes |
@SuppressWarnings( "deprecation" ) private ManipulationSession createUpdateSession() throws Exception { ManipulationSession session = new ManipulationSession(); final Properties p = new Properties(); p.setProperty( "strictAlignment", "true" ); p.setProperty( "strictViolationFails", "true" ); p.setProperty( "versionSuffix", "redhat-1" ); p.setProperty( "scanActiveProfiles", "true" ); session.setState( new DependencyState( p ) ); session.setState( new VersioningState( p ) ); session.setState( new CommonState( p ) ); final MavenExecutionRequest req = new DefaultMavenExecutionRequest().setUserProperties( p ).setRemoteRepositories( Collections.emptyList() ); final PlexusContainer container = new DefaultPlexusContainer(); final MavenSession mavenSession = new MavenSession( container, null, req, new DefaultMavenExecutionResult() ); session.setMavenSession( mavenSession ); return session; }
Example #17
Source File: AbstractSundrioMojo.java From sundrio with Apache License 2.0 | 6 votes |
void backGroundBuild(MavenProject project) throws MojoExecutionException { MavenExecutionRequest executionRequest = session.getRequest(); InvocationRequest request = new DefaultInvocationRequest(); request.setBaseDirectory(project.getBasedir()); request.setPomFile(project.getFile()); request.setGoals(executionRequest.getGoals()); request.setRecursive(false); request.setInteractive(false); request.setProfiles(executionRequest.getActiveProfiles()); request.setProperties(executionRequest.getUserProperties()); Invoker invoker = new DefaultInvoker(); try { InvocationResult result = invoker.execute(request); if (result.getExitCode() != 0) { throw new IllegalStateException("Error invoking Maven goals:[" + StringUtils.join(executionRequest.getGoals(), ", ") + "]", result.getExecutionException()); } } catch (MavenInvocationException e) { throw new IllegalStateException("Error invoking Maven goals:[" + StringUtils.join(executionRequest.getGoals(), ", ") + "]", e); } }
Example #18
Source File: UnchangedProjectsRemoverSelectedProjectsTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void moduleAChanged_makeDownstream_buildDownstreamDisabled() throws GitAPIException, IOException { MavenProject moduleB = addModuleMock(AID_MODULE_B, false); MavenProject moduleC = addModuleMock(AID_MODULE_C, false); setUpstreamProjects(moduleC, moduleB, moduleA); setDownstreamProjects(moduleB, moduleC); setDownstreamProjects(moduleA, moduleB, moduleC); setProjectSelections(moduleB); overrideProjects(moduleA, moduleB); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM); addGibProperty(Property.buildDownstream, "false"); changedProjects.add(moduleA); underTest.act(); verify(mavenSessionMock).setProjects(Collections.singletonList(moduleB)); assertProjectPropertiesEqual(moduleB, Collections.emptyMap()); }
Example #19
Source File: UnchangedProjectsRemoverSelectedProjectsTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void moduleAChanged_makeBoth_buildDownstreamDisabled() throws GitAPIException, IOException { MavenProject moduleB = addModuleMock(AID_MODULE_B, false); MavenProject moduleC = addModuleMock(AID_MODULE_C, false); setUpstreamProjects(moduleC, moduleB, moduleA); setDownstreamProjects(moduleB, moduleC); setDownstreamProjects(moduleA, moduleB, moduleC); setProjectSelections(moduleB); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_BOTH); addGibProperty(Property.buildDownstream, "false"); changedProjects.add(moduleA); underTest.act(); verify(mavenSessionMock).setProjects(Arrays.asList(moduleA, moduleB)); assertProjectPropertiesEqual(moduleA, ImmutableMap.of("maven.test.skip", "true")); assertProjectPropertiesEqual(moduleB, Collections.emptyMap()); }
Example #20
Source File: UnchangedProjectsRemoverSelectedProjectsTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void moduleAChanged_makeBoth_buildUpstreamDisabled() throws GitAPIException, IOException { MavenProject moduleB = addModuleMock(AID_MODULE_B, false); MavenProject moduleC = addModuleMock(AID_MODULE_C, false); setUpstreamProjects(moduleC, moduleB, moduleA); setDownstreamProjects(moduleB, moduleC); setDownstreamProjects(moduleA, moduleB, moduleC); setProjectSelections(moduleB); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_BOTH); addGibProperty(Property.buildUpstream, "false"); changedProjects.add(moduleA); underTest.act(); verify(mavenSessionMock).setProjects(Arrays.asList(moduleB, moduleC)); assertProjectPropertiesEqual(moduleB, Collections.emptyMap()); assertProjectPropertiesEqual(moduleC, Collections.emptyMap()); }
Example #21
Source File: MavenSessionMock.java From gitflow-incremental-builder with MIT License | 6 votes |
public static MavenSession get(Path workDir, Properties topLevelProjectProperties) throws Exception { PomFinder finder = new PomFinder(); Files.walkFileTree(workDir, finder); List<MavenProject> projects = finder.projects.stream() .sorted() .map(MavenSessionMock::createProject) .collect(Collectors.toList()); MavenProject topLevelProject = projects.get(0); topLevelProject.getModel().setProperties(topLevelProjectProperties); MavenSession mavenSession = mock(MavenSession.class, withSettings().lenient()); when(mavenSession.getCurrentProject()).thenReturn(topLevelProject); MavenExecutionRequest request = mock(MavenExecutionRequest.class); when(mavenSession.getRequest()).thenReturn(request); when(mavenSession.getAllProjects()).thenReturn(projects); when(mavenSession.getProjects()).thenReturn(projects); when(mavenSession.getTopLevelProject()).thenReturn(topLevelProject); ProjectDependencyGraph dependencyGraphMock = mock(ProjectDependencyGraph.class); when(mavenSession.getProjectDependencyGraph()).thenReturn(dependencyGraphMock); return mavenSession; }
Example #22
Source File: UnchangedProjectsRemoverTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void singleChanged_buildUpstream_modeImpacted_argsForUpstreamModules_linear() throws GitAPIException, IOException { MavenProject changedModuleMock = addModuleMock(AID_MODULE_B, true); MavenProject unchangedIntermediateModuleMock = addModuleMock("module-C", false); MavenProject dependsOnIntermediateModuleMock = addModuleMock("module-D", false); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM); setUpstreamProjects(dependsOnIntermediateModuleMock, unchangedIntermediateModuleMock, changedModuleMock, moduleA); setDownstreamProjects(changedModuleMock, unchangedIntermediateModuleMock, dependsOnIntermediateModuleMock); setDownstreamProjects(unchangedIntermediateModuleMock, dependsOnIntermediateModuleMock); addGibProperty(Property.buildUpstreamMode, "impacted"); addGibProperty(Property.argsForUpstreamModules, "foo=bar"); underTest.act(); verify(mavenSessionMock).setProjects( Arrays.asList(moduleA, changedModuleMock, unchangedIntermediateModuleMock, dependsOnIntermediateModuleMock)); assertProjectPropertiesEqual(moduleA, ImmutableMap.of("foo", "bar")); assertProjectPropertiesEqual(changedModuleMock, Collections.emptyMap()); assertProjectPropertiesEqual(unchangedIntermediateModuleMock, Collections.emptyMap()); assertProjectPropertiesEqual(dependsOnIntermediateModuleMock, Collections.emptyMap()); }
Example #23
Source File: UnchangedProjectsRemoverTest.java From gitflow-incremental-builder with MIT License | 6 votes |
@Test public void singleChanged_buildUpstream_modeImpacted_argsForUpstreamModules() throws GitAPIException, IOException { MavenProject changedModuleMock = addModuleMock(AID_MODULE_B, true); MavenProject unchangedModuleMock = addModuleMock("unchanged-module", false); MavenProject dependsOnBothModuleMock = addModuleMock("changed-and-unchanged-dependent", false); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM); setUpAndDownstreamsForBuildUpstreamModeTests(changedModuleMock, unchangedModuleMock, dependsOnBothModuleMock); addGibProperty(Property.buildUpstreamMode, "impacted"); addGibProperty(Property.argsForUpstreamModules, "foo=bar"); underTest.act(); verify(mavenSessionMock).setProjects(Arrays.asList(moduleA, changedModuleMock, unchangedModuleMock, dependsOnBothModuleMock)); assertProjectPropertiesEqual(moduleA, ImmutableMap.of("foo", "bar")); assertProjectPropertiesEqual(changedModuleMock, Collections.emptyMap()); assertProjectPropertiesEqual(unchangedModuleMock, ImmutableMap.of("foo", "bar")); assertProjectPropertiesEqual(dependsOnBothModuleMock, Collections.emptyMap()); }
Example #24
Source File: UnchangedProjectsRemoverSelectedProjectsTest.java From gitflow-incremental-builder with MIT License | 5 votes |
@Test public void moduleBChanged_makeUpstream_forceBuildA() throws GitAPIException, IOException { MavenProject moduleB = addModuleMock(AID_MODULE_B, true); setProjectSelections(moduleB); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM); addGibProperty(Property.forceBuildModules, "module-A"); underTest.act(); verify(mavenSessionMock).setProjects(Arrays.asList(moduleA, moduleB)); assertProjectPropertiesEqual(moduleA, ImmutableMap.of("maven.test.skip", "true")); assertProjectPropertiesEqual(moduleB, Collections.emptyMap()); }
Example #25
Source File: DistributionEnforcingManipulatorTest.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
private void setMavenSession() throws Exception { final MavenExecutionRequest req = new DefaultMavenExecutionRequest().setUserProperties( userCliProperties ) .setRemoteRepositories( Collections.emptyList() ); final PlexusContainer container = new DefaultPlexusContainer(); final MavenSession mavenSession = new MavenSession( container, null, req, new DefaultMavenExecutionResult() ); session.setMavenSession( mavenSession ); }
Example #26
Source File: UnchangedProjectsRemoverSelectedProjectsTest.java From gitflow-incremental-builder with MIT License | 5 votes |
@Test public void twoSelected_differentUpstreams_bothChanged() throws GitAPIException, IOException { MavenProject moduleB = addModuleMock(AID_MODULE_B, true); MavenProject moduleC = addModuleMock(AID_MODULE_C, false); setUpstreamProjects(moduleC, moduleB, moduleA); setDownstreamProjects(moduleB, moduleC); setDownstreamProjects(moduleA, moduleB, moduleC); MavenProject moduleD = addModuleMock(AID_MODULE_D, true); MavenProject moduleE = addModuleMock(AID_MODULE_E, false); setUpstreamProjects(moduleE, moduleD, moduleA); setDownstreamProjects(moduleD, moduleE); setDownstreamProjects(moduleA, moduleD, moduleE); setProjectSelections(moduleC, moduleE); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM); underTest.act(); verify(mavenSessionMock).setProjects(Arrays.asList(moduleB, moduleC, moduleD, moduleE)); assertProjectPropertiesEqual(moduleB, ImmutableMap.of("maven.test.skip", "true")); assertProjectPropertiesEqual(moduleC, Collections.emptyMap()); assertProjectPropertiesEqual(moduleD, ImmutableMap.of("maven.test.skip", "true")); assertProjectPropertiesEqual(moduleE, Collections.emptyMap()); }
Example #27
Source File: UnchangedProjectsRemoverSelectedProjectsTest.java From gitflow-incremental-builder with MIT License | 5 votes |
@Test public void twoSelected_differentUpstreams_oneChanged() throws GitAPIException, IOException { MavenProject moduleB = addModuleMock(AID_MODULE_B, false); MavenProject moduleC = addModuleMock(AID_MODULE_C, false); setUpstreamProjects(moduleC, moduleB, moduleA); setDownstreamProjects(moduleB, moduleC); setDownstreamProjects(moduleA, moduleB, moduleC); MavenProject moduleD = addModuleMock(AID_MODULE_D, true); MavenProject moduleE = addModuleMock(AID_MODULE_E, false); setUpstreamProjects(moduleE, moduleD, moduleA); setDownstreamProjects(moduleD, moduleE); setDownstreamProjects(moduleA, moduleD, moduleE); setProjectSelections(moduleC, moduleE); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM); underTest.act(); verify(mavenSessionMock).setProjects(Arrays.asList(moduleC, moduleD, moduleE)); assertProjectPropertiesEqual(moduleC, Collections.emptyMap()); assertProjectPropertiesEqual(moduleD, ImmutableMap.of("maven.test.skip", "true")); assertProjectPropertiesEqual(moduleE, Collections.emptyMap()); }
Example #28
Source File: UnchangedProjectsRemoverSelectedProjectsTest.java From gitflow-incremental-builder with MIT License | 5 votes |
@Test public void moduleBChanged_makeUpstream_buildAll() throws GitAPIException, IOException { MavenProject moduleB = addModuleMock(AID_MODULE_B, true); setProjectSelections(moduleB); when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM); addGibProperty(Property.buildAll, "true"); underTest.act(); verify(mavenSessionMock, never()).setProjects(anyList()); assertProjectPropertiesEqual(moduleA, ImmutableMap.of("maven.test.skip", "true")); assertProjectPropertiesEqual(moduleB, Collections.emptyMap()); }
Example #29
Source File: RunMojo.java From wisdom with Apache License 2.0 | 5 votes |
private MavenExecutionRequest getMavenExecutionRequest() { MavenExecutionRequest request = DefaultMavenExecutionRequest.copy(session.getRequest()); request.setStartTime(session.getStartTime()); request.setExecutionListener(null); if (! initialBuild && session.getGoals().contains("clean")) { // Here the package phase is required to restore the runtime environment request.setGoals(ImmutableList.of("clean", "package", "wisdom:internal-run")); } else { // It is safer to re-execute the package phase to have the new classes... request.setGoals(ImmutableList.of("package", "wisdom:internal-run")); } return request; }
Example #30
Source File: AbstractWildFlyMojoTest.java From wildfly-maven-plugin with GNU Lesser General Public License v2.1 | 5 votes |
public MavenProject readMavenProject(Path pom) throws Exception { MavenExecutionRequest request = new DefaultMavenExecutionRequest(); request.setBaseDirectory(pom.getParent().toFile()); ProjectBuildingRequest configuration = request.getProjectBuildingRequest(); configuration.setRepositorySession(new DefaultRepositorySystemSession()); MavenProject project = rule.lookup(ProjectBuilder.class).build(pom.toFile(), configuration).getProject(); Assert.assertNotNull(project); return project; }