Java Code Examples for org.apache.maven.plugin.descriptor.PluginDescriptor#getArtifacts()
The following examples show how to use
org.apache.maven.plugin.descriptor.PluginDescriptor#getArtifacts() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AgentDependencies.java From promagent with Apache License 2.0 | 5 votes |
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; } if (isKnown(artifact, actualDependencies)) { continue; } failOnVersionConflict(artifact, actualDependencies, pluginArtifactId); actualDependencies.add(artifact); } return actualDependencies; }
Example 2
Source File: TestPropertiesMojoTest.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
private MojoExecution newMojoExecution(Xpp3Dom... parameters) throws IOException { MojoExecution execution = mojos.newMojoExecution("testProperties", parameters); PluginDescriptor pluginDescriptor = execution.getMojoDescriptor().getPluginDescriptor(); ArtifactHandler handler = new DefaultArtifactHandler("jar"); DefaultArtifact workspaceResolver = new DefaultArtifact("io.takari.m2e.workspace", "org.eclipse.m2e.workspace.cli", "1", Artifact.SCOPE_COMPILE, ".jar", null, handler); workspaceResolver.setFile(new File("target/workspaceResolver.jar").getCanonicalFile()); List<Artifact> pluginArtifacts = new ArrayList<>(pluginDescriptor.getArtifacts()); pluginArtifacts.add(workspaceResolver); pluginDescriptor.setArtifacts(pluginArtifacts); return execution; }
Example 3
Source File: ExtractConnectorDescriptorsMojo.java From syndesis with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings({"PMD.EmptyCatchBlock", "PMD.CyclomaticComplexity"}) public void execute() throws MojoExecutionException, MojoFailureException { ArrayNode root = new ArrayNode(JsonNodeFactory.instance); URLClassLoader classLoader = null; try { 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) { } } } }