类org.apache.maven.plugin.descriptor.PluginDescriptor源码实例Demo

下面列出了怎么用org.apache.maven.plugin.descriptor.PluginDescriptor的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jax-maven-plugin   文件: Util.java
static Stream<String> getPluginRuntimeDependencyEntries(AbstractMojo mojo, MavenProject project, Log log,
        RepositorySystem repositorySystem, ArtifactRepository localRepository,
        List<ArtifactRepository> remoteRepositories) {
    PluginDescriptor pluginDescriptor = (PluginDescriptor) mojo.getPluginContext().get(PLUGIN_DESCRIPTOR);
    Plugin plugin = project.getBuild().getPluginsAsMap().get(pluginDescriptor.getPluginLookupKey());

    List<ArtifactResolutionResult> artifactResolutionResults = plugin //
            .getDependencies() //
            .stream() //
            .map(repositorySystem::createDependencyArtifact) //
            .map(a -> Util.resolve(log, a, repositorySystem, localRepository, remoteRepositories)) //
            .collect(Collectors.toList());

    Stream<Artifact> originalArtifacts = artifactResolutionResults.stream()
            .map(ArtifactResolutionResult::getOriginatingArtifact);

    Stream<Artifact> childArtifacts = artifactResolutionResults.stream()
            .flatMap(resolutionResult -> resolutionResult.getArtifactResolutionNodes().stream())
            .map(ResolutionNode::getArtifact);

    return Stream.concat(originalArtifacts, childArtifacts).map(Artifact::getFile).map(File::getAbsolutePath);
}
 
源代码2 项目: sofa-ark   文件: RepackageMojo.java
@Override
public void execute() throws MojoExecutionException {
    if ("war".equals(this.project.getPackaging())) {
        getLog().debug("repackage goal could not be applied to war project.");
        return;
    }
    if ("pom".equals(this.project.getPackaging())) {
        getLog().debug("repackage goal could not be applied to pom project.");
        return;
    }
    if (StringUtils.isSameStr(this.arkClassifier, this.bizClassifier)) {
        getLog().debug("Executable fat jar should be different from 'plug-in' module jar.");
        return;
    }
    if (this.skip) {
        getLog().debug("skipping repackaging as configuration.");
        return;
    }

    /* version of ark container packaged into fat jar follows the plugin version */
    PluginDescriptor pluginDescriptor = (PluginDescriptor) getPluginContext().get(
        "pluginDescriptor");
    arkVersion = pluginDescriptor.getVersion();

    repackage();
}
 
源代码3 项目: promagent   文件: AgentDependencies.java
static AgentDependencies init(PluginDescriptor pluginDescriptor) throws MojoExecutionException {

        String pluginGroupId = pluginDescriptor.getGroupId();
        String pluginArtifactId = pluginDescriptor.getArtifactId();

        List<ExpectedDependency> expectedDependencies = Arrays.asList(
                new ExpectedDependency(pluginGroupId, "promagent-agent"),
                new ExpectedDependency(pluginGroupId, "promagent-internal"),
                new ExpectedDependency(pluginGroupId, "promagent-api"),
                new ExpectedDependency("io.prometheus", "simpleclient_common"),
                new ExpectedDependency("io.prometheus", "simpleclient"),
                new ExpectedDependency("net.bytebuddy", "byte-buddy"),
                new ExpectedDependency("commons-io", "commons-io")
        );

        List<Artifact> actualDependencies = resolveVersions(pluginDescriptor, pluginArtifactId, expectedDependencies);
        failUnlessComplete(actualDependencies, expectedDependencies, pluginArtifactId);
        return new AgentDependencies(pluginGroupId, actualDependencies);
    }
 
@Test
public void extractionOfMojoSpecificConfigurationAndMergingwithDefaultMojoConfiguration() throws Exception {
  InputStream is = getClass().getResourceAsStream("/META-INF/maven/plugin.xml");
  assertNotNull(is);
  PluginDescriptor pluginDescriptor = pluginDescriptorBuilder.build(new InputStreamReader(is, "UTF-8"));
  String goal = merger.determineGoal("io.takari.maven.plugins.jar.Jar", pluginDescriptor);
  assertEquals("We expect the goal name to be 'jar'", "jar", goal);
  MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal);
  PlexusConfiguration defaultMojoConfiguration = mojoDescriptor.getMojoConfiguration();
  System.out.println(defaultMojoConfiguration);

  PlexusConfiguration configurationFromMaven = builder("configuration") //
      .es("jar") //
      .es("sourceJar").v("true").ee() //
      .ee() //
      .buildPlexusConfiguration();

  PlexusConfiguration mojoConfiguration = merger.extractAndMerge(goal, configurationFromMaven, defaultMojoConfiguration);

  String xml = mojoConfiguration.toString();
  assertXpathEvaluatesTo("java.io.File", "/configuration/classesDirectory/@implementation", xml);
  assertXpathEvaluatesTo("${project.build.outputDirectory}", "/configuration/classesDirectory/@default-value", xml);
  assertXpathEvaluatesTo("java.util.List", "/configuration/reactorProjects/@implementation", xml);
  assertXpathEvaluatesTo("${reactorProjects}", "/configuration/reactorProjects/@default-value", xml);
  assertXpathEvaluatesTo("true", "/configuration/sourceJar", xml);
}
 
源代码5 项目: iterator-maven-plugin   文件: IteratorMojo.java
/**
 * Taken from MojoExecutor of Don Brown. Make it working with Maven 3.1.
 * 
 * @param plugin
 * @param goal
 * @param configuration
 * @param env
 * @throws MojoExecutionException
 * @throws PluginResolutionException
 * @throws PluginDescriptorParsingException
 * @throws InvalidPluginDescriptorException
 * @throws PluginManagerException
 * @throws PluginConfigurationException
 * @throws MojoFailureException
 */
private void executeMojo( Plugin plugin, String goal, Xpp3Dom configuration )
    throws MojoExecutionException, PluginResolutionException, PluginDescriptorParsingException,
    InvalidPluginDescriptorException, MojoFailureException, PluginConfigurationException, PluginManagerException
{

    if ( configuration == null )
    {
        throw new NullPointerException( "configuration may not be null" );
    }

    PluginDescriptor pluginDescriptor = getPluginDescriptor( plugin );

    MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
    if ( mojoDescriptor == null )
    {
        throw new MojoExecutionException( "Could not find goal '" + goal + "' in plugin " + plugin.getGroupId()
            + ":" + plugin.getArtifactId() + ":" + plugin.getVersion() );
    }

    MojoExecution exec = mojoExecution( mojoDescriptor, configuration );
    pluginManager.executeMojo( getMavenSession(), exec );
}
 
源代码6 项目: jkube   文件: MojoExecutionService.java
public void callPluginGoal(String fullGoal) {
    String[] parts = splitGoalSpec(fullGoal);
    Plugin plugin = project.getPlugin(parts[0]);
    String goal = parts[1];

    if (plugin == null) {
        throw new IllegalStateException("No goal " + fullGoal + " found in pom.xml");
    }

    try {
        String executionId = null;
        if (goal != null && goal.length() > 0 && goal.indexOf('#') > -1) {
            int pos = goal.indexOf('#');
            executionId = goal.substring(pos + 1);
            goal = goal.substring(0, pos);
        }

        PluginDescriptor pluginDescriptor = getPluginDescriptor(project, plugin);
        MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal);
        if (mojoDescriptor == null) {
            throw new MojoExecutionException("Could not find goal '" + goal + "' in plugin "
                                             + plugin.getGroupId() + ":"
                                             + plugin.getArtifactId() + ":"
                                             + plugin.getVersion());
        }
        MojoExecution exec = getMojoExecution(executionId, mojoDescriptor);
        pluginManager.executeMojo(session, exec);
    } catch (Exception e) {
        throw new IllegalStateException("Unable to execute mojo", e);
    }
}
 
源代码7 项目: promagent   文件: AgentDependencies.java
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;
}
 
源代码8 项目: gradle-plugins   文件: AbstractGeneratorTask.java
/**
 * @see AbstractGeneratorMojo#execute()
 */
@TaskAction
public void generate() throws GeneratorException, IOException, XmlPullParserException, InvalidPluginDescriptorException, ExtractionException {
    PluginDescriptor pluginDescriptor = new PluginDescriptor();

    MavenProject project = new MavenProjectWrapper(getProject(), getPomFile().getAsFile().get());

    pluginDescriptor.setName(project.getName());
    pluginDescriptor.setDescription(project.getDescription());
    pluginDescriptor.setGroupId(project.getGroupId());
    pluginDescriptor.setVersion(project.getVersion());
    pluginDescriptor.setArtifactId(project.getArtifactId());
    pluginDescriptor.setGoalPrefix(goalPrefix.getOrElse(PluginDescriptor.getGoalPrefixFromArtifactId(project.getArtifactId())));

    List<ComponentDependency> deps = getRuntimeDependencies();
    pluginDescriptor.setDependencies(deps);

    DefaultPluginToolsRequest request = new DefaultPluginToolsRequest(project, pluginDescriptor);

    if (getEncoding().isPresent()) {
        request.setEncoding(getEncoding().getOrNull());
    }
    request.setSkipErrorNoDescriptorsFound(getSkipErrorNoDescriptorsFound().get());

    MojoScanner mojoScanner = getMojoScanner();
    mojoScanner.populatePluginDescriptor(request);

    getBaseDir().mkdirs();

    getGenerator().execute(
            getBaseDir(),
            request
    );
}
 
源代码9 项目: wildfly-swarm   文件: MultiStartMojo.java
@SuppressWarnings("unchecked")
protected void startProject(MavenProject project, String executionId, XmlPlexusConfiguration process) throws InvalidPluginDescriptorException, PluginResolutionException, PluginDescriptorParsingException, PluginNotFoundException, PluginConfigurationException, MojoFailureException, MojoExecutionException, PluginManagerException {
    Plugin plugin = this.project.getPlugin("org.wildfly.swarm:wildfly-swarm-plugin");

    Xpp3Dom config = getConfiguration(project, executionId);
    Xpp3Dom processConfig = getProcessConfiguration(process);

    Xpp3Dom globalConfig = getGlobalConfig();
    Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom(processConfig, config);
    mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, globalConfig);

    PluginDescriptor pluginDescriptor = this.pluginManager.loadPlugin(plugin, project.getRemotePluginRepositories(), this.repositorySystemSession);
    MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("start");
    MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, mergedConfig);
    mavenSession.setCurrentProject(project);
    this.pluginManager.executeMojo(mavenSession, mojoExecution);

    List<SwarmProcess> launched = (List<SwarmProcess>) mavenSession.getPluginContext(pluginDescriptor, project).get("swarm-process");

    List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get("swarm-process");

    if (procs == null) {
        procs = new ArrayList<>();
        getPluginContext().put("swarm-process", procs);
    }

    procs.addAll(launched);

    mavenSession.setCurrentProject(this.project);
}
 
源代码10 项目: thorntail   文件: MultiStartMojo.java
@SuppressWarnings("unchecked")
protected void startProject(MavenProject project, String executionId, XmlPlexusConfiguration process) throws InvalidPluginDescriptorException, PluginResolutionException, PluginDescriptorParsingException, PluginNotFoundException, PluginConfigurationException, MojoFailureException, MojoExecutionException, PluginManagerException {
    Plugin plugin = this.project.getPlugin(THORNTAIL_MAVEN_PLUGIN);

    Xpp3Dom config = getConfiguration(project, executionId);
    Xpp3Dom processConfig = getProcessConfiguration(process);

    Xpp3Dom globalConfig = getGlobalConfig();
    Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom(processConfig, config);
    mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, globalConfig);

    PluginDescriptor pluginDescriptor = this.pluginManager.loadPlugin(plugin, project.getRemotePluginRepositories(), this.repositorySystemSession);
    MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("start");
    MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, mergedConfig);
    mavenSession.setCurrentProject(project);
    this.pluginManager.executeMojo(mavenSession, mojoExecution);

    List<SwarmProcess> launched = (List<SwarmProcess>) mavenSession.getPluginContext(pluginDescriptor, project).get(THORNTAIL_PROCESS);

    List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get(THORNTAIL_PROCESS);

    if (procs == null) {
        procs = new ArrayList<>();
        getPluginContext().put(THORNTAIL_PROCESS, procs);
    }

    procs.addAll(launched);

    mavenSession.setCurrentProject(this.project);
}
 
源代码11 项目: gradle-plugins   文件: AbstractGeneratorTask.java
/**
 * @see AbstractGeneratorMojo#execute()
 */
@TaskAction
public void generate() throws GeneratorException, IOException, XmlPullParserException, InvalidPluginDescriptorException, ExtractionException {
    PluginDescriptor pluginDescriptor = new PluginDescriptor();

    MavenProject project = new MavenProjectWrapper(getProject(), getPomFile().getAsFile().get());

    pluginDescriptor.setName(project.getName());
    pluginDescriptor.setDescription(project.getDescription());
    pluginDescriptor.setGroupId(project.getGroupId());
    pluginDescriptor.setVersion(project.getVersion());
    pluginDescriptor.setArtifactId(project.getArtifactId());
    pluginDescriptor.setGoalPrefix(goalPrefix.getOrElse(PluginDescriptor.getGoalPrefixFromArtifactId(project.getArtifactId())));

    List<ComponentDependency> deps = getRuntimeDependencies();
    pluginDescriptor.setDependencies(deps);

    DefaultPluginToolsRequest request = new DefaultPluginToolsRequest(project, pluginDescriptor);

    if (getEncoding().isPresent()) {
        request.setEncoding(getEncoding().getOrNull());
    }
    request.setSkipErrorNoDescriptorsFound(getSkipErrorNoDescriptorsFound().get());

    MojoScanner mojoScanner = getMojoScanner();
    mojoScanner.populatePluginDescriptor(request);

    getBaseDir().mkdirs();

    getGenerator().execute(
            getBaseDir(),
            request
    );
}
 
源代码12 项目: ARCHIVE-wildfly-swarm   文件: MultiStartMojo.java
@SuppressWarnings("unchecked")
protected void startProject(MavenProject project, String executionId, XmlPlexusConfiguration process) throws InvalidPluginDescriptorException, PluginResolutionException, PluginDescriptorParsingException, PluginNotFoundException, PluginConfigurationException, MojoFailureException, MojoExecutionException, PluginManagerException {
    Plugin plugin = this.project.getPlugin("org.wildfly.swarm:wildfly-swarm-plugin");

    Xpp3Dom config = getConfiguration(project, executionId);
    Xpp3Dom processConfig = getProcessConfiguration(process);

    Xpp3Dom globalConfig = getGlobalConfig();
    Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom(processConfig, config);
    mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, globalConfig);

    PluginDescriptor pluginDescriptor = this.pluginManager.loadPlugin(plugin, project.getRemotePluginRepositories(), this.repositorySystemSession);
    MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("start");
    MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, mergedConfig);
    mavenSession.setCurrentProject(project);
    this.pluginManager.executeMojo(mavenSession, mojoExecution);

    List<SwarmProcess> launched = (List<SwarmProcess>) mavenSession.getPluginContext(pluginDescriptor, project).get("swarm-process");

    List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get("swarm-process");

    if (procs == null) {
        procs = new ArrayList<>();
        getPluginContext().put("swarm-process", procs);
    }

    procs.addAll(launched);

    mavenSession.setCurrentProject(this.project);
}
 
源代码13 项目: sarl   文件: AbstractDocumentationMojo.java
private Properties createGeneratorProperties() {
	final Properties props = new Properties();
	final PluginDescriptor descriptor = (PluginDescriptor) getPluginContext().get("pluginDescriptor"); //$NON-NLS-1$
	props.put("generator.name", Strings.emptyIfNull(descriptor.getArtifactId())); //$NON-NLS-1$
	props.put("generator.version", Strings.emptyIfNull(descriptor.getVersion())); //$NON-NLS-1$
	return props;
}
 
源代码14 项目: sarl   文件: MavenHelper.java
/** Load the given plugin.
 *
 * @param plugin the plugin to load.
 * @return the descriptor of the plugin.
 * @throws MojoExecutionException if something bad append.
 */
public PluginDescriptor loadPlugin(Plugin plugin)
		throws MojoExecutionException {
	try {
		final Object repositorySessionObject = this.getRepositorySessionMethod.invoke(this.session);
		return (PluginDescriptor) this.loadPluginMethod.invoke(
				this.buildPluginManager,
				plugin,
				getSession().getCurrentProject().getRemotePluginRepositories(),
				repositorySessionObject);
	} catch (IllegalAccessException | IllegalArgumentException
			| InvocationTargetException e) {
		throw new MojoExecutionException(e.getLocalizedMessage(), e);
	}
}
 
源代码15 项目: docker-maven-plugin   文件: MojoExecutionService.java
public void callPluginGoal(String fullGoal) throws MojoFailureException, MojoExecutionException {
    String[] parts = splitGoalSpec(fullGoal);
    Plugin plugin = project.getPlugin(parts[0]);
    String goal = parts[1];

    if (plugin == null) {
        throw new MojoFailureException("No goal " + fullGoal + " found in pom.xml");
    }

    try {
        String executionId = null;
        if (goal != null && goal.length() > 0 && goal.indexOf('#') > -1) {
            int pos = goal.indexOf('#');
            executionId = goal.substring(pos + 1);
            goal = goal.substring(0, pos);
        }

        PluginDescriptor pluginDescriptor = getPluginDescriptor(project, plugin);
        MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal);
        if (mojoDescriptor == null) {
            throw new MojoExecutionException("Could not find goal '" + goal + "' in plugin "
                                             + plugin.getGroupId() + ":"
                                             + plugin.getArtifactId() + ":"
                                             + plugin.getVersion());
        }
        MojoExecution exec = getMojoExecution(executionId, mojoDescriptor);
        pluginManager.executeMojo(session, exec);
    } catch (Exception e) {
        throw new MojoExecutionException("Unable to execute mojo", e);
    }
}
 
public PlexusConfiguration mojoConfigurationFor(Object mojoInstance, PlexusConfiguration pluginConfigurationFromMaven) throws ComponentConfigurationException {
  try (InputStream is = mojoInstance.getClass().getResourceAsStream("/META-INF/maven/plugin.xml")) {
    PluginDescriptor pd = pluginDescriptorBuilder.build(new InputStreamReader(is, "UTF-8")); // closes input stream too
    String goal = determineGoal(mojoInstance.getClass().getName(), pd);
    PlexusConfiguration defaultMojoConfiguration = pd.getMojo(goal).getMojoConfiguration();
    PlexusConfiguration mojoConfiguration = extractAndMerge(goal, pluginConfigurationFromMaven, defaultMojoConfiguration);
    return mojoConfiguration;
  } catch (Exception e) {
    throw new ComponentConfigurationException(e);
  }
}
 
String determineGoal(String className, PluginDescriptor pluginDescriptor) throws ComponentConfigurationException {
  List<MojoDescriptor> mojos = pluginDescriptor.getMojos();
  for (MojoDescriptor mojo : mojos) {
    if (className.equals(mojo.getImplementation())) {
      return mojo.getGoal();
    }
  }
  throw new ComponentConfigurationException("Cannot find the goal implementation with " + className);
}
 
/**
 * @return the goal prefix parameter or the goal prefix from the Plugin artifactId.
 */
private String getGoalPrefix() {
  if (goalPrefix == null) {
    goalPrefix = PluginDescriptor.getGoalPrefixFromArtifactId(project.getArtifactId());
  }

  return goalPrefix;
}
 
@Test
public void determineGoalFromMojoImplementation() throws Exception {
  InputStream is = getClass().getResourceAsStream("/META-INF/maven/plugin.xml");
  assertNotNull(is);
  PluginDescriptor pluginDescriptor = pluginDescriptorBuilder.build(new InputStreamReader(is, "UTF-8"));
  String goal = merger.determineGoal("io.takari.maven.plugins.jar.Jar", pluginDescriptor);
  assertEquals("We expect the goal name to be 'jar'", "jar", goal);
}
 
源代码20 项目: takari-lifecycle   文件: TestPropertiesMojoTest.java
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;
}
 
源代码21 项目: deadcode4j   文件: An_UpdateChecker.java
private void whenCheckingForUpdate() {
    PluginDescriptor pluginDescriptor = new PluginDescriptor();
    pluginDescriptor.setPluginArtifact(new DefaultArtifact("de.is24", "junit", "23", null, "maven-plugin", "", null));
    MojoDescriptor mojoDescriptor = new MojoDescriptor();
    mojoDescriptor.setPluginDescriptor(pluginDescriptor);
    result = objectUnderTest.checkForUpdate(new MojoExecution(mojoDescriptor));
}
 
源代码22 项目: promagent   文件: ManifestTransformer.java
ManifestTransformer(PluginDescriptor pluginDescriptor) {
    pluginArtifactId = pluginDescriptor.getArtifactId();
    pluginVersion = pluginDescriptor.getVersion();
}
 
源代码23 项目: syndesis   文件: ExtractConnectorDescriptorsMojo.java
@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) {

            }
        }
    }
}
 
源代码24 项目: unleash-maven-plugin   文件: AbstractUnleashMojo.java
@MojoProduces
private PluginDescriptor getPluginDescriptor() {
  return (PluginDescriptor) getPluginContext().get("pluginDescriptor");
}
 
源代码25 项目: emodb   文件: EmoStartMojo.java
/** The version of this plugin used; is also the same version of the emodb server to use. */
private String pluginVersion() {
    return ((PluginDescriptor) getPluginContext().get("pluginDescriptor")).getVersion();
}
 
@SuppressWarnings("unchecked")
private void generatePluginReport( ConfluenceService confluence, final Site site, final Locale locale )  throws Exception
{

    final String goalPrefix = PluginDescriptor.getGoalPrefixFromArtifactId(project.getArtifactId());
    final PluginDescriptor pluginDescriptor = new PluginDescriptor();
    pluginDescriptor.setGroupId(project.getGroupId());
    pluginDescriptor.setArtifactId(project.getArtifactId());
    pluginDescriptor.setVersion(project.getVersion());
    pluginDescriptor.setGoalPrefix(goalPrefix);

    final java.util.List<ComponentDependency> deps = new java.util.ArrayList<>();

    deps.addAll(toComponentDependencies(project.getRuntimeDependencies()));
    deps.addAll(toComponentDependencies(project.getCompileDependencies()));

    pluginDescriptor.setDependencies(deps);
    pluginDescriptor.setDescription(project.getDescription());

    PluginToolsRequest req = new DefaultPluginToolsRequest(project, pluginDescriptor);
    req.setEncoding(getEncoding());
    req.setLocal(local);
    req.setRemoteRepos(remoteRepos);
    req.setSkipErrorNoDescriptorsFound(false);
    req.setDependencies(dependencies);

    try {

        mojoScanner.populatePluginDescriptor(req);

    } catch (InvalidPluginDescriptorException e) {
        // this is OK, it happens to lifecycle plugins. Allow generation to proceed.
        getLog().warn(format("Plugin without mojos. %s\nMojoScanner:%s", e.getMessage(), mojoScanner.getClass()));

    }

    final Model.Page parentPage = loadParentPage(confluence, Optional.of(site)).join();

    outputDirectory.mkdirs();

    getLog().info( format("speceKey=%s parentPageTitle=%s", parentPage.getSpace(), parentPage.getTitle()) );

    final PluginGenerator generator = new PluginGenerator();

    final PluginToolsRequest request =
            new DefaultPluginToolsRequest(project, pluginDescriptor);

    final Model.Page confluenceHomePage = generator.processMojoDescriptors(
        request.getPluginDescriptor(),
        confluence,
        parentPage,
        site,
        locale );

    confluence.addLabelsByName(confluenceHomePage.getId(), site.getHome().getComputedLabels() ).join();

    final Map<String, Model.Page> varsToParentPageMap = new HashMap<>();

    generateChildren(   confluence,
                        site,
                        site.getHome(),
                        confluenceHomePage,
                        varsToParentPageMap);

    generator.generateGoalsPages(confluence, confluenceHomePage, varsToParentPageMap);


    //
    // Write the overview
    // PluginOverviewRenderer r = new PluginOverviewRenderer( getSink(), pluginDescriptor, locale );
    // r.render();
    //
}
 
/**
 *
 * @param pluginDescriptor
 * @param confluence
 * @param parentPage
 * @param site
 * @param locale
 * @return
 * @throws Exception
 */
public Model.Page processMojoDescriptors(
                        final PluginDescriptor pluginDescriptor,
                        final ConfluenceService confluence,
                        final Model.Page parentPage,
                        final Site site,
                        final Locale locale) throws Exception
{

    // issue#102
    //final String title = format( "%s-%s", pluginDescriptor.getArtifactId(), pluginDescriptor.getVersion() );
    final String title = getPageTitle();

    getProperties().put("pageTitle",    title);
    getProperties().put("artifactId",   getProject().getArtifactId());
    getProperties().put("version",      getProject().getVersion());

    return
        removeSnaphot(confluence, parentPage, title)
        .thenCompose( deleted -> confluence.getPage(parentPage.getSpace(), parentPage.getTitle()) )
        .exceptionally( ex ->
            throwRTE( "cannot find parent page [%s] in space [%s]", parentPage.getTitle(), ex ))
        .thenApply( parent ->
            parent.orElseThrow( () -> RTE( "cannot find parent page [%s] in space [%s]", parentPage.getTitle())) )
        .thenCombine( confluence.getPage(parentPage.getSpace(), title), ParentChildTuple::of)
        .thenCompose( tuple -> ( tuple.getChild().isPresent() ) ?
            completedFuture(tuple.getChild().get()) :
            resetUpdateStatusForResource(site.getHome().getUri())
            .thenCompose( reset ->confluence.createPage(tuple.getParent(), title)))
        .thenCompose( p ->
            canProceedToUpdateResource( site.getHome().getUri())
            .thenCompose( update -> {
                if(update) return updateHomeContent(confluence, site, p, pluginDescriptor, locale) ;
                else {
                    getLog().info( String.format("page [%s] has not been updated (deploy skipped)",
                            getPrintableStringForResource(site.getHome().getUri()) ));
                    return confluence.storePage(p);
                }}))
        .join();

}
 
源代码28 项目: sarl   文件: AbstractSarlMojo.java
/** Execute another MOJO.
 *
 * @param groupId identifier of the MOJO plugin group.
 * @param artifactId identifier of the MOJO plugin artifact.
 * @param version version of the MOJO plugin version.
 * @param goal the goal to run.
 * @param configuration the XML code for the configuration.
 * @param dependencies the dependencies of the plugin.
 * @throws MojoExecutionException when cannot run the MOJO.
 * @throws MojoFailureException when the build failed.
 */
protected void executeMojo(
		String groupId, String artifactId,
		String version, String goal,
		String configuration,
		Dependency... dependencies) throws MojoExecutionException, MojoFailureException {
	final Plugin plugin = new Plugin();
	plugin.setArtifactId(artifactId);
	plugin.setGroupId(groupId);
	plugin.setVersion(version);
	plugin.setDependencies(Arrays.asList(dependencies));

	getLog().debug(MessageFormat.format(Messages.AbstractSarlMojo_0, plugin.getId()));

	final PluginDescriptor pluginDescriptor = this.mavenHelper.loadPlugin(plugin);
	if (pluginDescriptor == null) {
		throw new MojoExecutionException(MessageFormat.format(Messages.AbstractSarlMojo_1, plugin.getId()));
	}
	final MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal);
	if (mojoDescriptor == null) {
		throw new MojoExecutionException(MessageFormat.format(Messages.AbstractSarlMojo_2, goal));
	}

	final Xpp3Dom mojoXml;
	try {
		mojoXml = this.mavenHelper.toXpp3Dom(mojoDescriptor.getMojoConfiguration());
	} catch (PlexusConfigurationException e1) {
		throw new MojoExecutionException(e1.getLocalizedMessage(), e1);
	}
	Xpp3Dom configurationXml = this.mavenHelper.toXpp3Dom(configuration, getLog());
	if (configurationXml != null) {
		configurationXml = Xpp3DomUtils.mergeXpp3Dom(
				configurationXml,
				mojoXml);
	} else {
		configurationXml = mojoXml;
	}

	getLog().debug(MessageFormat.format(Messages.AbstractSarlMojo_3, plugin.getId(), configurationXml.toString()));

	final MojoExecution execution = new MojoExecution(mojoDescriptor, configurationXml);

	this.mavenHelper.executeMojo(execution);
}
 
源代码29 项目: iterator-maven-plugin   文件: IteratorMojo.java
private PluginDescriptor getPluginDescriptor( Plugin plugin )
    throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException
{
    return mavenPluginManagerHelper.getPluginDescriptor( plugin, getMavenProject().getRemotePluginRepositories(),
                                                         getMavenSession() );
}
 
源代码30 项目: javalite   文件: ActiveJdbcInstrumentationPlugin.java
private void addUrlToPluginClasspath(URL url) {
    //Nice API, Maven :(
    PluginDescriptor pluginDescriptor = (PluginDescriptor) getPluginContext().get("pluginDescriptor");
    ClassRealm realm = pluginDescriptor.getClassRealm();
    realm.addURL(url);
}
 
 类所在包