List of usage examples for org.apache.maven.execution ExecutionEvent getSession
MavenSession getSession();
From source file:com.ccoe.build.profiler.profile.SessionProfile.java
License:Apache License
public SessionProfile(Context c, ExecutionEvent event, boolean debug) { super(new Timer(), event, c); this.projectProfiles = new ArrayList<ProjectProfile>(); String goal = ""; if (event != null) { goal = event.getSession().getGoals().toString(); }/*from w w w . j av a 2 s . c o m*/ if (getSession() != null) { getSession().setGoals(goal); } }
From source file:com.github.htfv.maven.plugins.buildconfigurator.core.configurators.propertyfiles.PropertyFileConfigurator.java
License:Apache License
/** * Reinterpolates all elements of the project model. * * @param ctx/*from www .j av a2 s . co m*/ * The configuration context. * @param resultBuilder * The result builder. */ private void reinterpolateProjectModel(final ConfigurationContext ctx, final Result.Builder resultBuilder) { // // Maven interpolates expressions when it loads the model. Since the // properties are loaded after the model, we have to interpolate // expressions again. // // It is actually not required for mojo parameters, because parameters // are interpolated before mojo is executed. However, it can be a // problem if mojo accesses model, like maven-resources-plugin accessing // project.build.resources. // // We take a conservative approach and only replace properties which // were loaded by the build configurator. // final ModelInterpolator interpolator = new ModelInterpolator(resultBuilder.newProperties()); interpolator.interpolateModel(ctx.getProject().getModel()); // // Maven interpolates mojo parameters before execution, but it skips // parameters of the PlexusConfiguration type. Updating the model now // has no effect, because execution plan is already calculated and mojo // configuration is copied to mojo execution. We cannot get access to // mojo execution, so we register a listener which will be called before // mojo is executed. // if (!ctx.getRequest().isConnectorRequest()) { final MavenSession mavenSession = ctx.getMavenSession(); final MavenExecutionRequest executionRequest = mavenSession.getRequest(); final ExecutionListener executionListener = executionRequest.getExecutionListener(); executionRequest.setExecutionListener(new DelegatingExecutionListener(executionListener) { @Override public void mojoStarted(final ExecutionEvent event) { interpolator.interpolateDOM(event.getMojoExecution().getConfiguration()); super.mojoStarted(event); } @Override public void projectFailed(final ExecutionEvent event) { event.getSession().getRequest().setExecutionListener(getDelegate()); super.projectFailed(event); } @Override public void projectSucceeded(final ExecutionEvent event) { event.getSession().getRequest().setExecutionListener(getDelegate()); super.projectSucceeded(event); } }); } }
From source file:com.sloshydog.timely.EndSessionSpy.java
License:Apache License
@Override protected void doOnEvent(ExecutionEvent event) { getReportGenerator().createReportFor(event.getSession(), getEventRecorder().getTimedEvents()); }
From source file:com.soebes.maven.extensions.deploy.archiver.DeployArchiver.java
License:Apache License
private boolean goalsContain(ExecutionEvent executionEvent, String goal) { return executionEvent.getSession().getGoals().contains(goal); }
From source file:com.soebes.maven.extensions.deploy.archiver.DeployArchiver.java
License:Apache License
private boolean containsLifeCyclePluginGoals(ExecutionEvent executionEvent, String groupId, String artifactId, String goal) {//from www. ja v a 2 s . co m boolean result = false; List<MavenProject> sortedProjects = executionEvent.getSession().getProjectDependencyGraph() .getSortedProjects(); for (MavenProject mavenProject : sortedProjects) { List<Plugin> buildPlugins = mavenProject.getBuildPlugins(); for (Plugin plugin : buildPlugins) { if (groupId.equals(plugin.getGroupId()) && artifactId.equals(plugin.getArtifactId())) { List<PluginExecution> executions = plugin.getExecutions(); for (PluginExecution pluginExecution : executions) { if (pluginExecution.getGoals().contains(goal)) { result = true; } } } } } return result; }
From source file:com.soebes.maven.extensions.deploy.archiver.DeployArchiver.java
License:Apache License
private void removePluginFromLifeCycle(ExecutionEvent executionEvent, String groupId, String artifactId, String goal) {//from w w w . ja va2 s .co m boolean removed = false; List<MavenProject> sortedProjects = executionEvent.getSession().getProjectDependencyGraph() .getSortedProjects(); for (MavenProject mavenProject : sortedProjects) { List<Plugin> buildPlugins = mavenProject.getBuildPlugins(); for (Plugin plugin : buildPlugins) { LOGGER.debug("Plugin: " + plugin.getId()); List<PluginExecution> printExecutions = plugin.getExecutions(); for (PluginExecution pluginExecution : printExecutions) { LOGGER.debug(" -> " + pluginExecution.getGoals()); } if (groupId.equals(plugin.getGroupId()) && artifactId.equals(plugin.getArtifactId())) { if (!removed) { LOGGER.warn(groupId + ":" + artifactId + ":" + goal + " has been deactivated."); } List<PluginExecution> executions = plugin.getExecutions(); for (PluginExecution pluginExecution : executions) { pluginExecution.removeGoal(goal); removed = true; } } } } }
From source file:com.soebes.maven.extensions.deploy.archiver.DeployArchiver.java
License:Apache License
private void deployProjects(ExecutionEvent executionEvent) { ArtifactRepository repository = executionEvent.getSession().getTopLevelProject() .getDistributionManagementArtifactRepository(); List<MavenProject> sortedProjects = executionEvent.getSession().getProjectDependencyGraph() .getSortedProjects();//from w ww . j a v a2s .co m for (MavenProject mavenProject : sortedProjects) { ProjectDeployerRequest deployRequest = new ProjectDeployerRequest().setProject(mavenProject) .setUpdateReleaseInfo(true); deployProject(executionEvent.getSession().getProjectBuildingRequest(), deployRequest, repository); } }
From source file:com.soebes.maven.extensions.deploy.archiver.DeployArchiver.java
License:Apache License
private void installProjects(ExecutionEvent exec) { // tarArchiver.addFileSet( new DefaultFileSet( targetDirectory ) ); File resultArchive = getArchiveFile(exec.getSession().getTopLevelProject().getBasedir(), ".archive", "bundle", "tar"); tarArchiver.setDestFile(resultArchive); tarArchiver.setCompression(TarCompressionMethod.none); tarArchiver.setLongfile(TarLongFileMode.gnu); List<MavenProject> sortedProjects = exec.getSession().getProjectDependencyGraph().getSortedProjects(); for (MavenProject mavenProject : sortedProjects) { ProjectInstallerRequest pir = new ProjectInstallerRequest().setProject(mavenProject) .setCreateChecksum(true).setUpdateReleaseInfo(true); installProject(exec.getSession().getProjectBuildingRequest(), pir); }/*from w ww .j a v a 2 s. c o m*/ try { tarArchiver.createArchive(); } catch (ArchiverException e) { LOGGER.error(e.getMessage(), e); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } }
From source file:com.sumologic.maven.stats.ProfilePublishingExecutionListener.java
License:Apache License
private SessionProfiler ensureProfilerStarted(ExecutionEvent event) { if (this.sessionProfiler == null) { synchronized (this) { if (this.sessionProfiler == null) { this.sessionProfiler = new SessionProfiler(event.getSession()); }// www . j av a 2 s.co m } } return this.sessionProfiler; }
From source file:com.wielgolaski.maven.profiling.ProfilingExecutionListener.java
License:Apache License
@Override public void sessionEnded(ExecutionEvent event) { final long total = System.currentTimeMillis() - event.getSession().getRequest().getStartTime().getTime(); logger.info("MOJO EXECUTION TIMES"); logger.info("------------------------------------------------------------------------"); final long sum = sum(times.values()); addTime("other", total - sum); // sort by time, descending List<Map.Entry<String, Times>> entries = sortByValue(times.entrySet()); Collections.reverse(entries); for (Map.Entry<String, Times> e : entries) { Times t = e.getValue();/*w w w . j av a2s. c o m*/ logger.info(fmtPercentAligned(t.time, total) + " " + e.getKey() + " " + fmtTime(t.time)); // sort by time, descending List<Map.Entry<String, Long>> nested = sortByValue(t.entries.entrySet()); Collections.reverse(nested); for (Map.Entry<String, Long> n : nested) { String msg = " * " + n.getKey(); // omit repeating data when there is only one entry that is identical to its parent if (nested.size() > 1) { msg += " " + fmtPercent(n.getValue(), total) + " " + fmtTime(n.getValue()); } logger.info(msg); } } logger.info("------------------------------------------------------------------------"); }