List of usage examples for org.apache.maven.plugin MojoExecution getPlugin
public Plugin getPlugin()
From source file:com.carrotgarden.m2e.scr.BuildParticipant.java
License:BSD License
/** * //from ww w . jav a 2 s . c om * this version of parameter lookup seems to work * * {@link org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator} * * */ protected <T> T getParameterValue(final String parameter, final Class<T> asType) throws CoreException { final MavenSession session = getSession(); final MojoExecution mojoExecution = getMojoExecution(); // final Plugin plugin = mojoExecution.getPlugin(); final PluginExecution execution = new PluginExecution(); execution.setConfiguration(mojoExecution.getConfiguration()); final String goal = mojoExecution.getGoal(); // final T value = getMaven().getMojoParameterValue(parameter, asType, session, plugin, execution, goal); // log.info("@@@ value=" + value); return value; }
From source file:com.ccoe.build.profiler.profile.MojoProfile.java
License:Apache License
public MojoProfile(Context c, MojoExecution mojoExecution, ExecutionEvent event) { super(new Timer(), event, c); this.mojoExecution = mojoExecution; this.pluginGroupID = mojoExecution.getGroupId(); this.pluginArtifactID = mojoExecution.getArtifactId(); this.pluginVersion = mojoExecution.getVersion(); this.pluginExecutionId = mojoExecution.getExecutionId(); this.event = event; // get the configuration of the plugin if the group id matches the KEY. // please replace the KEY String configuration = ""; if (mojoExecution.getPlugin().getConfiguration() != null && mojoExecution.getPlugin().getGroupId().contains("KEY")) { configuration = mojoExecution.getPlugin().getConfiguration().toString(); }//from w w w . ja v a 2 s . c o m String payload = " (" + pluginExecutionId + ") " + configuration; if (getSession() != null) { plugin.setGroupId(pluginGroupID); plugin.setArtifactId(pluginArtifactID); plugin.setVersion(pluginVersion); plugin.setPluginKey(mojoExecution.getPlugin().getId()); plugin.setStartTime(new Date(this.getTimer().getStartTime())); plugin.setPayload(payload); plugin.setExecutionId(pluginExecutionId); if (getSession().getCurrentProject().getPhases().size() > 0) { getSession().getCurrentProject().getLastPhase().getPlugins().add(plugin); } } }
From source file:com.techadvantage.tycho.extras.buildtimestamp.svnkit.SVNKitBuildTimestampProvider.java
License:Open Source License
private String getLogin(MojoExecution execution) { Xpp3Dom pluginConfiguration = (Xpp3Dom) execution.getPlugin().getConfiguration(); Xpp3Dom ignoreDom = pluginConfiguration.getChild("svnkit.login"); if (ignoreDom == null) { return null; }//from ww w . j a va 2 s . c o m return ignoreDom.getValue(); }
From source file:com.techadvantage.tycho.extras.buildtimestamp.svnkit.SVNKitBuildTimestampProvider.java
License:Open Source License
private String getPassword(MojoExecution execution) { Xpp3Dom pluginConfiguration = (Xpp3Dom) execution.getPlugin().getConfiguration(); Xpp3Dom ignoreDom = pluginConfiguration.getChild("svnkit.password"); if (ignoreDom == null) { return null; }/*from ww w . jav a 2s .c om*/ return ignoreDom.getValue(); }
From source file:io.fabric8.vertx.maven.plugin.utils.MojoExecutor.java
License:Apache License
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();//from w w w . ja va 2s . com }
From source file:net.rapicault.maveninspector.views.MojoLabelProvider.java
License:Open Source License
@Override public String getColumnText(Object element, int columnIndex) { MojoExecution mojoToPrint = null; if (element instanceof MojoExecution) { mojoToPrint = (MojoExecution) element; } else {/*w w w . j av a 2 s .c o m*/ return ""; } if (ColumnNames.PHASE.ordinal() == columnIndex) { return mojoToPrint.getLifecyclePhase(); } if (ColumnNames.GOAL.ordinal() == columnIndex) { return mojoToPrint.getGoal(); } if (ColumnNames.PLUGIN.ordinal() == columnIndex) { return mojoToPrint.getPlugin().getId(); } return ""; }
From source file:org.bitstrings.eclipse.m2e.connectors.xmlbeans.XmlBeansProjectConfigurator.java
License:Open Source License
@Override public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException { super.configure(request, monitor); for (MojoExecution mojoExecution : getMojoExecutions(request, monitor)) { Object configuration = mojoExecution.getPlugin().getConfiguration(); Xpp3Dom conf = (Xpp3Dom) configuration; // Force the noJavac option to 'true' Eclipse will compile the code // so no point having XMLBeans do it. Xpp3Dom noJavac = conf.getChild("noJavac"); if (noJavac == null) { noJavac = new Xpp3Dom("noJavac"); conf.addChild(noJavac);//from w ww . j av a 2 s . c o m } noJavac.setValue(Boolean.TRUE.toString()); } }
From source file:org.eclipse.ecf.tycho.extras.buildtimestamp.jgit.JGitMinBuildTimestampProvider.java
License:Open Source License
private static Date getMinimumTimestamp(MojoExecution execution) throws MojoExecutionException { Xpp3Dom pluginConfiguration = (Xpp3Dom) execution.getPlugin().getConfiguration(); if (pluginConfiguration == null) { return new Date(0); }//from w w w .jav a 2 s. c o m Xpp3Dom ignoreDom = pluginConfiguration.getChild("jgit.minimum"); if (ignoreDom == null) { return new Date(0); } try { long stamp = Long.parseLong(ignoreDom.getValue()); return new Date(stamp * 1000); } catch (NumberFormatException e) { throw new MojoExecutionException("jgit.minimum could not be parsed as a timestamp", e); } }
From source file:org.eclipse.m2e.core.internal.embedder.MavenImpl.java
License:Open Source License
@SuppressWarnings("deprecation") public MojoExecution setupMojoExecution(MavenSession session, MavenProject project, MojoExecution execution) throws CoreException { MojoExecution clone = new MojoExecution(execution.getPlugin(), execution.getGoal(), execution.getExecutionId()); clone.setMojoDescriptor(execution.getMojoDescriptor()); if (execution.getConfiguration() != null) { clone.setConfiguration(new Xpp3Dom(execution.getConfiguration())); }//from w w w. jav a 2 s .com clone.setLifecyclePhase(execution.getLifecyclePhase()); LifecycleExecutionPlanCalculator executionPlanCalculator = lookup(LifecycleExecutionPlanCalculator.class); try { executionPlanCalculator.setupMojoExecution(session, project, clone); } catch (Exception ex) { throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, NLS.bind(Messages.MavenImpl_error_calc_build_plan, ex.getMessage()), ex)); } return clone; }
From source file:org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory.java
License:Open Source License
private static List<LifecycleMappingMetadataSource> getMavenPluginEmbeddedMetadataSources( List<MojoExecution> mojoExecutions, List<ArtifactRepository> remoteRepositories, IProgressMonitor monitor) {//from w w w. jav a 2 s. com Map<File, LifecycleMappingMetadataSource> result = new LinkedHashMap<File, LifecycleMappingMetadataSource>(); if (mojoExecutions == null || mojoExecutions.isEmpty()) { // TODO need to understand under what conditions execution plan is null here return Collections.emptyList(); } MavenImpl maven = (MavenImpl) MavenPlugin.getMaven(); for (MojoExecution execution : mojoExecutions) { Artifact artifact; try { artifact = maven.resolvePluginArtifact(execution.getPlugin(), remoteRepositories, monitor); } catch (CoreException e) { // skip this plugin, it won't run anyways continue; } File file = artifact.getFile(); if (file == null || result.containsKey(file) || !file.canRead()) { continue; } LifecycleMappingMetadataSource metadata = readMavenPluginEmbeddedMetadata(artifact); if (metadata != null) { // enforce embedded metadata only contains mappings for this plugin and nothing else for (LifecycleMappingMetadata lifecycleMetadta : metadata.getLifecycleMappings()) { enforcePluginMapping(artifact, lifecycleMetadta.getPluginExecutions()); } enforcePluginMapping(artifact, metadata.getPluginExecutions()); result.put(file, metadata); } } return new ArrayList<LifecycleMappingMetadataSource>(result.values()); }