mirror of https://github.com/apache/maven.git
[MNG-7889] Preserve MetadataXpp3Reader/Writer for Maven 3 compatible
This commit is contained in:
parent
34b0591f03
commit
9378676b80
|
@ -99,6 +99,8 @@ under the License.
|
|||
</models>
|
||||
<templates>
|
||||
<template>model-v3.vm</template>
|
||||
<template>reader.vm</template>
|
||||
<template>writer.vm</template>
|
||||
</templates>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.maven.artifact.repository.metadata.io.xpp3;
|
||||
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
|
||||
import org.apache.maven.artifact.repository.metadata.Metadata;
|
||||
|
||||
/**
|
||||
* Provide public methods from {@link org.apache.maven.artifact.repository.metadata.io.MetadataXpp3Reader}
|
||||
*
|
||||
* @deprecated Maven 3 compatability
|
||||
*/
|
||||
@Deprecated
|
||||
public class MetadataXpp3Reader {
|
||||
|
||||
private final org.apache.maven.artifact.repository.metadata.io.MetadataXpp3Reader delegate;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public MetadataXpp3Reader() {
|
||||
delegate = new org.apache.maven.artifact.repository.metadata.io.MetadataXpp3Reader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with ContentTransformer
|
||||
*
|
||||
* @param contentTransformer a transformer
|
||||
*/
|
||||
public MetadataXpp3Reader(ContentTransformer contentTransformer) {
|
||||
delegate =
|
||||
new org.apache.maven.artifact.repository.metadata.io.MetadataXpp3Reader(contentTransformer::transform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state of the "add default entities" flag.
|
||||
*
|
||||
* @return boolean a field value
|
||||
*/
|
||||
public boolean getAddDefaultEntities() {
|
||||
return delegate.getAddDefaultEntities();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the state of the "add default entities" flag.
|
||||
*
|
||||
* @param addDefaultEntities a addDefaultEntities object.
|
||||
*/
|
||||
public void setAddDefaultEntities(boolean addDefaultEntities) {
|
||||
delegate.setAddDefaultEntities(addDefaultEntities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method read.
|
||||
*
|
||||
* @param reader a reader object.
|
||||
* @param strict a strict object.
|
||||
* @return Metadata
|
||||
* @throws IOException IOException if any.
|
||||
* @throws XMLStreamException XmlPullParserException if
|
||||
* any.
|
||||
*/
|
||||
public Metadata read(Reader reader, boolean strict) throws IOException, XMLStreamException {
|
||||
return new Metadata(delegate.read(reader, strict));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method read.
|
||||
*
|
||||
* @param reader a reader object.
|
||||
* @return Metadata
|
||||
* @throws IOException IOException if any.
|
||||
* @throws XMLStreamException XmlPullParserException if
|
||||
* any.
|
||||
*/
|
||||
public Metadata read(Reader reader) throws IOException, XMLStreamException {
|
||||
return new Metadata(delegate.read(reader));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method read.
|
||||
*
|
||||
* @param in a in object.
|
||||
* @param strict a strict object.
|
||||
* @return Metadata
|
||||
* @throws IOException IOException if any.
|
||||
* @throws XMLStreamException XmlPullParserException if
|
||||
* any.
|
||||
*/
|
||||
public Metadata read(InputStream in, boolean strict) throws IOException, XMLStreamException {
|
||||
return new Metadata(delegate.read(in, strict));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method read.
|
||||
*
|
||||
* @param in a in object.
|
||||
* @return Metadata
|
||||
* @throws IOException IOException if any.
|
||||
* @throws XMLStreamException XmlPullParserException if
|
||||
* any.
|
||||
*/
|
||||
public Metadata read(InputStream in) throws IOException, XMLStreamException {
|
||||
return new Metadata(delegate.read(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method read.
|
||||
*
|
||||
* @param parser a parser object.
|
||||
* @param strict a strict object.
|
||||
* @return Metadata
|
||||
* @throws IOException IOException if any.
|
||||
* @throws XMLStreamException XmlPullParserException if
|
||||
* any.
|
||||
*/
|
||||
public Metadata read(XMLStreamReader parser, boolean strict) throws IOException, XMLStreamException {
|
||||
return new Metadata(delegate.read(parser, strict));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link org.apache.maven.artifact.repository.metadata.io.MetadataXpp3Reader.ContentTransformer}
|
||||
*/
|
||||
public interface ContentTransformer {
|
||||
/**
|
||||
* Interpolate the value read from the xpp3 document
|
||||
*
|
||||
* @param source The source value
|
||||
* @param fieldName A description of the field being interpolated. The implementation may use this to
|
||||
* log stuff.
|
||||
* @return The interpolated value.
|
||||
*/
|
||||
String transform(String source, String fieldName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.maven.artifact.repository.metadata.io.xpp3;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.apache.maven.artifact.repository.metadata.Metadata;
|
||||
|
||||
/**
|
||||
* Provide public methods from {@link org.apache.maven.artifact.repository.metadata.io.MetadataXpp3Writer}
|
||||
*
|
||||
* @deprecated Maven 3 compatability
|
||||
*/
|
||||
@Deprecated
|
||||
public class MetadataXpp3Writer {
|
||||
|
||||
private final org.apache.maven.artifact.repository.metadata.io.MetadataXpp3Writer delegate;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public MetadataXpp3Writer() {
|
||||
delegate = new org.apache.maven.artifact.repository.metadata.io.MetadataXpp3Writer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setFileComment.
|
||||
*
|
||||
* @param fileComment a fileComment object.
|
||||
*/
|
||||
public void setFileComment(String fileComment) {
|
||||
delegate.setFileComment(fileComment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method write.
|
||||
*
|
||||
* @param writer a writer object
|
||||
* @param metadata a Metadata object
|
||||
* @throws java.io.IOException java.io.IOException if any
|
||||
*/
|
||||
public void write(Writer writer, Metadata metadata) throws java.io.IOException {
|
||||
delegate.write(writer, metadata.getDelegate());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method write.
|
||||
*
|
||||
* @param stream a stream object
|
||||
* @param metadata a Metadata object
|
||||
* @throws java.io.IOException java.io.IOException if any
|
||||
*/
|
||||
public void write(OutputStream stream, Metadata metadata) throws java.io.IOException {
|
||||
delegate.write(stream, metadata.getDelegate());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue