Skip to content

Commit

Permalink
Merge pull request #39995 from gsmet/raw-maven-for-bootstrap
Browse files Browse the repository at this point in the history
Go back to raw Maven read/write for bootstrap
  • Loading branch information
aloubyansky authored Apr 10, 2024
2 parents d1011f6 + 68a1bbe commit 051e910
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 29 deletions.
5 changes: 0 additions & 5 deletions independent-projects/bootstrap/bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>maven-model-helper</artifactId>
<version>${maven-model-helper.version}</version>
</dependency>
<!-- Smallrye Common dependencies, imported as a BOM -->
<dependency>
<groupId>io.smallrye.common</groupId>
Expand Down
4 changes: 0 additions & 4 deletions independent-projects/bootstrap/maven-resolver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>maven-model-helper</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.quarkus.bootstrap.resolver.maven.workspace;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystem;
import java.nio.file.Files;
Expand All @@ -16,9 +16,10 @@

import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;

import io.fabric8.maven.Maven;
import io.fabric8.maven.XMLFormat;
import io.quarkus.bootstrap.util.PropertyUtils;
import io.quarkus.fs.util.ZipUtils;
import io.quarkus.maven.dependency.ArtifactCoords;
Expand Down Expand Up @@ -231,30 +232,21 @@ private static Properties loadPomProps(Path appJar, Path artifactIdPath) throws
}

public static Model readModel(final Path pomXml) throws IOException {
try {
return Maven.readModel(pomXml);
} catch (UncheckedIOException e) {
throw e.getCause();
} catch (RuntimeException e) {
throw new IOException("Failed to read model", e.getCause());
}
return readModel(Files.newInputStream(pomXml));
}

public static Model readModel(InputStream stream) throws IOException {
try (InputStream is = stream) {
return Maven.readModel(is);
} catch (UncheckedIOException e) {
throw e.getCause();
} catch (RuntimeException e) {
throw new IOException("Failed to read model", e.getCause());
return new MavenXpp3Reader().read(stream);
} catch (XmlPullParserException e) {
throw new IOException("Failed to parse POM", e);
}
}

public static void persistModel(Path pomFile, Model model) throws IOException {
try {
Maven.writeModel(model, pomFile, XMLFormat.builder().indent(" ").insertLineBreakBetweenMajorSections().build());
} catch (UncheckedIOException e) {
throw e.getCause();
final MavenXpp3Writer xpp3Writer = new MavenXpp3Writer();
try (BufferedWriter pomFileWriter = Files.newBufferedWriter(pomFile)) {
xpp3Writer.write(pomFileWriter, model);
}
}
}
1 change: 0 additions & 1 deletion independent-projects/bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
<org-crac.version>0.1.3</org-crac.version>
<formatter-maven-plugin.version>2.23.0</formatter-maven-plugin.version>
<impsort-maven-plugin.version>1.9.0</impsort-maven-plugin.version>
<maven-model-helper.version>36</maven-model-helper.version>
</properties>
<modules>
<module>bom</module>
Expand Down

0 comments on commit 051e910

Please sign in to comment.