org.apache.maven.plugin.MojoExecution Java Examples
The following examples show how to use
org.apache.maven.plugin.MojoExecution.
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: AbstractRunMojo.java From vertx-maven-plugin with Apache License 2.0 | 6 votes |
private Callable<Void> toTask(MojoExecution execution) { MojoExecutor executor = new MojoExecutor(execution, project, mavenSession, buildPluginManager); return () -> { try { //--- vertx-maven-plugin:1.0-SNAPSHOT:run (default-cli) @ vertx-demo getLog().info(">>> " + execution.getArtifactId() + ":" + execution.getVersion() + ":" + execution.getGoal() + " (" + execution.getExecutionId() + ") @" + project.getArtifactId()); executor.execute(); } catch (Exception e) { getLog().error("Error while doing incremental build", e); } return null; }; }
Example #2
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex ) throws LifecycleExecutionException { if (SkipCheck.skip(session.getCurrentProject().getBasedir()) && mojoExecutions.stream().map(MojoExecution::getGoal).map(String::toLowerCase) .anyMatch(s -> s.contains("group.idealworld.dew:dew-maven-plugin:release") || s.contains("dew:release") || s.contains("deploy"))) { return; } DependencyContext dependencyContext = newDependencyContext( session, mojoExecutions ); PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() ); for ( MojoExecution mojoExecution : mojoExecutions ) { execute( session, mojoExecution, projectIndex, dependencyContext, phaseRecorder ); } }
Example #3
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex ) throws LifecycleExecutionException { if (SkipCheck.skip(session.getCurrentProject().getBasedir()) && mojoExecutions.stream().map(MojoExecution::getGoal).map(String::toLowerCase) .anyMatch(s -> s.contains("group.idealworld.dew:dew-maven-plugin:release") || s.contains("dew:release") || s.contains("deploy"))) { return; } DependencyContext dependencyContext = newDependencyContext( session, mojoExecutions ); PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() ); for ( MojoExecution mojoExecution : mojoExecutions ) { execute( session, mojoExecution, projectIndex, dependencyContext, phaseRecorder ); } }
Example #4
Source File: ChangeDetector.java From spring-cloud-contract with Apache License 2.0 | 6 votes |
static boolean inputFilesChangeDetected(File contractsDirectory, MojoExecution mojoExecution, MavenSession session) throws MojoExecutionException { IncrementalBuildHelper incrementalBuildHelper = new IncrementalBuildHelper( mojoExecution, session); DirectoryScanner scanner = incrementalBuildHelper.getDirectoryScanner(); scanner.setBasedir(contractsDirectory); scanner.scan(); boolean changeDetected = incrementalBuildHelper.inputFileTreeChanged(scanner); if (scanner.getIncludedFiles().length == 0) { // at least one input file must exist to consider changed/unchanged // return true to skip incremental build and make visible no input file at all return true; } return changeDetected; }
Example #5
Source File: CatchAllExecutionHandler.java From pipeline-maven-plugin with MIT License | 6 votes |
@Nonnull @Override protected List<String> getConfigurationParametersToReport(ExecutionEvent executionEvent) { MojoExecution mojoExecution = executionEvent.getMojoExecution(); if (mojoExecution == null) { return Collections.emptyList(); } Xpp3Dom configuration = mojoExecution.getConfiguration(); List<String> parameters = new ArrayList<String>(); for (Xpp3Dom configurationParameter : configuration.getChildren()) { parameters.add(configurationParameter.getName()); } return parameters; }
Example #6
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex ) throws LifecycleExecutionException { if (SkipCheck.skip(session.getCurrentProject().getBasedir()) && mojoExecutions.stream().map(MojoExecution::getGoal).map(String::toLowerCase) .anyMatch(s -> s.contains("group.idealworld.dew:dew-maven-plugin:release") || s.contains("dew:release") || s.contains("deploy"))) { return; } DependencyContext dependencyContext = newDependencyContext( session, mojoExecutions ); PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() ); for ( MojoExecution mojoExecution : mojoExecutions ) { execute( session, mojoExecution, projectIndex, dependencyContext, phaseRecorder ); } }
Example #7
Source File: XtendProjectConfigurator.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException { addNature(request.getProject(), XtextProjectHelper.NATURE_ID, monitor); OutputConfiguration config = new XtendOutputConfigurationProvider() .getOutputConfigurations().iterator().next(); List<MojoExecution> executions = getMojoExecutions(request, monitor); SubMonitor progress = SubMonitor.convert(monitor, executions.size()); for (MojoExecution execution : executions) { String goal = execution.getGoal(); if (goal.equals("compile")) { readCompileConfig(config, request, execution, progress.split(1)); } else if (goal.equals("testCompile")) { readTestCompileConfig(config, request, execution, progress.split(1)); } else if (goal.equals("xtend-install-debug-info")) { readDebugInfoConfig(config, request, execution, progress.split(1)); } else if (goal.equals("xtend-test-install-debug-info")) { readTestDebugInfoConfig(config, request, execution, progress.split(1)); } } writePreferences(config, request.getProject()); }
Example #8
Source File: JApiCmpMojoTest.java From japicmp with Apache License 2.0 | 6 votes |
@Test public void testSimple() throws MojoFailureException, MojoExecutionException { JApiCmpMojo mojo = new JApiCmpMojo(); Version oldVersion = createVersion("groupId", "artifactId", "0.1.0"); Version newVersion = createVersion("groupId", "artifactId", "0.1.1"); PluginParameters pluginParameters = new PluginParameters(false, newVersion, oldVersion, new Parameter(), null, Optional.of(Paths.get(System.getProperty("user.dir"), "target", "simple").toFile()), Optional.<String>absent(), true, null, null, null, null); ArtifactResolver artifactResolver = mock(ArtifactResolver.class); ArtifactResolutionResult artifactResolutionResult = mock(ArtifactResolutionResult.class); Set<Artifact> artifactSet = new HashSet<>(); Artifact resolvedArtifact = mock(Artifact.class); artifactSet.add(resolvedArtifact); when(resolvedArtifact.getFile()).thenReturn(Paths.get(System.getProperty("user.dir"), "target", "guava-18.0.jar").toFile()); when(artifactResolutionResult.getArtifacts()).thenReturn(artifactSet); when(artifactResolver.resolve(Matchers.<ArtifactResolutionRequest>anyObject())).thenReturn(artifactResolutionResult); ArtifactFactory artifactFactory = mock(ArtifactFactory.class); when(artifactFactory.createArtifactWithClassifier(eq("groupId"), eq("artifactId"), eq("0.1.1"), anyString(), anyString())).thenReturn(mock(Artifact.class)); MavenProject mavenProject = mock(MavenProject.class); when(mavenProject.getArtifact()).thenReturn(mock(Artifact.class)); MavenParameters mavenParameters = new MavenParameters(new ArrayList<ArtifactRepository>(), artifactFactory, mock(ArtifactRepository.class), artifactResolver, mavenProject, mock(MojoExecution.class), "0.0.1", mock(ArtifactMetadataSource.class)); mojo.executeWithParameters(pluginParameters, mavenParameters); assertThat(Files.exists(Paths.get(System.getProperty("user.dir"), "target", "simple", "japicmp", "japicmp.diff")), is(true)); assertThat(Files.exists(Paths.get(System.getProperty("user.dir"), "target", "simple", "japicmp", "japicmp.xml")), is(true)); assertThat(Files.exists(Paths.get(System.getProperty("user.dir"), "target", "simple", "japicmp", "japicmp.html")), is(true)); }
Example #9
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex ) throws LifecycleExecutionException { if (SkipCheck.skip(session.getCurrentProject().getBasedir()) && mojoExecutions.stream().map(MojoExecution::getGoal).map(String::toLowerCase) .anyMatch(s -> s.contains("group.idealworld.dew:dew-maven-plugin:release") || s.contains("dew:release") || s.contains("deploy"))) { return; } DependencyContext dependencyContext = newDependencyContext( session, mojoExecutions ); PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() ); for ( MojoExecution mojoExecution : mojoExecutions ) { execute( session, mojoExecution, projectIndex, dependencyContext, phaseRecorder ); } }
Example #10
Source File: AbstractRunMojo.java From vertx-maven-plugin with Apache License 2.0 | 6 votes |
private Callable<Void> toTask(MojoExecution execution) { MojoExecutor executor = new MojoExecutor(execution, project, mavenSession, buildPluginManager); return () -> { try { //--- vertx-maven-plugin:1.0-SNAPSHOT:run (default-cli) @ vertx-demo getLog().info(">>> " + execution.getArtifactId() + ":" + execution.getVersion() + ":" + execution.getGoal() + " (" + execution.getExecutionId() + ") @" + project.getArtifactId()); executor.execute(); } catch (Exception e) { getLog().error("Error while doing incremental build", e); } return null; }; }
Example #11
Source File: AnnotationProcessingTest.java From takari-lifecycle with Eclipse Public License 1.0 | 6 votes |
protected void processAnnotations(MavenSession session, MavenProject project, String goal, File processor, Proc proc, Xpp3Dom... parameters) throws Exception { MojoExecution execution = mojos.newMojoExecution(goal); addDependency(project, "processor", new File(processor, "target/classes")); Xpp3Dom configuration = execution.getConfiguration(); if (proc != null) { configuration.addChild(newParameter("proc", proc.name())); } if (parameters != null) { for (Xpp3Dom parameter : parameters) { configuration.addChild(parameter); } } mojos.executeMojo(session, project, execution); }
Example #12
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 #13
Source File: IteratorMojo.java From iterator-maven-plugin with Apache License 2.0 | 6 votes |
/** * Taken from MojoExecutor of Don Brown. Make it working with Maven 3.1. * * @param plugin * @param goal * @param configuration * @param env * @throws MojoExecutionException * @throws PluginResolutionException * @throws PluginDescriptorParsingException * @throws InvalidPluginDescriptorException * @throws PluginManagerException * @throws PluginConfigurationException * @throws MojoFailureException */ private void executeMojo( Plugin plugin, String goal, Xpp3Dom configuration ) throws MojoExecutionException, PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException, MojoFailureException, PluginConfigurationException, PluginManagerException { if ( configuration == null ) { throw new NullPointerException( "configuration may not be null" ); } PluginDescriptor pluginDescriptor = getPluginDescriptor( plugin ); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal ); if ( mojoDescriptor == null ) { throw new MojoExecutionException( "Could not find goal '" + goal + "' in plugin " + plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion() ); } MojoExecution exec = mojoExecution( mojoDescriptor, configuration ); pluginManager.executeMojo( getMavenSession(), exec ); }
Example #14
Source File: MultiStartMojo.java From thorntail with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected void startProject(MavenProject project, String executionId, XmlPlexusConfiguration process) throws InvalidPluginDescriptorException, PluginResolutionException, PluginDescriptorParsingException, PluginNotFoundException, PluginConfigurationException, MojoFailureException, MojoExecutionException, PluginManagerException { Plugin plugin = this.project.getPlugin(THORNTAIL_MAVEN_PLUGIN); Xpp3Dom config = getConfiguration(project, executionId); Xpp3Dom processConfig = getProcessConfiguration(process); Xpp3Dom globalConfig = getGlobalConfig(); Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom(processConfig, config); mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, globalConfig); PluginDescriptor pluginDescriptor = this.pluginManager.loadPlugin(plugin, project.getRemotePluginRepositories(), this.repositorySystemSession); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("start"); MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, mergedConfig); mavenSession.setCurrentProject(project); this.pluginManager.executeMojo(mavenSession, mojoExecution); List<SwarmProcess> launched = (List<SwarmProcess>) mavenSession.getPluginContext(pluginDescriptor, project).get(THORNTAIL_PROCESS); List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get(THORNTAIL_PROCESS); if (procs == null) { procs = new ArrayList<>(); getPluginContext().put(THORNTAIL_PROCESS, procs); } procs.addAll(launched); mavenSession.setCurrentProject(this.project); }
Example #15
Source File: SARLProjectConfigurator.java From sarl with Apache License 2.0 | 5 votes |
/** Read the SARL configuration. * * @param request the configuration request. * @param monitor the monitor. * @return the SARL configuration. * @throws CoreException if something wrong appends. */ protected SARLConfiguration readConfiguration(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException { SARLConfiguration initConfig = null; SARLConfiguration compileConfig = null; final List<MojoExecution> mojos = getMojoExecutions(request, monitor); for (final MojoExecution mojo : mojos) { final String goal = mojo.getGoal(); switch (goal) { case "initialize": //$NON-NLS-1$ initConfig = readInitializeConfiguration(request, mojo, monitor); break; case "compile": //$NON-NLS-1$ case "testCompile": //$NON-NLS-1$ compileConfig = readCompileConfiguration(request, mojo, monitor); break; default: } } if (compileConfig != null && initConfig != null) { compileConfig.setFrom(initConfig); } return compileConfig; }
Example #16
Source File: AbstractExecutionHandler.java From pipeline-maven-plugin with MIT License | 5 votes |
public boolean handle(@Nonnull Object event) { if (!(event instanceof ExecutionEvent)) { return false; } ExecutionEvent executionEvent = (ExecutionEvent) event; ExecutionEvent.Type supportedType = getSupportedType(); if (supportedType != null && !(supportedType.equals(executionEvent.getType()))) { return false; } String supportedGoal = getSupportedPluginGoal(); if (supportedGoal == null) { return _handle(executionEvent); } else { String[] gag = supportedGoal.split(":"); if (gag.length == 3) { MojoExecution execution = executionEvent.getMojoExecution(); if (execution.getGroupId().equals(gag[0]) && execution.getArtifactId().equals(gag[1]) && execution.getGoal().equals(gag[2])) { _handle(executionEvent); return true; } else { return false; } } else { reporter.print(toString() + " - unsupported supportedPluginGoal:" + supportedGoal); return false; } } }
Example #17
Source File: WtpMavenProjectConfigurator.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
@Override public AbstractBuildParticipant getBuildParticipant(IMavenProjectFacade projectFacade, MojoExecution execution, IPluginExecutionMetadata executionMetadata) { GwtMavenPlugin.logInfo("WtpMavenProjectConfigurator.getBuildParticipant invoked"); return super.getBuildParticipant(projectFacade, execution, executionMetadata); }
Example #18
Source File: MultiStartMojo.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected void startProject(MavenProject project, String executionId, XmlPlexusConfiguration process) throws InvalidPluginDescriptorException, PluginResolutionException, PluginDescriptorParsingException, PluginNotFoundException, PluginConfigurationException, MojoFailureException, MojoExecutionException, PluginManagerException { Plugin plugin = this.project.getPlugin("org.wildfly.swarm:wildfly-swarm-plugin"); Xpp3Dom config = getConfiguration(project, executionId); Xpp3Dom processConfig = getProcessConfiguration(process); Xpp3Dom globalConfig = getGlobalConfig(); Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom(processConfig, config); mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, globalConfig); PluginDescriptor pluginDescriptor = this.pluginManager.loadPlugin(plugin, project.getRemotePluginRepositories(), this.repositorySystemSession); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("start"); MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, mergedConfig); mavenSession.setCurrentProject(project); this.pluginManager.executeMojo(mavenSession, mojoExecution); List<SwarmProcess> launched = (List<SwarmProcess>) mavenSession.getPluginContext(pluginDescriptor, project).get("swarm-process"); List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get("swarm-process"); if (procs == null) { procs = new ArrayList<>(); getPluginContext().put("swarm-process", procs); } procs.addAll(launched); mavenSession.setCurrentProject(this.project); }
Example #19
Source File: CompileTest.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
@Test public void testBinaryTypeMessage() throws Exception { // javac (tested with 1.8.0_05 and 1.7.0_45) produce warning messages for dependency .class files in some cases // the point of this test is to verify compile mojo tolerates this messages, i.e. does not fail // in this particular test, the message is triggered by missing @annotation referenced from a dependency class File basedir = resources.getBasedir("compile/binary-class-message"); MavenProject project = mojos.readMavenProject(new File(basedir, "project")); MavenSession session = mojos.newMavenSession(project); MojoExecution execution = mojos.newMojoExecution(); addDependency(project, "dependency", new File(basedir, "annotated.zip")); mojos.executeMojo(session, project, execution); mojos.assertBuildOutputs(new File(basedir, "project/target/classes"), "project/Project.class"); }
Example #20
Source File: MojoExecutionName.java From maven-buildtime-extension with MIT License | 5 votes |
public MojoExecutionName(MojoExecution mojoExecution) { name = String.format(Locale.ENGLISH, "%s:%s (%s)", mojoExecution.getArtifactId(), mojoExecution.getGoal(), mojoExecution.getExecutionId()); }
Example #21
Source File: XtextProjectConfigurator.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private void configureLanguages(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException { List<MojoExecution> executions = getMojoExecutions(request, monitor); SubMonitor progress = SubMonitor.convert(monitor, executions.size()); for (MojoExecution execution : executions) { Languages languages = maven.getMojoParameterValue(request.getMavenProject(), execution, "languages", Languages.class, progress.split(1)); if(languages!=null) { ProjectScope projectPreferences = new ProjectScope(request.getProject()); for (Language language : languages) { configureLanguage(projectPreferences, language, request); } } } }
Example #22
Source File: MultiStartMojo.java From wildfly-swarm with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected void startProject(MavenProject project, String executionId, XmlPlexusConfiguration process) throws InvalidPluginDescriptorException, PluginResolutionException, PluginDescriptorParsingException, PluginNotFoundException, PluginConfigurationException, MojoFailureException, MojoExecutionException, PluginManagerException { Plugin plugin = this.project.getPlugin("org.wildfly.swarm:wildfly-swarm-plugin"); Xpp3Dom config = getConfiguration(project, executionId); Xpp3Dom processConfig = getProcessConfiguration(process); Xpp3Dom globalConfig = getGlobalConfig(); Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom(processConfig, config); mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, globalConfig); PluginDescriptor pluginDescriptor = this.pluginManager.loadPlugin(plugin, project.getRemotePluginRepositories(), this.repositorySystemSession); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("start"); MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, mergedConfig); mavenSession.setCurrentProject(project); this.pluginManager.executeMojo(mavenSession, mojoExecution); List<SwarmProcess> launched = (List<SwarmProcess>) mavenSession.getPluginContext(pluginDescriptor, project).get("swarm-process"); List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get("swarm-process"); if (procs == null) { procs = new ArrayList<>(); getPluginContext().put("swarm-process", procs); } procs.addAll(launched); mavenSession.setCurrentProject(this.project); }
Example #23
Source File: IntegrationTest.java From twirl-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void doNotAddSourceRootWhenConfiguredAsSuch() throws Exception { File basedir = resources.getBasedir("hello-world-not-adding-source-root"); MavenProject project = rule.readMavenProject(basedir); MavenSession session = rule.newMavenSession(project); MojoExecution execution = rule.newMojoExecution("compile"); rule.executeMojo(session, project, execution); String expected = new File(basedir, "target/generated-sources/twirl").getAbsolutePath(); assertThat(project.getCompileSourceRoots()).doesNotContain(expected); }
Example #24
Source File: MojoExecutionServiceTest.java From docker-maven-plugin with Apache License 2.0 | 5 votes |
private void standardSetup() throws Exception { new Expectations() {{ project.getPlugin(PLUGIN_NAME); result = new Plugin(); pluginDescriptor.getMojo(GOAL_NAME); result = createPluginDescriptor(); pluginManager.executeMojo(session, (MojoExecution) any); executionService.getPluginDescriptor((MavenProject) any, (Plugin) any); }}; }
Example #25
Source File: LeftOverPrevention.java From spring-cloud-contract with Apache License 2.0 | 5 votes |
LeftOverPrevention(File generatedDirectory, MojoExecution mojoExecution, MavenSession session) throws MojoExecutionException { this.generatedDirectory = generatedDirectory; this.incrementalBuildHelper = new IncrementalBuildHelper(mojoExecution, session); this.incrementalBuildHelper.beforeRebuildExecution( new IncrementalBuildHelperRequest().outputDirectory(generatedDirectory)); }
Example #26
Source File: JApiCmpMojoTest.java From japicmp with Apache License 2.0 | 5 votes |
@Test public void testIgnoreMissingVersions() throws MojoFailureException, IOException, MojoExecutionException { JApiCmpMojo mojo = new JApiCmpMojo(); Version oldVersion = createVersion("groupId", "artifactId", "0.1.0"); Version newVersion = createVersion("groupId", "artifactId", "0.1.1"); Parameter parameterParam = new Parameter(); parameterParam.setIgnoreMissingNewVersion(true); parameterParam.setIgnoreMissingOldVersion(true); PluginParameters pluginParameters = new PluginParameters(false, newVersion, oldVersion, parameterParam, null, Optional.of(Paths.get(System.getProperty("user.dir"), "target", "simple").toFile()), Optional.<String>absent(), true, null, null, null, null); ArtifactResolver artifactResolver = mock(ArtifactResolver.class); ArtifactResolutionResult artifactResolutionResult = mock(ArtifactResolutionResult.class); Set<Artifact> artifactSet = new HashSet<>(); when(artifactResolutionResult.getArtifacts()).thenReturn(artifactSet); when(artifactResolver.resolve(Matchers.<ArtifactResolutionRequest>anyObject())).thenReturn(artifactResolutionResult); ArtifactFactory artifactFactory = mock(ArtifactFactory.class); when(artifactFactory.createArtifactWithClassifier(eq("groupId"), eq("artifactId"), eq("0.1.1"), anyString(), anyString())).thenReturn(mock(Artifact.class)); MojoExecution mojoExecution = mock(MojoExecution.class); String executionId = "ignoreMissingVersions"; when(mojoExecution.getExecutionId()).thenReturn(executionId); MavenProject mavenProject = mock(MavenProject.class); when(mavenProject.getArtifact()).thenReturn(mock(Artifact.class)); MavenParameters mavenParameters = new MavenParameters(new ArrayList<ArtifactRepository>(), artifactFactory, mock(ArtifactRepository.class), artifactResolver, mavenProject, mojoExecution, "0.0.1", mock(ArtifactMetadataSource.class)); mojo.executeWithParameters(pluginParameters, mavenParameters); assertThat(Files.exists(Paths.get(System.getProperty("user.dir"), "target", "simple", "japicmp", executionId + ".diff")), is(false)); assertThat(Files.exists(Paths.get(System.getProperty("user.dir"), "target", "simple", "japicmp", executionId + ".xml")), is(false)); assertThat(Files.exists(Paths.get(System.getProperty("user.dir"), "target", "simple", "japicmp", executionId + ".html")), is(false)); }
Example #27
Source File: MojoSpy.java From vertx-maven-plugin with Apache License 2.0 | 5 votes |
private void addExecutionIfNotContainedAlready(MojoExecution execution) { String artifact = execution.getArtifactId(); String id = execution.getExecutionId(); // We must avoid duplicates in the list for (MojoExecution exec : MOJOS) { if (exec.getArtifactId().equals(artifact) && exec.getExecutionId().equals(id)) { // Duplicate found. return; } } MOJOS.add(execution); }
Example #28
Source File: AbstractCompileJdtTest.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
@Override public org.apache.maven.plugin.MojoExecution newMojoExecution() { MojoExecution execution = super.newMojoExecution(); Xpp3Dom compilerId = new Xpp3Dom("compilerId"); compilerId.setValue("jdt"); execution.getConfiguration().addChild(compilerId); return execution; }
Example #29
Source File: TestPropertiesMojoTest.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
private MojoExecution newMojoExecution(Xpp3Dom... parameters) throws IOException { MojoExecution execution = mojos.newMojoExecution("testProperties", parameters); PluginDescriptor pluginDescriptor = execution.getMojoDescriptor().getPluginDescriptor(); ArtifactHandler handler = new DefaultArtifactHandler("jar"); DefaultArtifact workspaceResolver = new DefaultArtifact("io.takari.m2e.workspace", "org.eclipse.m2e.workspace.cli", "1", Artifact.SCOPE_COMPILE, ".jar", null, handler); workspaceResolver.setFile(new File("target/workspaceResolver.jar").getCanonicalFile()); List<Artifact> pluginArtifacts = new ArrayList<>(pluginDescriptor.getArtifacts()); pluginArtifacts.add(workspaceResolver); pluginDescriptor.setArtifacts(pluginArtifacts); return execution; }
Example #30
Source File: MojoExecutionNameTest.java From maven-buildtime-extension with MIT License | 5 votes |
@Test public void getName() throws Exception { Plugin plugin = new Plugin(); plugin.setArtifactId("artifact"); MojoExecution execution = new MojoExecution(plugin, "goal", "id"); MojoExecutionName executionName = new MojoExecutionName(execution); assertEquals("artifact:goal (id)", executionName.getName()); }