Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go back to raw Maven read/write for bootstrap #39995

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
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
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
Loading