Java 类org.apache.maven.plugin.descriptor.PluginDescriptorBuilder 实例源码

项目:takari-lifecycle    文件:LegacyPluginDescriptors.java   
public static Collection<MojoDescriptor> readMojos(InputStream is) throws IOException, XmlPullParserException {
  Reader reader = ReaderFactory.newXmlReader(is);
  org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor;
  try {
    pluginDescriptor = new PluginDescriptorBuilder().build(reader);
  } catch (PlexusConfigurationException e) {
    Throwables.propagateIfPossible(e.getCause(), IOException.class, XmlPullParserException.class);
    throw Throwables.propagate(e);
  }
  List<MojoDescriptor> result = new ArrayList<>();
  for (org.apache.maven.plugin.descriptor.MojoDescriptor mojo : pluginDescriptor.getMojos()) {
    result.add(toMojoDescriptor(mojo));
  }
  return result;
}
项目:mule-tooling-incubator    文件:MavenArtifactResolver.java   
public PluginDescriptor getPluginDescriptor(File file) throws IOException, PlexusConfigurationException {
    PluginDescriptor descriptor = null;
    if (file.exists()) {
        JarFile jarFile = new JarFile(file);
        ZipEntry entry = jarFile.getEntry("META-INF/maven/plugin.xml");
        InputStream plugin = jarFile.getInputStream(entry);
        BufferedReader in = new BufferedReader(new InputStreamReader(plugin));
        descriptor = new PluginDescriptorBuilder().build(in);
    }
    return descriptor;
}