Skip to content

Commit

Permalink
Fix download snapshot warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ammachado committed Oct 28, 2024
1 parent fca4935 commit 547e934
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ pom.xml.versionsBackup
.classpath
.project
.settings
.vscode/
20 changes: 13 additions & 7 deletions src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.openrewrite.marker.ci.BuildEnvironment;
import org.openrewrite.maven.cache.InMemoryMavenPomCache;
import org.openrewrite.maven.cache.MavenPomCache;
import org.openrewrite.maven.internal.RawPom;
import org.openrewrite.maven.internal.RawRepositories;
import org.openrewrite.maven.tree.Pom;
import org.openrewrite.maven.tree.ProfileActivation;
Expand All @@ -57,6 +58,7 @@

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
Expand Down Expand Up @@ -615,7 +617,10 @@ public Map<MavenProject, Xml.Document> parseMaven(List<MavenProject> mavenProjec
* @param paths A list of paths to poms that have been collected so far.
*/
private void collectPoms(MavenProject project, Set<Path> paths, MavenExecutionContextView ctx) {
paths.add(pomPath(project));
if (!paths.add(pomPath(project))) {
return;
}

ResolvedGroupArtifactVersion gav = createResolvedGAV(project, ctx);
ctx.getPomCache().putPom(gav, createPom(gav, project));

Expand Down Expand Up @@ -822,11 +827,12 @@ private static ResolvedGroupArtifactVersion createResolvedGAV(MavenProject proje
);
}

private static Pom createPom(ResolvedGroupArtifactVersion gav, MavenProject project) {
Pom.PomBuilder builder = Pom.builder()
.gav(gav)
;
// TODO: complete mapping
return builder.build();
private static @Nullable Pom createPom(ResolvedGroupArtifactVersion gav, MavenProject project) {
try (InputStream is = Files.newInputStream(project.getFile().toPath())) {
RawPom rawPom = RawPom.parse(is, null);
return rawPom.toPom(project.getBasedir().toPath(), null);
} catch (IOException e) {
return null;
}
}
}

0 comments on commit 547e934

Please sign in to comment.