Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,24 @@ public PluginDescriptor build(Reader reader) throws PlexusConfigurationException
*/
@Deprecated
public PluginDescriptor build(Reader reader, String source) throws PlexusConfigurationException {
return build(() -> reader, source);
try {
BufferedReader br = new BufferedReader(reader, BUFFER_SIZE);
br.mark(BUFFER_SIZE);
XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(br);
xsr.nextTag();
String nsUri = xsr.getNamespaceURI();
br.reset();
if (PLUGIN_2_0_0.equals(nsUri)) {
xsr = XMLInputFactory.newFactory().createXMLStreamReader(br);
return new PluginDescriptor(new PluginDescriptorStaxReader().read(xsr, true));
} else {
// Call buildConfiguration() for backward compatibility with subclasses that override it
PlexusConfiguration cfg = buildConfiguration(br);
return build(source, cfg);
}
} catch (XMLStreamException | IOException e) {
throw new PlexusConfigurationException(e.getMessage(), e);
}
}

public PluginDescriptor build(ReaderSupplier readerSupplier) throws PlexusConfigurationException {
Expand All @@ -98,7 +115,24 @@ public PluginDescriptor build(ReaderSupplier readerSupplier, String source) thro
*/
@Deprecated
public PluginDescriptor build(InputStream input, String source) throws PlexusConfigurationException {
return build(() -> input, source);
try {
BufferedInputStream bis = new BufferedInputStream(input, BUFFER_SIZE);
bis.mark(BUFFER_SIZE);
XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(bis);
xsr.nextTag();
String nsUri = xsr.getNamespaceURI();
bis.reset();
if (PLUGIN_2_0_0.equals(nsUri)) {
xsr = XMLInputFactory.newFactory().createXMLStreamReader(bis);
return new PluginDescriptor(new PluginDescriptorStaxReader().read(xsr, true));
} else {
// Call buildConfiguration() for backward compatibility with subclasses that override it
PlexusConfiguration cfg = buildConfiguration(bis);
return build(source, cfg);
}
} catch (XMLStreamException | IOException e) {
throw new PlexusConfigurationException(e.getMessage(), e);
}
}

public PluginDescriptor build(StreamSupplier inputSupplier) throws PlexusConfigurationException {
Expand Down