Example usage for org.apache.maven.plugin MojoExecution getVersion

List of usage examples for org.apache.maven.plugin MojoExecution getVersion

Introduction

In this page you can find the example usage for org.apache.maven.plugin MojoExecution getVersion.

Prototype

public String getVersion() 

Source Link

Usage

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  . jav  a 2 s .  c om
    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.soebes.maven.extensions.MojoTimer.java

License:Apache License

private MojoKey createMojoKey(MojoExecution mojo) {
    return new MojoKey(mojo.getGroupId(), mojo.getArtifactId(), mojo.getVersion(), mojo.getGoal(),
            mojo.getExecutionId(), mojo.getLifecyclePhase());
}

From source file:hudson.gridmaven.util.ExecutionEventLogger.java

License:Apache License

private void append(StringBuilder buffer, MojoExecution me) {
    buffer.append(me.getArtifactId()).append(':').append(me.getVersion());
    buffer.append(':').append(me.getGoal());
    if (me.getExecutionId() != null) {
        buffer.append(" (").append(me.getExecutionId()).append(')');
    }// w  w w  .j a  v a  2 s .c o m
}

From source file:io.reactiverse.vertx.maven.plugin.mojos.AbstractRunMojo.java

License:Apache License

private Callable<Void> toTask(MojoExecution execution) {
    MojoExecutor executor = new MojoExecutor(execution, project, mavenSession, buildPluginManager);

    return () -> {
        try {// ww  w.  j  a  v a  2s  . com
            //--- 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;
    };
}

From source file:org.commonjava.emb.boot.log.EventLogger.java

License:Apache License

private void append(final StringBuilder buffer, final MojoExecution me) {
    buffer.append(me.getArtifactId()).append(':').append(me.getVersion());
    buffer.append(':').append(me.getGoal());
    if (me.getExecutionId() != null) {
        buffer.append(" (").append(me.getExecutionId()).append(')');
    }//from  w  w  w.ja v  a 2 s  . c  o  m
}

From source file:org.eclipse.m2e.core.project.configurator.MojoExecutionKey.java

License:Open Source License

public MojoExecutionKey(MojoExecution mojoExecution) {
    groupId = mojoExecution.getGroupId();
    artifactId = mojoExecution.getArtifactId();
    version = mojoExecution.getVersion();
    goal = mojoExecution.getGoal();//  w  w w. j a v  a2s  . c om
    executionId = mojoExecution.getExecutionId();
    lifecyclePhase = mojoExecution.getLifecyclePhase();
}

From source file:org.eclipse.m2e.core.project.configurator.MojoExecutionKey.java

License:Open Source License

public boolean match(MojoExecution mojoExecution) {
    if (mojoExecution == null) {
        return false;
    }/* w  w w .  j a  va 2 s  .c  o  m*/
    return groupId.equals(mojoExecution.getGroupId()) && artifactId.equals(mojoExecution.getArtifactId())
            && version.equals(mojoExecution.getVersion()) && goal.equals(mojoExecution.getGoal())
            && executionId.equals(mojoExecution.getExecutionId());
}

From source file:org.eclipse.m2e.wtp.MavenDeploymentDescriptorManagement.java

License:Open Source License

/**
 * Executes ear:generate-application-xml goal to generate application.xml (and jboss-app.xml if needed). Existing
 * files will be overwritten.//from w  w  w .j  av a2  s .co m
 * 
 * @throws CoreException
 */

public void updateConfiguration(IProject project, MavenProject mavenProject, EarPluginConfiguration plugin,
        boolean useBuildDirectory, IProgressMonitor monitor) throws CoreException {

    IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
    IMavenProjectFacade mavenFacade = projectManager.getProject(project);
    IMaven maven = MavenPlugin.getMaven();
    //Create a maven request + session
    IFile pomResource = project.getFile(IMavenConstants.POM_FILE_NAME);
    MavenExecutionRequest request = projectManager.createExecutionRequest(pomResource,
            mavenFacade.getResolverConfiguration(), monitor);
    MavenSession session = maven.createSession(request, mavenProject);

    MavenExecutionPlan executionPlan = maven.calculateExecutionPlan(session, mavenProject,
            Collections.singletonList("ear:generate-application-xml"), true, monitor);
    MojoExecution genConfigMojo = getExecution(executionPlan, "maven-ear-plugin", "generate-application-xml");
    if (genConfigMojo == null) {
        //TODO Better error management
        return;
    }

    //Let's force the generated config files location
    Xpp3Dom configuration = genConfigMojo.getConfiguration();
    if (configuration == null) {
        configuration = new Xpp3Dom("configuration");
        genConfigMojo.setConfiguration(configuration);
    }

    File tempDirectory;
    try {
        tempDirectory = getTempDirectory();
    } catch (IOException ex) {
        IStatus status = new Status(IStatus.ERROR, MavenWtpPlugin.ID, ex.getLocalizedMessage(), ex);
        throw new CoreException(status);
    }

    // Some old maven-ear-plugin have a dependency on an old plexus-util version that prevents
    // using workdirectory == generatedDescriptorLocation, so we keep them separated 
    File generatedDescriptorLocation = new File(tempDirectory, "generatedDescriptorLocation");
    File workDirectory = new File(tempDirectory, "workDirectory");

    Xpp3Dom workDirectoryDom = configuration.getChild("workDirectory");
    if (workDirectoryDom == null) {
        workDirectoryDom = new Xpp3Dom("workDirectory");
        configuration.addChild(workDirectoryDom);
    }
    workDirectoryDom.setValue(workDirectory.getAbsolutePath());

    Xpp3Dom genDescriptorLocationDom = configuration.getChild("generatedDescriptorLocation");
    if (genDescriptorLocationDom == null) {
        genDescriptorLocationDom = new Xpp3Dom("generatedDescriptorLocation");
        configuration.addChild(genDescriptorLocationDom);
    }
    genDescriptorLocationDom.setValue(generatedDescriptorLocation.getAbsolutePath());

    // Fix for http://jira.codehaus.org/browse/MEAR-116?focusedCommentId=232316&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_232316
    // affecting maven-ear-plugin version < 2.4.3
    if (!VALID_EAR_PLUGIN_RANGE.containsVersion(new DefaultArtifactVersion(genConfigMojo.getVersion()))) {
        //System.err.println("overriding modules for ear plugin "+genConfigMojo.getVersion());
        overrideModules(configuration, plugin.getAllEarModules());
    }

    //Execute our modified mojo
    maven.execute(session, genConfigMojo, monitor);

    if (session.getResult().hasExceptions()) {
        IMavenMarkerManager markerManager = MavenPluginActivator.getDefault().getMavenMarkerManager();
        markerManager.addMarkers(mavenFacade.getPom(),
                MavenWtpConstants.WTP_MARKER_GENERATE_APPLICATIONXML_ERROR, session.getResult());
    }

    //Copy generated files to their final location
    File[] files = generatedDescriptorLocation.listFiles();

    //MECLIPSEWTP-56 : application.xml should not be generated in the source directory

    IFolder targetFolder;
    IFolder earResourcesFolder = getEarResourcesDir(project, mavenProject, monitor);
    if (useBuildDirectory) {
        targetFolder = earResourcesFolder;
    } else {
        targetFolder = project.getFolder(plugin.getEarContentDirectory(project));

        if (earResourcesFolder.exists() && earResourcesFolder.isAccessible()) {
            earResourcesFolder.delete(true, monitor);
        }
    }

    IFolder metaInfFolder = targetFolder.getFolder("/META-INF/");

    if (files != null && files.length > 0) {
        //We generated something
        try {
            ImportOperation op = new ImportOperation(metaInfFolder.getFullPath(), generatedDescriptorLocation,
                    new FileSystemStructureProvider(), OVERWRITE_ALL_QUERY, Arrays.asList(files));
            op.setCreateContainerStructure(false);
            op.setOverwriteResources(true);

            op.run(monitor);

        } catch (InvocationTargetException ex) {
            IStatus status = new Status(IStatus.ERROR, MavenWtpPlugin.ID, IStatus.ERROR, ex.getMessage(), ex);
            throw new CoreException(status);
        } catch (InterruptedException ex) {
            throw new OperationCanceledException(ex.getMessage());
        }
    }
    targetFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor);

    deleteDirectory(generatedDescriptorLocation);

}

From source file:org.grumblesmurf.malabar.ExecutionEventLogger.java

License:Apache License

@Override
public void mojoStarted(ExecutionEvent event) {
    if (logger.isInfoEnabled()) {
        MojoExecution me = event.getMojoExecution();
        StringBuilder buffer = new StringBuilder(128);

        buffer.append("--- ").append(me.getArtifactId()).append(':').append(me.getVersion()).append(':')
                .append(me.getGoal());/*from   w w  w .  java2 s .c  om*/

        if (me.getExecutionId() != null) {
            buffer.append(" (").append(me.getExecutionId()).append(')');
        }
        buffer.append(" @ ").append(event.getProject().getArtifactId());
        buffer.append(" ---");

        logger.info("");
        logger.info(buffer.toString());
    }
}

From source file:org.jboss.tools.maven.apt.internal.compiler.MavenCompilerExecutionDelegate.java

License:Open Source License

public AbstractBuildParticipant getMojoExecutionBuildParticipant(MojoExecution execution) {
    //<proc></proc> is not available for maven-compiler-plugin < 2.2
    if (VALID_COMPILER_PLUGIN_RANGE.containsVersion(new DefaultArtifactVersion(execution.getVersion()))) {
        // Disabled for now return new MavenCompilerBuildParticipant(execution);
    }/* w  ww .ja v  a2 s  . com*/
    return null;
}