Example usage for org.apache.maven.plugin.descriptor PluginDescriptor getArtifacts

List of usage examples for org.apache.maven.plugin.descriptor PluginDescriptor getArtifacts

Introduction

In this page you can find the example usage for org.apache.maven.plugin.descriptor PluginDescriptor getArtifacts.

Prototype

public List<Artifact> getArtifacts() 

Source Link

Document

Gets the artifacts that make up the plugin's class realm, excluding artifacts shadowed by the Maven core realm like maven-project .

Usage

From source file:io.promagent.plugin.AgentDependencies.java

License:Apache License

private static List<Artifact> resolveVersions(PluginDescriptor pluginDescriptor, String pluginArtifactId,
        List<ExpectedDependency> expectedDependencies) throws MojoExecutionException {
    List<Artifact> actualDependencies = new ArrayList<>();
    for (Artifact artifact : pluginDescriptor.getArtifacts()) {
        if (!isExpected(artifact, expectedDependencies)) {
            continue;
        }//from  www . ja va2s . co m
        if (isKnown(artifact, actualDependencies)) {
            continue;
        }
        failOnVersionConflict(artifact, actualDependencies, pluginArtifactId);
        actualDependencies.add(artifact);
    }
    return actualDependencies;
}

From source file:io.syndesis.maven.ExtractConnectorDescriptorsMojo.java

License:Apache License

@Override
@SuppressWarnings("PMD.EmptyCatchBlock")
public void execute() throws MojoExecutionException, MojoFailureException {

    ArrayNode root = new ArrayNode(JsonNodeFactory.instance);

    URLClassLoader classLoader = null;
    try {/*from  ww  w  .  j  a  v  a 2s. com*/
        PluginDescriptor desc = (PluginDescriptor) getPluginContext().get("pluginDescriptor");
        List<Artifact> artifacts = desc.getArtifacts();
        ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(
                session.getProjectBuildingRequest());
        buildingRequest.setRemoteRepositories(remoteRepositories);
        for (Artifact artifact : artifacts) {
            ArtifactResult result = artifactResolver.resolveArtifact(buildingRequest, artifact);
            File jar = result.getArtifact().getFile();
            classLoader = createClassLoader(jar);
            if (classLoader == null) {
                throw new IOException("Can not create classloader for " + jar);
            }
            ObjectNode entry = new ObjectNode(JsonNodeFactory.instance);
            addConnectorMeta(entry, classLoader);
            addComponentMeta(entry, classLoader);
            if (entry.size() > 0) {
                addGav(entry, artifact);
                root.add(entry);
            }
        }
        if (root.size() > 0) {
            saveCamelMetaData(root);
        }
    } catch (ArtifactResolverException | IOException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    } finally {
        if (classLoader != null) {
            try {
                classLoader.close();
            } catch (IOException ignored) {

            }
        }
    }
}

From source file:org.apache.activemq.artemis.maven.ActiveMQStartPlugin.java

License:Apache License

public void execute() throws MojoExecutionException, MojoFailureException {
    String property = System.getProperty(SKIPBROKERSTART);
    if (property != null) {
        getLog().info("skipping Broker Start");
        return;//from w  w w .  j  ava 2  s  .  c o  m
    }
    if (testClusterManager) {
        try {
            createClusterManagerMBean();
        } catch (Exception e) {
            throw new MojoExecutionException("Failed to create cluster manager mbean", e);
        }
    }

    if (systemProperties != null && !systemProperties.isEmpty()) {
        System.getProperties().putAll(systemProperties);
    }

    String workingPath = new File(".").getAbsolutePath();

    try {
        registerNode(nodeId, workingPath, configurationDir);
    } catch (Exception e1) {
        throw new MojoExecutionException("Failed to create cluster manager mbean", e1);
    }

    if (fork) {
        try {
            PluginDescriptor pd = (PluginDescriptor) getPluginContext().get("pluginDescriptor");
            final Process p = SpawnedVMSupport.spawnVM(pd.getArtifacts(),
                    "ActiveMQServer_" + (nodeId != null ? nodeId : ""),
                    SpawnedActiveMQBootstrap.class.getName(), systemProperties, true, serverStartString,
                    "FAILED::", ".", configurationDir, debug, configurationDir, "" + waitOnStart, nodeId);
            Runtime.getRuntime().addShutdownHook(new Thread() {
                @Override
                public void run() {
                    //just to be on the safe side
                    p.destroy();
                }
            });
            if (waitOnStart) {
                p.waitFor();
            }
        } catch (Throwable e) {
            e.printStackTrace();
            throw new MojoExecutionException(e.getMessage());
        }
    } else {
        ActiveMQBootstrap bootstrap = new ActiveMQBootstrap(configurationDir, waitOnStart, nodeId,
                securityManager);
        if (configurationDir != null) {
            extendPluginClasspath(configurationDir);
        }
        try {
            bootstrap.execute();
        } catch (Exception e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }
    }
}

From source file:org.apache.activemq.maven.ActiveMQStartPlugin.java

License:Apache License

public void execute() throws MojoExecutionException, MojoFailureException {
    if (testClusterManager) {
        try {/*from w  w w .  j  a v a  2 s . c o m*/
            createClusterManagerMBean();
        } catch (Exception e) {
            throw new MojoExecutionException("Failed to create cluster manager mbean", e);
        }
    }

    if (systemProperties != null && !systemProperties.isEmpty()) {
        System.getProperties().putAll(systemProperties);
    }

    String workingPath = new File(".").getAbsolutePath();

    try {
        registerNode(nodeId, workingPath, configurationDir);
    } catch (Exception e1) {
        throw new MojoExecutionException("Failed to create cluster manager mbean", e1);
    }

    if (fork) {
        try {
            PluginDescriptor pd = (PluginDescriptor) getPluginContext().get("pluginDescriptor");
            final Process p = SpawnedVMSupport.spawnVM(pd.getArtifacts(),
                    "ActiveMQServer_" + (nodeId != null ? nodeId : ""),
                    SpawnedActiveMQBootstrap.class.getName(), systemProperties, true, serverStartString,
                    "FAILED::", ".", configurationDir, debug, configurationDir, "" + waitOnStart, nodeId);
            Runtime.getRuntime().addShutdownHook(new Thread() {
                @Override
                public void run() {
                    //just to be on the safe side
                    p.destroy();
                }
            });
            if (waitOnStart) {
                p.waitFor();
            }
        } catch (Throwable e) {
            e.printStackTrace();
            throw new MojoExecutionException(e.getMessage());
        }
    } else {
        ActiveMQBootstrap bootstrap = new ActiveMQBootstrap(configurationDir, waitOnStart, nodeId,
                securityManager);
        if (configurationDir != null) {
            extendPluginClasspath(configurationDir);
        }
        try {
            bootstrap.execute();
        } catch (Exception e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }
    }
}

From source file:org.hornetq.maven.HornetQStartPlugin.java

License:Apache License

public void execute() throws MojoExecutionException, MojoFailureException {
    if (testClusterManager) {
        try {//w w  w  .  j a  v  a  2  s. c  o m
            createClusterManagerMBean();
        } catch (Exception e) {
            throw new MojoExecutionException("Failed to create cluster manager mbean", e);
        }
    }

    if (systemProperties != null && !systemProperties.isEmpty()) {
        System.getProperties().putAll(systemProperties);
    }

    String workingPath = new File(".").getAbsolutePath();

    try {
        registerNode(nodeId, workingPath, hornetqConfigurationDir, jndiPort, jndiRmiPort);
    } catch (Exception e1) {
        throw new MojoExecutionException("Failed to create cluster manager mbean", e1);
    }

    if (fork) {
        try {
            PluginDescriptor pd = (PluginDescriptor) getPluginContext().get("pluginDescriptor");
            final Process p = SpawnedVMSupport.spawnVM(pd.getArtifacts(),
                    "HornetQServer_" + (nodeId != null ? nodeId : ""), SpawnedHornetQBootstrap.class.getName(),
                    systemProperties, true, serverStartString, "FAILED::", ".", hornetqConfigurationDir, debug,
                    useJndi.toString(), jndiHost, "" + jndiPort, "" + jndiRmiPort, hornetqConfigurationDir,
                    "" + waitOnStart, nodeId);
            Runtime.getRuntime().addShutdownHook(new Thread() {
                @Override
                public void run() {
                    //just to be on the safe side
                    p.destroy();
                }
            });
            if (waitOnStart) {
                p.waitFor();
            }
        } catch (Throwable e) {
            e.printStackTrace();
            throw new MojoExecutionException(e.getMessage());
        }
    } else {
        HornetQBootstrap bootstrap = new HornetQBootstrap(useJndi, jndiHost, jndiPort, jndiRmiPort,
                hornetqConfigurationDir, waitOnStart, nodeId, securityManager);
        if (hornetqConfigurationDir != null) {
            extendPluginClasspath(hornetqConfigurationDir);
        }
        try {
            bootstrap.execute();
        } catch (Exception e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }
    }
}

From source file:org.jamon.eclipse.maven.configurator.JamonPluginConfiguration.java

License:Mozilla Public License

public static JamonPluginConfiguration forProjectConfigurationRequest(ProjectConfigurationRequest request,
        IProgressMonitor monitor, IMaven maven) throws CoreException {
    IMavenProjectFacade mavenProjectFacade = request.getMavenProjectFacade();

    for (MojoExecution execution : mavenProjectFacade.getMojoExecutions("org.jamon", "jamon-maven-plugin",
            monitor, "translate", "translate-tests")) {
        PluginDescriptor pluginDescriptor = execution.getMojoDescriptor().getPluginDescriptor();

        Object mojo = maven.getConfiguredMojo(request.getMavenSession(), execution, Object.class);
        Artifact jamonProcessorArtifact = null;
        for (Artifact artifact : pluginDescriptor.getArtifacts()) {
            if ("org.jamon".equals(artifact.getGroupId())
                    && "jamon-processor".equals(artifact.getArtifactId())) {
                jamonProcessorArtifact = artifact;
                break;
            }//from ww w. j a v  a 2  s .c  om
        }

        IProject project = request.getProject();
        return new JamonPluginConfiguration(
                getProjectRelativePath(getFileProperty(mojo, "templateSourceDir"), project),
                getProjectRelativePath(getFileProperty(mojo, "templateOutputDir"), project),
                jamonProcessorArtifact);

    }
    return null;
}