From 0d27f1bb2b10121d5c2cdd98e3b54a35ff621455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Kr=C3=BCger?= Date: Wed, 1 Nov 2023 17:12:54 +0100 Subject: [PATCH] Fix download error in build Dependencies were not downloaded by RewriteMavenProjectParser. Adding the repository definition solved the issue. --- .../sbm/parsers/CompareParserRecipeRunTest.java | 7 +++++-- .../sbm/parsers/maven/MavenExecutionRequestFactory.java | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/CompareParserRecipeRunTest.java b/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/CompareParserRecipeRunTest.java index 800e406fa..8c7002bbe 100644 --- a/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/CompareParserRecipeRunTest.java +++ b/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/CompareParserRecipeRunTest.java @@ -33,6 +33,8 @@ import org.springframework.sbm.boot.autoconfigure.SbmSupportRewriteConfiguration; import org.springframework.sbm.parsers.maven.RewriteMavenProjectParser; import org.springframework.sbm.parsers.maven.SbmTestConfiguration; +import org.springframework.sbm.test.util.ParallelParsingResult; +import org.springframework.sbm.test.util.ParserExecutionHelper; import org.springframework.sbm.test.util.TestProjectHelper; import java.nio.file.Path; @@ -60,8 +62,9 @@ public class CompareParserRecipeRunTest { @DisplayName("Running a recipe with RewriteMavenParser should yield the same result as with RewriteProjectParser") void runningARecipeWithRewriteMavenParserYieldsTheSameResultAsWithRewriteProjectParser() { Path baseDir = TestProjectHelper.getMavenProject("parser-recipe-run"); - RewriteProjectParsingResult sutParsingResult = sut.parse(baseDir); - RewriteProjectParsingResult compParsingResult = comparingParser.parse(baseDir); + ParallelParsingResult parallelParsingResult = new ParserExecutionHelper().parseParallel(baseDir); + RewriteProjectParsingResult sutParsingResult = parallelParsingResult.testedParsingResult(); + RewriteProjectParsingResult compParsingResult = parallelParsingResult.comparingParsingResult(); AtomicInteger counter = new AtomicInteger(0); diff --git a/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/maven/MavenExecutionRequestFactory.java b/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/maven/MavenExecutionRequestFactory.java index 924dcd341..5f8159dae 100644 --- a/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/maven/MavenExecutionRequestFactory.java +++ b/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/maven/MavenExecutionRequestFactory.java @@ -19,6 +19,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; +import org.apache.maven.artifact.repository.MavenArtifactRepository; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest; @@ -75,6 +76,8 @@ public MavenExecutionRequest createMavenExecutionRequest(PlexusContainer plexusC userProperties.put("skipTests", "true"); request.setUserProperties(userProperties); + request.setRemoteRepositories(List.of(new MavenArtifactRepository("central", "https://repo.maven.apache.org/maven2", new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(true, "never", "warn"), new ArtifactRepositoryPolicy(true, "never", "warn")))); + // TODO: make profile configurable // fixes the maven run when plugins depending on Java version are encountered. // This is the case for some transitive dependencies when running against the SBM code base itself.