From cd653ebf314b806637c88e2f90898c756541bd9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Wed, 1 Mar 2023 16:18:30 +0100 Subject: [PATCH] Add a workaround to the encoding problem from polyglot See https://github.com/takari/polyglot-maven/pull/259 --- .../pomless/TychoTeslaModelProcessor.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoTeslaModelProcessor.java diff --git a/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoTeslaModelProcessor.java b/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoTeslaModelProcessor.java new file mode 100644 index 0000000000..32c6e5538a --- /dev/null +++ b/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoTeslaModelProcessor.java @@ -0,0 +1,38 @@ +package org.eclipse.tycho.pomless; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.util.Map; + +import javax.annotation.Priority; + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelProcessor; +import org.apache.maven.model.io.ModelParseException; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.util.ReaderFactory; +import org.sonatype.maven.polyglot.TeslaModelProcessor; + +//This is a hack until https://github.com/takari/polyglot-maven/pull/259 is fixed +@Component(role = ModelProcessor.class) +@Priority(10) +public class TychoTeslaModelProcessor extends TeslaModelProcessor { + @Override + public Model read(final File input, final Map options) throws IOException, ModelParseException { + Model model; + try (Reader reader = ReaderFactory.newXmlReader(input)) { + model = read(reader, options); + model.setPomFile(input); + } + return model; + } + + @Override + public Model read(final InputStream input, final Map options) throws IOException, ModelParseException { + try (Reader reader = ReaderFactory.newXmlReader(input)) { + return read(reader, options); + } + } +}