/** * Get set of plugins having a goal/mojo used but not marked @threadSafe * * @return the set of plugins (without info on which goal is concerned) */ public Set<Plugin> getNonThreadSafePlugins() { Set<Plugin> plugins = new HashSet<>(); for ( ExecutionPlanItem executionPlanItem : planItem ) { final MojoExecution mojoExecution = executionPlanItem.getMojoExecution(); if ( !mojoExecution.getMojoDescriptor().isThreadSafe() ) { plugins.add( mojoExecution.getPlugin() ); } } return plugins; }
pluginManager.getMojoDescriptor( forkedExecution.getPlugin(), forkedExecution.getGoal(), project.getRemotePluginRepositories(), session.getRepositorySession() );
@Override public void setupMojoExecution( MavenSession session, MavenProject project, MojoExecution mojoExecution ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); if ( mojoDescriptor == null ) { mojoDescriptor = pluginManager.getMojoDescriptor( mojoExecution.getPlugin(), mojoExecution.getGoal(), project.getRemotePluginRepositories(), session.getRepositorySession() ); mojoExecution.setMojoDescriptor( mojoDescriptor ); } mojoExecutionConfigurator( mojoExecution ).configure( project, mojoExecution, MojoExecution.Source.CLI.equals( mojoExecution.getSource() ) ); finalizeMojoConfiguration( mojoExecution ); calculateForkedExecutions( mojoExecution, session, project, new HashSet<MojoDescriptor>() ); }
protected <T> T getParameterValue(final MojoExecution execution, final ConfigurationContainer configurationContainer, final String parameter, final Class<T> asType) throws CoreException { return maven.getMojoParameterValue(mavenProject, parameter, asType, execution.getPlugin(), configurationContainer, execution.getGoal(), monitor); }
public MojoExecutor(MojoExecution execution, MavenProject project, MavenSession session, BuildPluginManager buildPluginManager) { this.build = buildPluginManager; this.project = project; this.session = session; this.plugin = execution.getPlugin(); configuration = execution.getConfiguration(); goal = execution.getGoal(); }
@Override public void execute() throws MojoExecutionException, MojoFailureException { Preconditions.checkNotNull(lifecycleExecutor); Preconditions.checkNotNull(session); MavenExecutionPlan mavenExecutionPlan; try { mavenExecutionPlan = lifecycleExecutor.calculateExecutionPlan(session, "package"); } catch (Exception ex) { throw new MojoExecutionException("failed to calculate execution plan", ex); } mavenExecutionPlan .getMojoExecutions() .stream() .filter(mojoExecution -> "package".equals(mojoExecution.getLifecyclePhase())) .filter( mojoExecution -> MavenProjectProperties.PLUGIN_NAME.equals( mojoExecution.getPlugin().getArtifactId())) .map(MojoExecution::getGoal) .forEach(System.out::println); } }
private List<String> getCompilerPluginClassPaths() { ArrayList<String> result = new ArrayList<>(); List<File> files = new ArrayList<>(); for (Dependency dependency : mojoExecution.getPlugin().getDependencies()) { Artifact artifact = system.createDependencyArtifact(dependency); ArtifactResolutionResult resolved = system.resolve(new ArtifactResolutionRequest().setArtifact(artifact)); for (Artifact resolvedArtifact : resolved.getArtifacts()) { File file = resolvedArtifact.getFile(); if (file != null && file.exists()) { files.add(file); } } } for (File file : files) { result.add(file.getAbsolutePath()); } return result; }
private String mojoExecutionFullId(ExecutionEvent event) { StringBuffer result = new StringBuffer("["); if (event.getMojoExecution() != null) { String phase = event.getMojoExecution().getLifecyclePhase(); if (phase != null) { result.append(phase).append(":"); } Plugin plugin = event.getMojoExecution().getPlugin(); if (plugin != null) { result.append(plugin.getGroupId()).append(":").append(plugin.getArtifactId()).append(":").append(plugin.getVersion()); } String executionId = event.getMojoExecution().getExecutionId(); if (executionId != null) { result.append(":").append(executionId); } String goal = event.getMojoExecution().getGoal(); if (executionId != null) { result.append(":").append(goal); } } result.append("]"); return result.toString(); }
static AggregationKey from(MojoExecution mojoExecution) { return new AggregationKey(mojoExecution.getPlugin().getId(), mojoExecution.getGoal()); }
Collection<String> ignoredPatterns = new HashSet<>(IGNORED_PATTERNS); if (execution != null) { Xpp3Dom pluginConfiguration = (Xpp3Dom) execution.getPlugin().getConfiguration(); if (pluginConfiguration != null) { Xpp3Dom ignoredPatternsNode = pluginConfiguration.getChild("ignoredPatterns");
protected <T> T getParameterValue(String parameter, Class<T> asType, MavenSession session, MojoExecution mojoExecution) throws CoreException { PluginExecution execution = new PluginExecution(); execution.setConfiguration(mojoExecution.getConfiguration()); return maven.getMojoParameterValue(parameter, asType, session, mojoExecution.getPlugin(), execution, mojoExecution.getGoal()); }
mavenProjectRegistry.getProjects(); final List<Dependency> dependencies = mojoExecution.getPlugin().getDependencies(); for (final Dependency dependency : dependencies) { for (final IMavenProjectFacade projectFacade : projects) {
@SuppressWarnings("unchecked") public <T> List<T> getParameterList(final String parameter, @SuppressWarnings("unused") final Class<T> asType) throws CoreException { ConfigurationContainer executionClone = execution.clone(); Xpp3Dom configuration = (Xpp3Dom) executionClone.getConfiguration(); configuration = configuration != null ? configuration.getChild(parameter) : null; if (configuration != null && configuration.getChildCount() > 0) { configuration.setAttribute("default-value", ""); } final List<T> list = maven.getMojoParameterValue(mavenProject, parameter, List.class, mojoExecution.getPlugin(), executionClone, mojoExecution.getGoal(), monitor); if (list == null) { return Collections.emptyList(); } return list; }
@Override public void mojoSucceeded(ExecutionEvent event) { MavenProject project = event.getProject(); if (project == null) { logger.warn("Skipping Artifactory Build-Info dependency extraction: Null project."); return; } if ("maven-surefire-plugin".equals((event).getMojoExecution().getPlugin().getArtifactId())) { List<File> resultsFile = getSurefireResultsFile(project); if (isTestsFailed(resultsFile)) { projectHasTestFailures = true; } } extractModuleDependencies(project); if (wrappedListener != null) { wrappedListener.mojoSucceeded(event); } }
mavenFacade.getMavenProject(), mojoExecution.getPlugin(), monitor);
@Override protected AnnotationProcessorConfiguration getAnnotationProcessorConfiguration(IProgressMonitor monitor) throws CoreException { MojoExecution mojoExecution = getProcessorPluginMojoExecution(mavenFacade, GOAL_PROCESS, monitor); if(mojoExecution == null) { return null; } File generatedOutputDirectory = getParameterValue(OUTPUT_DIRECTORY_PARAMETER, File.class, mavenSession, mojoExecution); PluginDependencyResolver dependencyResolver = new PluginDependencyResolver(); List<File> dependencies = dependencyResolver.getResolvedPluginDependencies(mavenSession, mavenFacade.getMavenProject(), mojoExecution.getPlugin(), monitor); @SuppressWarnings("unchecked") Map<String, String> options = getParameterValue("optionMap", Map.class, mavenSession, mojoExecution); DefaultAnnotationProcessorConfiguration configuration = new DefaultAnnotationProcessorConfiguration(); configuration.setOutputDirectory(generatedOutputDirectory); configuration.setAnnotationProcessingEnabled(true); configuration.setDependencies(dependencies); configuration.setAnnotationProcessorOptions(options); MojoExecution testMojoExecution = getProcessorPluginMojoExecution(mavenFacade, GOAL_PROCESS_TEST, monitor); if(testMojoExecution != null) { File generatedTestOutputDirectory = getParameterValue(OUTPUT_DIRECTORY_PARAMETER, File.class, mavenSession, testMojoExecution); configuration.setTestOutputDirectory(generatedTestOutputDirectory); } return configuration; }