diff --git a/.github/workflows/build-sbm-revamp.yml b/.github/workflows/build-sbm-revamp.yml index a6d80009b..4556f6176 100644 --- a/.github/workflows/build-sbm-revamp.yml +++ b/.github/workflows/build-sbm-revamp.yml @@ -18,10 +18,6 @@ jobs: java-version: 17 cache: 'maven' - - name: sbm-support-rewrite (build + test) - working-directory: sbm-support-rewrite - run: mvn --batch-mode clean install - - name: clean run: mvn clean diff --git a/components/openrewrite-spring-recipes/src/main/java/org/springframework/sbm/spring/migration/actions/OpenRewriteRecipeAdapterAction.java b/components/openrewrite-spring-recipes/src/main/java/org/springframework/sbm/spring/migration/actions/OpenRewriteRecipeAdapterAction.java index f02437cd8..c1648cccd 100644 --- a/components/openrewrite-spring-recipes/src/main/java/org/springframework/sbm/spring/migration/actions/OpenRewriteRecipeAdapterAction.java +++ b/components/openrewrite-spring-recipes/src/main/java/org/springframework/sbm/spring/migration/actions/OpenRewriteRecipeAdapterAction.java @@ -24,7 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.recipe.AbstractAction; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.resource.filter.GenericTypeListFilter; import java.io.IOException; diff --git a/components/recipe-test-support/src/main/java/org/springframework/sbm/test/RecipeTestSupport.java b/components/recipe-test-support/src/main/java/org/springframework/sbm/test/RecipeTestSupport.java index aac1f0024..ecb617034 100644 --- a/components/recipe-test-support/src/main/java/org/springframework/sbm/test/RecipeTestSupport.java +++ b/components/recipe-test-support/src/main/java/org/springframework/sbm/test/RecipeTestSupport.java @@ -15,21 +15,21 @@ */ package org.springframework.sbm.test; -import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.parsers.maven.MavenSettingsInitializer; +import org.springframework.rewrite.project.RewriteSourceFileWrapper; import org.springframework.sbm.build.impl.MavenBuildFileRefactoringFactory; -import org.springframework.sbm.parsers.maven.MavenSettingsInitializer; import org.springframework.sbm.build.impl.RewriteMavenParser; import org.springframework.sbm.engine.context.ProjectContextHolder; import org.springframework.sbm.engine.context.RewriteJavaSearchActionDeserializer; import org.springframework.sbm.engine.recipe.*; import org.springframework.sbm.java.impl.RewriteJavaParser; import org.springframework.sbm.java.util.BasePackageCalculator; -import org.springframework.sbm.project.RewriteSourceFileWrapper; import org.springframework.sbm.project.resource.ProjectResourceSetHolder; import org.springframework.sbm.project.resource.SbmApplicationProperties; import org.springframework.sbm.project.resource.ResourceHelper; -import org.springframework.sbm.scopes.ExecutionScope; -import org.springframework.sbm.scopes.ScanScope; +import org.springframework.rewrite.scopes.ExecutionScope; +import org.springframework.rewrite.scopes.ScanScope; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; diff --git a/components/sbm-core/pom.xml b/components/sbm-core/pom.xml index 8127d0e55..93a8b0df5 100644 --- a/components/sbm-core/pom.xml +++ b/components/sbm-core/pom.xml @@ -37,8 +37,8 @@ 0.15.2-SNAPSHOT - org.springframework.experimental - sbm-support-rewrite + org.springframework.rewrite + spring-rewrite-commons-launcher 0.1.0-SNAPSHOT diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/SbmCoreConfig.java b/components/sbm-core/src/main/java/org/springframework/sbm/SbmCoreConfig.java index d2bc152b9..a65767080 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/SbmCoreConfig.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/SbmCoreConfig.java @@ -19,8 +19,8 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; -import org.springframework.sbm.parsers.RewriteExecutionContext; -import org.springframework.sbm.scopes.annotations.ScanScope; +import org.springframework.rewrite.parsers.RewriteExecutionContext; +import org.springframework.rewrite.scopes.annotations.ScanScope; import java.util.function.Supplier; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/build/api/BuildFile.java b/components/sbm-core/src/main/java/org/springframework/sbm/build/api/BuildFile.java index 507bdcd0c..d95897a41 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/build/api/BuildFile.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/build/api/BuildFile.java @@ -15,10 +15,8 @@ */ package org.springframework.sbm.build.api; -import org.openrewrite.maven.tree.ResolvedDependency; import org.openrewrite.maven.tree.Scope; - -import org.springframework.sbm.project.resource.ProjectResource; +import org.springframework.rewrite.project.resource.ProjectResource; import java.nio.file.Path; import java.util.List; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/build/api/Module.java b/components/sbm-core/src/main/java/org/springframework/sbm/build/api/Module.java index 9452ce601..b1dd03312 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/build/api/Module.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/build/api/Module.java @@ -20,6 +20,11 @@ import org.openrewrite.ExecutionContext; import org.openrewrite.SourceFile; import org.openrewrite.maven.tree.MavenResolutionResult; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.ProjectResourceSetFactory; +import org.springframework.rewrite.project.resource.RewriteMigrationResultMerger; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.build.impl.JavaSourceSetImpl; import org.springframework.sbm.build.impl.MavenBuildFileUtil; import org.springframework.sbm.build.impl.OpenRewriteMavenBuildFile; @@ -29,11 +34,6 @@ import org.springframework.sbm.java.refactoring.JavaRefactoringFactory; import org.springframework.sbm.java.util.BasePackageCalculator; import org.springframework.sbm.parsers.JavaParserBuilder; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.ProjectResourceSetFactory; -import org.springframework.sbm.project.resource.RewriteMigrationResultMerger; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; import java.nio.file.Path; import java.util.ArrayList; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/build/api/ResourceSet.java b/components/sbm-core/src/main/java/org/springframework/sbm/build/api/ResourceSet.java index bf0b524a6..3159a4102 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/build/api/ResourceSet.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/build/api/ResourceSet.java @@ -15,12 +15,12 @@ */ package org.springframework.sbm.build.api; -import org.openrewrite.ExecutionContext; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; -import org.springframework.sbm.project.resource.StringProjectResource; import lombok.RequiredArgsConstructor; +import org.openrewrite.ExecutionContext; import org.openrewrite.SourceFile; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.sbm.project.resource.StringProjectResource; import java.nio.file.Path; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/build/api/RootBuildFileFilter.java b/components/sbm-core/src/main/java/org/springframework/sbm/build/api/RootBuildFileFilter.java index af5959501..5c4a742d3 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/build/api/RootBuildFileFilter.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/build/api/RootBuildFileFilter.java @@ -15,8 +15,9 @@ */ package org.springframework.sbm.build.api; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; + +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; public class RootBuildFileFilter implements ProjectResourceFinder { @Override diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/build/filter/BuildFileProjectResourceFinder.java b/components/sbm-core/src/main/java/org/springframework/sbm/build/filter/BuildFileProjectResourceFinder.java index 7f6c20abe..39e694a85 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/build/filter/BuildFileProjectResourceFinder.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/build/filter/BuildFileProjectResourceFinder.java @@ -15,8 +15,8 @@ */ package org.springframework.sbm.build.filter; +import org.springframework.rewrite.project.resource.finder.GenericTypeListFinder; import org.springframework.sbm.build.api.BuildFile; -import org.springframework.sbm.project.resource.finder.GenericTypeListFinder; public class BuildFileProjectResourceFinder extends GenericTypeListFinder { public BuildFileProjectResourceFinder() { diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/JavaSourceSetImpl.java b/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/JavaSourceSetImpl.java index 8fc76e829..bdc0e7f70 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/JavaSourceSetImpl.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/JavaSourceSetImpl.java @@ -16,7 +16,11 @@ package org.springframework.sbm.build.impl; import org.openrewrite.ExecutionContext; +import org.openrewrite.Recipe; import org.openrewrite.SourceFile; +import org.openrewrite.java.tree.J; +import org.springframework.rewrite.project.resource.ProjectResource; +import org.springframework.rewrite.project.resource.ProjectResourceSet; import org.springframework.sbm.build.api.JavaSourceSet; import org.springframework.sbm.java.api.JavaSource; import org.springframework.sbm.java.api.JavaSourceLocation; @@ -24,11 +28,6 @@ import org.springframework.sbm.java.refactoring.JavaRefactoringFactory; import org.springframework.sbm.java.util.BasePackageCalculator; import org.springframework.sbm.parsers.JavaParserBuilder; -import org.springframework.sbm.project.resource.ProjectResource; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.openrewrite.Recipe; -import org.openrewrite.java.JavaParser; -import org.openrewrite.java.tree.J; import java.nio.file.Files; import java.nio.file.Path; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/MavenBuildFileRefactoring.java b/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/MavenBuildFileRefactoring.java index 89de628dd..d101a490e 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/MavenBuildFileRefactoring.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/MavenBuildFileRefactoring.java @@ -24,11 +24,10 @@ import org.openrewrite.maven.MavenVisitor; import org.openrewrite.maven.tree.MavenResolutionResult; import org.openrewrite.xml.tree.Xml; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.support.openrewrite.GenericOpenRewriteRecipe; -import javax.print.Doc; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -36,7 +35,6 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import java.util.stream.Stream; /** * This class provides a facade to apply OpenRewrite {@code Recipe}s and {@code Visitor}s to the project Maven build files. diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/OpenRewriteMavenBuildFile.java b/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/OpenRewriteMavenBuildFile.java index 6cc2ffc24..ed5d9f7e8 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/OpenRewriteMavenBuildFile.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/OpenRewriteMavenBuildFile.java @@ -25,23 +25,18 @@ import org.openrewrite.maven.tree.*; import org.openrewrite.xml.tree.Content; import org.openrewrite.xml.tree.Xml; - import org.springframework.context.ApplicationEventPublisher; -import org.springframework.sbm.build.api.BuildFile; -import org.springframework.sbm.build.api.DependenciesChangedEvent; +import org.springframework.rewrite.parsers.maven.RewriteMavenArtifactDownloader; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.support.openrewrite.GenericOpenRewriteRecipe; import org.springframework.sbm.build.api.Dependency; -import org.springframework.sbm.build.api.ParentDeclaration; import org.springframework.sbm.build.api.Plugin; -import org.springframework.sbm.build.api.RepositoryDefinition; -import org.springframework.sbm.build.api.RewriteMavenParentDeclaration; +import org.springframework.sbm.build.api.*; import org.springframework.sbm.build.impl.inner.PluginRepositoryHandler; import org.springframework.sbm.build.migration.recipe.AddMavenPlugin; import org.springframework.sbm.build.migration.recipe.RemoveMavenPlugin; import org.springframework.sbm.build.migration.visitor.AddOrUpdateDependencyManagement; import org.springframework.sbm.java.impl.ClasspathRegistry; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; -import org.springframework.sbm.parsers.maven.RewriteMavenArtifactDownloader; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; import org.springframework.util.Assert; import java.io.ByteArrayInputStream; @@ -898,15 +893,35 @@ public void removePlugins(String... coordinates) { Recipe recipe; String coordinate = iterator.next(); String[] split = coordinate.split(":"); - recipe = new RemoveMavenPlugin(split[0], split[1]); + List recipes = new ArrayList<>(); + recipes.add(new RemoveMavenPlugin(split[0], split[1])); while (iterator.hasNext()) { coordinate = iterator.next(); split = coordinate.split(":"); - recipe.getRecipeList().add(new RemoveMavenPlugin(split[0], split[1])); + recipes.add(new RemoveMavenPlugin(split[0], split[1])); } List sourceFile = List.of(getSourceFile()); LargeSourceSet sourceSet = new InMemoryLargeSourceSet(sourceFile); + + recipe = new Recipe() { + + @Override + public String getDisplayName() { + return "Aggregated Recipes"; + } + + @Override + public String getDescription() { + return getDisplayName(); + } + + @Override + public List getRecipeList() { + return recipes; + } + }; + List run = recipe.run(sourceSet, executionContext).getChangeset().getAllResults(); if (!run.isEmpty()) { replaceWith(run.get(0).getAfter()); diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/OpenRewriteMavenPlugin.java b/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/OpenRewriteMavenPlugin.java index a9985748b..75dd727a7 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/OpenRewriteMavenPlugin.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/OpenRewriteMavenPlugin.java @@ -15,40 +15,26 @@ */ package org.springframework.sbm.build.impl; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Null; - import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.Singular; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Null; +import lombok.*; import org.openrewrite.maven.ChangePluginConfiguration; import org.openrewrite.maven.internal.MavenXmlMapper; import org.openrewrite.xml.tree.Xml; import org.openrewrite.xml.tree.Xml.Document; - +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.build.api.Plugin; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; + +import java.util.*; +import java.util.stream.Collectors; @Getter @Setter diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/RewriteMavenParser.java b/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/RewriteMavenParser.java index de9e8dc1b..259c17313 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/RewriteMavenParser.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/build/impl/RewriteMavenParser.java @@ -21,7 +21,7 @@ import org.openrewrite.SourceFile; import org.openrewrite.internal.lang.Nullable; import org.openrewrite.maven.MavenParser; -import org.springframework.sbm.parsers.maven.MavenSettingsInitializer; +import org.springframework.rewrite.parsers.maven.MavenSettingsInitializer; import org.springframework.stereotype.Component; import java.nio.file.Path; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/build/migration/actions/AddMavenPlugin.java b/components/sbm-core/src/main/java/org/springframework/sbm/build/migration/actions/AddMavenPlugin.java index 89a833951..5696ba454 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/build/migration/actions/AddMavenPlugin.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/build/migration/actions/AddMavenPlugin.java @@ -40,7 +40,7 @@ public AddMavenPlugin() { @Override public void apply(ProjectContext context) { - context.getBuildFile().addPlugin(plugin); + context.getApplicationModules().getRootModule().getBuildFile().addPlugin(plugin); } private class DefaultMultiModuleHandler implements MultiModuleHandler { diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/build/migration/actions/AddMinimalPomXml.java b/components/sbm-core/src/main/java/org/springframework/sbm/build/migration/actions/AddMinimalPomXml.java index 0dcb0384b..7212a1b3a 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/build/migration/actions/AddMinimalPomXml.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/build/migration/actions/AddMinimalPomXml.java @@ -23,12 +23,12 @@ import org.openrewrite.Parser; import org.openrewrite.SourceFile; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.rewrite.parsers.maven.RewriteMavenArtifactDownloader; import org.springframework.sbm.build.impl.MavenBuildFileRefactoringFactory; import org.springframework.sbm.build.impl.OpenRewriteMavenBuildFile; import org.springframework.sbm.build.impl.RewriteMavenParser; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.recipe.AbstractAction; -import org.springframework.sbm.parsers.maven.RewriteMavenArtifactDownloader; import java.io.ByteArrayInputStream; import java.io.StringWriter; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/build/resource/BuildFileResourceWrapper.java b/components/sbm-core/src/main/java/org/springframework/sbm/build/resource/BuildFileResourceWrapper.java index 23d13a16f..cc29634a0 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/build/resource/BuildFileResourceWrapper.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/build/resource/BuildFileResourceWrapper.java @@ -21,12 +21,12 @@ import org.openrewrite.xml.tree.Xml; import org.springframework.context.ApplicationEventPublisher; import org.springframework.core.annotation.Order; +import org.springframework.rewrite.parsers.maven.RewriteMavenArtifactDownloader; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.build.impl.MavenBuildFileRefactoring; import org.springframework.sbm.build.impl.MavenBuildFileRefactoringFactory; import org.springframework.sbm.build.impl.OpenRewriteMavenBuildFile; -import org.springframework.sbm.parsers.maven.RewriteMavenArtifactDownloader; import org.springframework.sbm.project.resource.ProjectResourceWrapper; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import org.springframework.stereotype.Component; @Component diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/common/api/TextResource/TextSource.java b/components/sbm-core/src/main/java/org/springframework/sbm/common/api/TextResource/TextSource.java index 4efa2b76a..d00298f6d 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/common/api/TextResource/TextSource.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/common/api/TextResource/TextSource.java @@ -15,7 +15,7 @@ */ package org.springframework.sbm.common.api.TextResource; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.openrewrite.text.PlainText; import java.nio.file.Path; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/common/migration/actions/DeleteFileMatchingPattern.java b/components/sbm-core/src/main/java/org/springframework/sbm/common/migration/actions/DeleteFileMatchingPattern.java index 1b18429c7..84b4ec78b 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/common/migration/actions/DeleteFileMatchingPattern.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/common/migration/actions/DeleteFileMatchingPattern.java @@ -16,10 +16,10 @@ package org.springframework.sbm.common.migration.actions; import lombok.Setter; -import org.springframework.sbm.project.resource.finder.PathPatternMatchingProjectResourceFinder; +import org.springframework.rewrite.project.resource.finder.PathPatternMatchingProjectResourceFinder; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.recipe.AbstractAction; -import org.springframework.sbm.project.resource.ProjectResource; +import org.springframework.rewrite.project.resource.ProjectResource; /** * Delete files matching path pattern. diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/common/migration/actions/MoveFilesAction.java b/components/sbm-core/src/main/java/org/springframework/sbm/common/migration/actions/MoveFilesAction.java index b802dd442..0dbef18d0 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/common/migration/actions/MoveFilesAction.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/common/migration/actions/MoveFilesAction.java @@ -15,10 +15,10 @@ */ package org.springframework.sbm.common.migration.actions; +import org.springframework.rewrite.project.resource.ProjectResource; +import org.springframework.rewrite.project.resource.finder.PathPatternMatchingProjectResourceFinder; import org.springframework.sbm.engine.recipe.AbstractAction; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.ProjectResource; -import org.springframework.sbm.project.resource.finder.PathPatternMatchingProjectResourceFinder; import lombok.Getter; import lombok.Setter; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/common/migration/conditions/FileMatchingPatternExist.java b/components/sbm-core/src/main/java/org/springframework/sbm/common/migration/conditions/FileMatchingPatternExist.java index d82270d00..557b2679c 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/common/migration/conditions/FileMatchingPatternExist.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/common/migration/conditions/FileMatchingPatternExist.java @@ -16,7 +16,7 @@ package org.springframework.sbm.common.migration.conditions; import lombok.*; -import org.springframework.sbm.utils.OsAgnosticPathMatcher; +import org.springframework.rewrite.utils.OsAgnosticPathMatcher; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.recipe.Condition; import org.springframework.util.PathMatcher; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ApplicableRecipeListCommand.java b/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ApplicableRecipeListCommand.java index 09c14cbc6..f99505566 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ApplicableRecipeListCommand.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ApplicableRecipeListCommand.java @@ -15,12 +15,12 @@ */ package org.springframework.sbm.engine.commands; +import org.springframework.rewrite.scopes.ExecutionScope; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.recipe.ApplicableRecipesListHolder; import org.springframework.sbm.engine.recipe.Recipe; import org.springframework.sbm.engine.recipe.Recipes; import org.springframework.sbm.engine.recipe.RecipesBuilder; -import org.springframework.sbm.scopes.ExecutionScope; import org.springframework.stereotype.Component; import java.util.List; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ApplyCommand.java b/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ApplyCommand.java index a4de73f14..d43199740 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ApplyCommand.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ApplyCommand.java @@ -16,8 +16,9 @@ package org.springframework.sbm.engine.commands; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.sbm.project.resource.finder.DeletedResourcePathStringFilter; -import org.springframework.sbm.project.resource.finder.ModifiedResourcePathStringFilter; +import org.springframework.rewrite.project.resource.finder.DeletedResourcePathStringFilter; +import org.springframework.rewrite.project.resource.finder.ModifiedResourcePathStringFilter; +import org.springframework.rewrite.scopes.ExecutionScope; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.context.ProjectContextSerializer; import org.springframework.sbm.engine.git.GitSupport; @@ -25,7 +26,6 @@ import org.springframework.sbm.engine.recipe.Action; import org.springframework.sbm.engine.recipe.Recipe; import org.springframework.sbm.engine.recipe.RecipesBuilder; -import org.springframework.sbm.scopes.ExecutionScope; import org.springframework.stereotype.Component; import java.util.List; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ApplyCommandHelper.java b/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ApplyCommandHelper.java index fddfe3897..d5f361ae2 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ApplyCommandHelper.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ApplyCommandHelper.java @@ -15,14 +15,14 @@ */ package org.springframework.sbm.engine.commands; +import org.springframework.rewrite.project.resource.finder.DeletedResourcePathStringFilter; +import org.springframework.rewrite.project.resource.finder.ModifiedResourcePathStringFilter; import org.springframework.sbm.engine.git.GitSupport; import org.springframework.sbm.engine.git.ProjectSyncVerifier; import org.springframework.sbm.engine.recipe.Recipe; import org.springframework.sbm.engine.recipe.RecipesBuilder; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.context.ProjectContextSerializer; -import org.springframework.sbm.project.resource.finder.DeletedResourcePathStringFilter; -import org.springframework.sbm.project.resource.finder.ModifiedResourcePathStringFilter; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ScanCommand.java b/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ScanCommand.java index 2d4703dc3..3c5e1b9fd 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ScanCommand.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/engine/commands/ScanCommand.java @@ -25,7 +25,6 @@ import org.springframework.sbm.engine.precondition.PreconditionVerifier; import org.springframework.sbm.project.parser.PathScanner; import org.springframework.sbm.project.parser.ProjectContextInitializer; -import org.springframework.sbm.scopes.ScanScope; import org.springframework.stereotype.Component; import java.nio.file.Path; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContext.java b/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContext.java index e3b0b433a..0fa19c309 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContext.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContext.java @@ -15,14 +15,21 @@ */ package org.springframework.sbm.engine.context; +import lombok.Getter; +import lombok.Setter; import org.openrewrite.ExecutionContext; import org.openrewrite.Recipe; import org.openrewrite.RecipeRun; import org.openrewrite.SourceFile; import org.openrewrite.internal.InMemoryLargeSourceSet; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.ProjectResourceSetFactory; +import org.springframework.rewrite.project.resource.RewriteMigrationResultMerger; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.build.api.ApplicationModules; -import org.springframework.sbm.build.api.Module; import org.springframework.sbm.build.api.BuildFile; +import org.springframework.sbm.build.api.Module; import org.springframework.sbm.build.api.RootBuildFileFilter; import org.springframework.sbm.build.filter.BuildFileProjectResourceFinder; import org.springframework.sbm.java.api.ProjectJavaSources; @@ -30,13 +37,6 @@ import org.springframework.sbm.java.refactoring.JavaRefactoringFactory; import org.springframework.sbm.java.util.BasePackageCalculator; import org.springframework.sbm.parsers.JavaParserBuilder; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.ProjectResourceSetFactory; -import org.springframework.sbm.project.resource.RewriteMigrationResultMerger; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; -import lombok.Getter; -import lombok.Setter; import java.nio.file.Path; import java.util.List; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContextFactory.java b/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContextFactory.java index 348fe9c8d..ad869611b 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContextFactory.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContextFactory.java @@ -16,11 +16,14 @@ package org.springframework.sbm.engine.context; import org.openrewrite.ExecutionContext; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.ProjectResourceSetFactory; +import org.springframework.rewrite.project.resource.RewriteMigrationResultMerger; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.build.api.BuildFile; import org.springframework.sbm.build.filter.BuildFileProjectResourceFinder; -import org.springframework.sbm.engine.recipe.MigrationResultProjectContextMerger; -import org.springframework.sbm.java.refactoring.JavaRefactoringFactory; import org.springframework.sbm.java.impl.ClasspathRegistry; +import org.springframework.sbm.java.refactoring.JavaRefactoringFactory; import org.springframework.sbm.java.util.BasePackageCalculator; import org.springframework.sbm.parsers.JavaParserBuilder; import org.springframework.sbm.project.resource.*; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContextHolder.java b/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContextHolder.java index e9d37c4d9..7a995a123 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContextHolder.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContextHolder.java @@ -17,7 +17,7 @@ import lombok.Getter; import lombok.Setter; -import org.springframework.sbm.scopes.annotations.ScanScope; +import org.springframework.rewrite.scopes.annotations.ScanScope; import org.springframework.stereotype.Component; @Component diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContextSerializer.java b/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContextSerializer.java index 3021a87d2..95418abc2 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContextSerializer.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContextSerializer.java @@ -15,8 +15,8 @@ */ package org.springframework.sbm.engine.context; -import org.springframework.sbm.project.resource.ProjectResourceSetSerializer; import lombok.RequiredArgsConstructor; +import org.springframework.rewrite.project.resource.ProjectResourceSetSerializer; import org.springframework.stereotype.Component; @Component diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/engine/precondition/JavaSourceDirExistsPreconditionCheck.java b/components/sbm-core/src/main/java/org/springframework/sbm/engine/precondition/JavaSourceDirExistsPreconditionCheck.java index 3cc5b724a..3e89db5e8 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/engine/precondition/JavaSourceDirExistsPreconditionCheck.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/engine/precondition/JavaSourceDirExistsPreconditionCheck.java @@ -16,8 +16,8 @@ package org.springframework.sbm.engine.precondition; import org.springframework.core.io.Resource; -import org.springframework.sbm.utils.OsAgnosticPathMatcher; -import org.springframework.sbm.utils.LinuxWindowsPathUnifier; +import org.springframework.rewrite.utils.LinuxWindowsPathUnifier; +import org.springframework.rewrite.utils.OsAgnosticPathMatcher; import org.springframework.stereotype.Component; import org.springframework.util.PathMatcher; @@ -35,7 +35,7 @@ class JavaSourceDirExistsPreconditionCheck extends PreconditionCheck { @Override public PreconditionCheckResult verify(Path projectRoot, List projectResources) { if (projectResources.stream() - .noneMatch(r -> pathMatcher.match(PATTERN, pathUnifier.unifyPath(getPath(r).toAbsolutePath().toString())))) { + .noneMatch(r -> pathMatcher.match(PATTERN, LinuxWindowsPathUnifier.unifiedPathString(r)))) { return new PreconditionCheckResult(ResultState.FAILED, "PreconditionCheck check could not find a '" + JAVA_SRC_DIR + "' dir. This dir is required."); } return new PreconditionCheckResult(ResultState.PASSED, "Found required source dir 'src/main/java'."); diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/engine/recipe/MigrationResultProjectContextMerger.java b/components/sbm-core/src/main/java/org/springframework/sbm/engine/recipe/MigrationResultProjectContextMerger.java index 346e9192c..8ff3d52fd 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/engine/recipe/MigrationResultProjectContextMerger.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/engine/recipe/MigrationResultProjectContextMerger.java @@ -17,18 +17,11 @@ import lombok.RequiredArgsConstructor; import org.openrewrite.Result; -import org.openrewrite.SourceFile; -import org.springframework.sbm.project.resource.RewriteMigrationResultMerger; -import org.springframework.sbm.project.resource.finder.AbsolutePathResourceFinder; +import org.springframework.rewrite.project.resource.RewriteMigrationResultMerger; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.RewriteSourceFileWrapper; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import org.springframework.stereotype.Component; -import java.nio.file.Path; import java.util.List; -import java.util.Optional; @Component @RequiredArgsConstructor diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/engine/recipe/OpenRewriteSourceFilesFinder.java b/components/sbm-core/src/main/java/org/springframework/sbm/engine/recipe/OpenRewriteSourceFilesFinder.java index c2e1dba0a..f53f41300 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/engine/recipe/OpenRewriteSourceFilesFinder.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/engine/recipe/OpenRewriteSourceFilesFinder.java @@ -16,9 +16,9 @@ package org.springframework.sbm.engine.recipe; import org.openrewrite.SourceFile; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; import java.util.List; import java.util.stream.Collectors; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/JavaSourceProjectResourceWrapper.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/JavaSourceProjectResourceWrapper.java index 54aa1a935..f1efb2348 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/JavaSourceProjectResourceWrapper.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/JavaSourceProjectResourceWrapper.java @@ -16,12 +16,12 @@ package org.springframework.sbm.java; import org.openrewrite.ExecutionContext; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.java.impl.OpenRewriteJavaSource; import org.springframework.sbm.java.refactoring.JavaRefactoring; import org.springframework.sbm.java.refactoring.JavaRefactoringFactory; import org.springframework.sbm.parsers.JavaParserBuilder; import org.springframework.sbm.project.resource.ProjectResourceWrapper; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import lombok.RequiredArgsConstructor; import org.openrewrite.SourceFile; import org.openrewrite.java.tree.J; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/api/JavaSource.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/api/JavaSource.java index 3b0313755..dcc2775cd 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/api/JavaSource.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/api/JavaSource.java @@ -15,9 +15,9 @@ */ package org.springframework.sbm.java.api; +import org.springframework.rewrite.project.resource.ProjectResource; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.java.impl.StaticFieldAccessTransformer; -import org.springframework.sbm.project.resource.ProjectResource; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import org.openrewrite.Recipe; import org.openrewrite.java.tree.J; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/api/ProjectJavaSources.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/api/ProjectJavaSources.java index 46eb2356f..82931806a 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/api/ProjectJavaSources.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/api/ProjectJavaSources.java @@ -15,9 +15,9 @@ */ package org.springframework.sbm.java.api; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import org.openrewrite.Recipe; import org.openrewrite.java.tree.J; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import java.util.List; import java.util.Optional; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/filter/FindJavaSourceContainingType.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/filter/FindJavaSourceContainingType.java index baf823359..0b74d4716 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/filter/FindJavaSourceContainingType.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/filter/FindJavaSourceContainingType.java @@ -15,11 +15,11 @@ */ package org.springframework.sbm.java.filter; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.java.api.JavaSourceAndType; import org.springframework.sbm.java.impl.OpenRewriteJavaSource; import org.springframework.sbm.java.impl.OpenRewriteType; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; import java.util.Optional; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/filter/JavaSourceListFinder.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/filter/JavaSourceListFinder.java index 97e8ce662..e27149c81 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/filter/JavaSourceListFinder.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/filter/JavaSourceListFinder.java @@ -15,8 +15,8 @@ */ package org.springframework.sbm.java.filter; +import org.springframework.rewrite.project.resource.finder.GenericTypeListFinder; import org.springframework.sbm.java.api.JavaSource; -import org.springframework.sbm.project.resource.finder.GenericTypeListFinder; public class JavaSourceListFinder extends GenericTypeListFinder { public JavaSourceListFinder() { diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/filter/OpenRewriteJavaSourceListFinder.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/filter/OpenRewriteJavaSourceListFinder.java index 0b1f06ce0..cf22bb1fd 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/filter/OpenRewriteJavaSourceListFinder.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/filter/OpenRewriteJavaSourceListFinder.java @@ -15,8 +15,8 @@ */ package org.springframework.sbm.java.filter; +import org.springframework.rewrite.project.resource.finder.GenericTypeListFinder; import org.springframework.sbm.java.impl.OpenRewriteJavaSource; -import org.springframework.sbm.project.resource.finder.GenericTypeListFinder; public class OpenRewriteJavaSourceListFinder extends GenericTypeListFinder { diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/ClasspathRegistry.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/ClasspathRegistry.java index 771e9945a..d8aa66eea 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/ClasspathRegistry.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/ClasspathRegistry.java @@ -19,9 +19,9 @@ import org.openrewrite.maven.cache.LocalMavenArtifactCache; import org.openrewrite.maven.tree.ResolvedDependency; import org.openrewrite.maven.tree.Scope; +import org.springframework.rewrite.parsers.maven.RewriteMavenArtifactDownloader; import org.springframework.sbm.build.api.BuildFile; import org.springframework.sbm.build.impl.OpenRewriteMavenBuildFile; -import org.springframework.sbm.parsers.maven.RewriteMavenArtifactDownloader; import org.springframework.sbm.project.parser.DependencyHelper; import java.nio.file.Path; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/DependencyChangeHandler.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/DependencyChangeHandler.java index d676a9891..df84ab264 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/DependencyChangeHandler.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/DependencyChangeHandler.java @@ -28,6 +28,8 @@ import org.openrewrite.maven.tree.ResolvedDependency; import org.openrewrite.maven.tree.Scope; import org.openrewrite.maven.utilities.MavenArtifactDownloader; +import org.springframework.rewrite.parsers.SourceFileParser; +import org.springframework.rewrite.utils.JavaHelper; import org.springframework.sbm.build.api.ApplicationModules; import org.springframework.sbm.build.api.Module; import org.springframework.sbm.build.impl.OpenRewriteMavenBuildFile; @@ -35,8 +37,6 @@ import org.springframework.sbm.engine.context.ProjectContextHolder; import org.springframework.sbm.java.api.JavaSource; import org.springframework.sbm.parsers.JavaParserBuilder; -import org.springframework.sbm.parsers.SourceFileParser; -import org.springframework.sbm.utils.JavaHelper; import org.springframework.stereotype.Component; import java.io.ByteArrayInputStream; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/JavaParserFactory.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/JavaParserFactory.java index b975ebbdc..c1ce540a8 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/JavaParserFactory.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/JavaParserFactory.java @@ -18,7 +18,7 @@ import org.jetbrains.annotations.NotNull; import org.openrewrite.ExecutionContext; import org.openrewrite.java.JavaParser; -import org.springframework.sbm.project.resource.SbmApplicationProperties; +import org.springframework.rewrite.parsers.SpringRewriteProperties; import java.nio.file.Path; import java.util.ArrayList; @@ -33,7 +33,7 @@ public class JavaParserFactory { @Deprecated public static @NotNull JavaParser getInitialJavaParser(ExecutionContext executionContext) { Set dependencies = ClasspathRegistry.getInstance().getInitialDependencies(); - JavaParser javaParser = new RewriteJavaParser(new SbmApplicationProperties(), executionContext); + JavaParser javaParser = new RewriteJavaParser(new SpringRewriteProperties(), executionContext); javaParser.setClasspath(new ArrayList<>(dependencies)); return javaParser; } @@ -41,7 +41,7 @@ public class JavaParserFactory { @Deprecated public static @NotNull JavaParser getCurrentJavaParser(ExecutionContext executionContext) { Set dependencies = ClasspathRegistry.getInstance().getCurrentDependencies(); - JavaParser javaParser = new RewriteJavaParser(new SbmApplicationProperties(), executionContext); + JavaParser javaParser = new RewriteJavaParser(new SpringRewriteProperties(), executionContext); javaParser.setClasspath(new ArrayList<>(dependencies)); return javaParser; } diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteJavaSource.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteJavaSource.java index 07443da61..9dbe72c07 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteJavaSource.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteJavaSource.java @@ -23,11 +23,11 @@ import org.openrewrite.java.tree.J; import org.openrewrite.java.tree.JavaType; import org.openrewrite.marker.Marker; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.parsers.JavaParserBuilder; import org.springframework.sbm.java.api.*; import org.springframework.sbm.java.migration.visitor.ReplaceLiteralVisitor; import org.springframework.sbm.java.refactoring.JavaRefactoring; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.search.recipe.CommentJavaSearchResult; import java.io.File; @@ -53,7 +53,6 @@ public OpenRewriteJavaSource(Path absoluteProjectPath, J.CompilationUnit compila @Deprecated public RewriteSourceFileHolder getResource() { - // FIXME: now is a RewriteSourceFileHolder return this; } diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteMember.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteMember.java index 9241ef8dd..9fbedac01 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteMember.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteMember.java @@ -15,11 +15,6 @@ */ package org.springframework.sbm.java.impl; -import org.springframework.sbm.java.api.Annotation; -import org.springframework.sbm.java.api.Member; -import org.springframework.sbm.java.refactoring.JavaRefactoring; -import org.springframework.sbm.parsers.JavaParserBuilder; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.openrewrite.internal.lang.Nullable; @@ -27,6 +22,11 @@ import org.openrewrite.java.tree.J.VariableDeclarations.NamedVariable; import org.openrewrite.java.tree.JavaType; import org.openrewrite.java.tree.TypeTree; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.sbm.java.api.Annotation; +import org.springframework.sbm.java.api.Member; +import org.springframework.sbm.java.refactoring.JavaRefactoring; +import org.springframework.sbm.parsers.JavaParserBuilder; import org.springframework.sbm.support.openrewrite.java.AddAnnotationVisitor; import org.springframework.sbm.support.openrewrite.java.RemoveAnnotationVisitor; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteMethod.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteMethod.java index 177500cd5..93d7b125b 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteMethod.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteMethod.java @@ -19,19 +19,15 @@ import org.openrewrite.ExecutionContext; import org.openrewrite.Recipe; import org.openrewrite.java.ChangeMethodName; -import org.openrewrite.java.tree.J; -import org.openrewrite.java.tree.JavaType; -import org.openrewrite.java.tree.Statement; -import org.openrewrite.java.tree.TypeTree; -import org.openrewrite.java.tree.TypeUtils; +import org.openrewrite.java.tree.*; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.support.openrewrite.GenericOpenRewriteRecipe; import org.springframework.sbm.java.api.Annotation; import org.springframework.sbm.java.api.Method; import org.springframework.sbm.java.api.MethodParam; import org.springframework.sbm.java.api.Visibility; import org.springframework.sbm.java.refactoring.JavaRefactoring; import org.springframework.sbm.parsers.JavaParserBuilder; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; import org.springframework.sbm.support.openrewrite.java.AddAnnotationVisitor; import org.springframework.sbm.support.openrewrite.java.RemoveAnnotationVisitor; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteMethodParam.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteMethodParam.java index ccb670e4f..2d111118c 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteMethodParam.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteMethodParam.java @@ -15,19 +15,18 @@ */ package org.springframework.sbm.java.impl; +import lombok.extern.slf4j.Slf4j; import org.openrewrite.ExecutionContext; +import org.openrewrite.java.tree.J; +import org.openrewrite.java.tree.JavaType; +import org.openrewrite.java.tree.Statement; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.java.api.Annotation; import org.springframework.sbm.java.api.MethodParam; import org.springframework.sbm.java.refactoring.JavaRefactoring; import org.springframework.sbm.parsers.JavaParserBuilder; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.support.openrewrite.java.AddAnnotationVisitor; import org.springframework.sbm.support.openrewrite.java.RemoveAnnotationVisitor; -import lombok.extern.slf4j.Slf4j; -import org.openrewrite.java.JavaParser; -import org.openrewrite.java.tree.J; -import org.openrewrite.java.tree.JavaType; -import org.openrewrite.java.tree.Statement; import java.util.List; import java.util.regex.Pattern; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteType.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteType.java index 6ef4c00b4..7bbec383d 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteType.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/OpenRewriteType.java @@ -15,20 +15,23 @@ */ package org.springframework.sbm.java.impl; -import org.openrewrite.*; +import lombok.extern.slf4j.Slf4j; +import org.openrewrite.ExecutionContext; +import org.openrewrite.Recipe; import org.openrewrite.java.*; import org.openrewrite.java.format.WrappingAndBraces; -import org.openrewrite.java.tree.*; +import org.openrewrite.java.search.DeclaresMethod; +import org.openrewrite.java.tree.J; +import org.openrewrite.java.tree.J.ClassDeclaration; +import org.openrewrite.java.tree.JavaType; +import org.openrewrite.java.tree.JavaType.Class; +import org.openrewrite.java.tree.TypeUtils; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.support.openrewrite.GenericOpenRewriteRecipe; import org.springframework.sbm.java.api.*; import org.springframework.sbm.java.migration.visitor.RemoveImplementsVisitor; import org.springframework.sbm.java.refactoring.JavaRefactoring; import org.springframework.sbm.parsers.JavaParserBuilder; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; -import lombok.extern.slf4j.Slf4j; -import org.openrewrite.java.search.DeclaresMethod; -import org.openrewrite.java.tree.J.ClassDeclaration; -import org.openrewrite.java.tree.JavaType.Class; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; import org.springframework.sbm.support.openrewrite.java.AddAnnotationVisitor; import org.springframework.sbm.support.openrewrite.java.FindCompilationUnitContainingType; import org.springframework.sbm.support.openrewrite.java.RemoveAnnotationVisitor; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/ProjectJavaSourcesImpl.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/ProjectJavaSourcesImpl.java index 4814d2f70..7f93afd0b 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/ProjectJavaSourcesImpl.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/ProjectJavaSourcesImpl.java @@ -25,13 +25,13 @@ import org.openrewrite.java.tree.J; import org.openrewrite.java.tree.JavaType; import org.openrewrite.java.tree.TypeUtils; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.support.openrewrite.GenericOpenRewriteRecipe; import org.springframework.sbm.java.api.*; import org.springframework.sbm.java.exceptions.UnresolvedTypeException; import org.springframework.sbm.java.filter.JavaSourceListFinder; import org.springframework.sbm.java.refactoring.JavaGlobalRefactoring; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; import java.util.ArrayList; import java.util.List; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/RewriteJavaParser.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/RewriteJavaParser.java index f7140c0cb..cd6819e03 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/RewriteJavaParser.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/impl/RewriteJavaParser.java @@ -21,10 +21,9 @@ import org.openrewrite.SourceFile; import org.openrewrite.internal.lang.Nullable; import org.openrewrite.java.JavaParser; -import org.openrewrite.java.marker.JavaSourceSet; import org.openrewrite.java.tree.J; -import org.springframework.sbm.project.resource.SbmApplicationProperties; -import org.springframework.sbm.scopes.annotations.ScanScope; +import org.springframework.rewrite.parsers.SpringRewriteProperties; +import org.springframework.rewrite.scopes.annotations.ScanScope; import org.springframework.stereotype.Component; import java.net.URI; @@ -39,14 +38,14 @@ @Deprecated public class RewriteJavaParser implements JavaParser { - private final SbmApplicationProperties sbmApplicationProperties; + private final SpringRewriteProperties sbmApplicationProperties; @Getter private final JavaParser javaParser; private final ExecutionContext executionContext; // satisfies DI - public RewriteJavaParser(SbmApplicationProperties sbmApplicationProperties, ExecutionContext executionContext) { + public RewriteJavaParser(SpringRewriteProperties sbmApplicationProperties, ExecutionContext executionContext) { this.sbmApplicationProperties = sbmApplicationProperties; this.executionContext = executionContext; javaParser = buildJavaParser(Collections.emptySet()); @@ -55,7 +54,7 @@ public RewriteJavaParser(SbmApplicationProperties sbmApplicationProperties, Exec @NotNull private JavaParser buildJavaParser(Collection classpath) { Builder builder = JavaParser.fromJavaVersion() - .logCompilationWarningsAndErrors(sbmApplicationProperties.isJavaParserLoggingCompilationWarningsAndErrors()); + .logCompilationWarningsAndErrors(sbmApplicationProperties.isLogCompilationWarningsAndErrors()); if (!classpath.isEmpty()) { builder.classpath(classpath); } diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaGlobalRefactoring.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaGlobalRefactoring.java index 41df0763e..87234039c 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaGlobalRefactoring.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaGlobalRefactoring.java @@ -15,11 +15,11 @@ */ package org.springframework.sbm.java.refactoring; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import org.openrewrite.ExecutionContext; import org.openrewrite.Recipe; import org.openrewrite.java.JavaVisitor; import org.openrewrite.java.tree.J; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import java.util.List; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaGlobalRefactoringImpl.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaGlobalRefactoringImpl.java index 8be386600..76859da0d 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaGlobalRefactoringImpl.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaGlobalRefactoringImpl.java @@ -25,9 +25,9 @@ import org.openrewrite.marker.Markers; import org.openrewrite.marker.RecipesThatMadeChanges; import org.openrewrite.marker.SearchResult; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.support.openrewrite.GenericOpenRewriteRecipe; import java.util.Arrays; import java.util.List; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoring.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoring.java index 492969b08..693e3d432 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoring.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoring.java @@ -15,11 +15,11 @@ */ package org.springframework.sbm.java.refactoring; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import org.openrewrite.ExecutionContext; import org.openrewrite.Recipe; import org.openrewrite.java.JavaVisitor; import org.openrewrite.java.tree.J; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import java.util.List; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoringFactory.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoringFactory.java index 410f1c5f5..4505400f8 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoringFactory.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoringFactory.java @@ -15,8 +15,8 @@ */ package org.springframework.sbm.java.refactoring; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import org.openrewrite.java.tree.J; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; public interface JavaRefactoringFactory { diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoringFactoryImpl.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoringFactoryImpl.java index 3004e22c0..cfda8424d 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoringFactoryImpl.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoringFactoryImpl.java @@ -17,7 +17,7 @@ import org.openrewrite.ExecutionContext; import org.springframework.sbm.project.resource.ProjectResourceSetHolder; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import lombok.RequiredArgsConstructor; import org.openrewrite.java.tree.J; import org.springframework.stereotype.Component; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoringImpl.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoringImpl.java index 7a5ba2a65..9dcf5839c 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoringImpl.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/refactoring/JavaRefactoringImpl.java @@ -15,15 +15,14 @@ */ package org.springframework.sbm.java.refactoring; -import org.openrewrite.java.tree.JavaType; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; import org.openrewrite.ExecutionContext; import org.openrewrite.Recipe; import org.openrewrite.Result; import org.openrewrite.java.JavaVisitor; import org.openrewrite.java.tree.J; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.support.openrewrite.GenericOpenRewriteRecipe; import java.util.Arrays; import java.util.List; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/java/util/BasePackageCalculator.java b/components/sbm-core/src/main/java/org/springframework/sbm/java/util/BasePackageCalculator.java index a0a4495f5..2ce1284eb 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/java/util/BasePackageCalculator.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/java/util/BasePackageCalculator.java @@ -15,14 +15,14 @@ */ package org.springframework.sbm.java.util; +import lombok.RequiredArgsConstructor; import org.springframework.sbm.java.api.JavaSource; import org.springframework.sbm.project.resource.SbmApplicationProperties; -import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; -import java.util.List; import java.util.ArrayList; import java.util.Comparator; +import java.util.List; /** * Calculates and returns the base package when given a list of JavaSource diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/parsers/JavaParserBuilder.java b/components/sbm-core/src/main/java/org/springframework/sbm/parsers/JavaParserBuilder.java index 5004179a0..a9cb8f195 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/parsers/JavaParserBuilder.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/parsers/JavaParserBuilder.java @@ -18,7 +18,7 @@ import lombok.Getter; import lombok.Setter; import org.openrewrite.java.JavaParser; -import org.springframework.sbm.scopes.annotations.ScanScope; +import org.springframework.rewrite.scopes.annotations.ScanScope; import org.springframework.stereotype.Component; import java.util.function.Supplier; @@ -32,7 +32,7 @@ public class JavaParserBuilder extends JavaParser.Builder{ @Getter @Setter - private JavaParser.Builder builder; + private JavaParser.Builder builder = JavaParser.fromJavaVersion(); public Supplier getSupplier() { return () -> builder; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/MavenProjectParser.java b/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/MavenProjectParser.java index e649d704e..533feba53 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/MavenProjectParser.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/MavenProjectParser.java @@ -19,7 +19,7 @@ import lombok.extern.slf4j.Slf4j; import org.openrewrite.SourceFile; import org.springframework.core.io.Resource; -import org.springframework.sbm.parsers.RewriteProjectParser; +import org.springframework.rewrite.parsers.RewriteProjectParser; import org.springframework.stereotype.Component; import java.nio.file.Path; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/PathScanner.java b/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/PathScanner.java index f9dfe129e..0ee832e3e 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/PathScanner.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/PathScanner.java @@ -17,10 +17,10 @@ import lombok.RequiredArgsConstructor; import org.springframework.core.io.Resource; -import org.springframework.sbm.utils.OsAgnosticPathMatcher; +import org.springframework.rewrite.utils.LinuxWindowsPathUnifier; +import org.springframework.rewrite.utils.OsAgnosticPathMatcher; import org.springframework.sbm.project.resource.ResourceHelper; import org.springframework.sbm.project.resource.SbmApplicationProperties; -import org.springframework.sbm.utils.LinuxWindowsPathUnifier; import org.springframework.stereotype.Service; import org.springframework.util.PathMatcher; @@ -37,11 +37,10 @@ public class PathScanner { private final SbmApplicationProperties sbmApplicationProperties; private final ResourceHelper resourceHelper; private final PathMatcher pathMatcher = new OsAgnosticPathMatcher(); - private final LinuxWindowsPathUnifier pathUnifier = new LinuxWindowsPathUnifier(); public List scan(Path projectRoot) { Path absoluteRootPath = projectRoot.toAbsolutePath(); - String pattern = new LinuxWindowsPathUnifier().unifyPath(absoluteRootPath.toString() + "/**"); + String pattern = LinuxWindowsPathUnifier.unifiedPathString(absoluteRootPath) + "/**"; Resource[] resources = resourceHelper.loadResources("file:" + pattern); return Arrays.asList(resources) @@ -56,7 +55,7 @@ private boolean isRelevant(Path projectRoot, Path givenResource) { } return sbmApplicationProperties.getIgnoredPathsPatterns().stream() .noneMatch(ir -> pathMatcher.match(ir, - pathUnifier.unifyPath(projectRoot.relativize(givenResource)))); + LinuxWindowsPathUnifier.unifiedPathString(projectRoot.relativize(givenResource)))); } private Path getPath(Resource r) { diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/ProjectContextInitializer.java b/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/ProjectContextInitializer.java index 924ab9e40..1dce931ba 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/ProjectContextInitializer.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/ProjectContextInitializer.java @@ -19,16 +19,16 @@ import org.openrewrite.ExecutionContext; import org.openrewrite.SourceFile; import org.springframework.core.io.Resource; +import org.springframework.rewrite.parsers.RewriteProjectParser; +import org.springframework.rewrite.project.RewriteSourceFileWrapper; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.ProjectResourceSetFactory; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.context.ProjectContextFactory; import org.springframework.sbm.engine.context.ProjectContextHolder; import org.springframework.sbm.engine.git.Commit; import org.springframework.sbm.engine.git.GitSupport; -import org.springframework.sbm.parsers.RewriteProjectParser; -import org.springframework.sbm.project.RewriteSourceFileWrapper; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.ProjectResourceSetFactory; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.stereotype.Component; import java.nio.file.Path; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/ResourceParser.java b/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/ResourceParser.java index a7952737f..407f0a481 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/ResourceParser.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/ResourceParser.java @@ -28,6 +28,7 @@ import org.openrewrite.properties.PropertiesParser; import org.openrewrite.protobuf.ProtoParser; import org.openrewrite.text.PlainTextParser; +import org.openrewrite.tree.ParsingEventListener; import org.openrewrite.tree.ParsingExecutionContextView; import org.openrewrite.xml.XmlParser; import org.openrewrite.yaml.YamlParser; @@ -116,7 +117,14 @@ public List parse(Path baseDir, List relevantResources, Li }); ParsingExecutionContextView ctx = ParsingExecutionContextView.view(executionContext); - ctx.setParsingListener((input, sourceFile) -> eventPublisher.publishEvent(new StartedScanningProjectResourceEvent(sourceFile.getSourcePath()))); + ParsingEventListener parsingEventListener = new ParsingEventListener() { + @Override + public void parsed(Parser.Input input, SourceFile sourceFile) { + Path sourcePath = sourceFile.getSourcePath(); + eventPublisher.publishEvent(new StartedScanningProjectResourceEvent(sourcePath)); + } + }; + ctx.setParsingListener(parsingEventListener); return parserAndParserInputMappings.entrySet().stream() .filter(ifNoInput()) diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/RewriteMavenParserFactory.java b/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/RewriteMavenParserFactory.java index 32972754e..768f99022 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/RewriteMavenParserFactory.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/project/parser/RewriteMavenParserFactory.java @@ -19,7 +19,7 @@ import org.openrewrite.maven.cache.LocalMavenArtifactCache; import org.openrewrite.maven.cache.ReadOnlyLocalMavenArtifactCache; import org.openrewrite.maven.utilities.MavenArtifactDownloader; -import org.springframework.sbm.parsers.RewriteExecutionContext; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import java.nio.file.Path; import java.nio.file.Paths; diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/project/resource/ProjectResourceSetHolder.java b/components/sbm-core/src/main/java/org/springframework/sbm/project/resource/ProjectResourceSetHolder.java similarity index 86% rename from sbm-support-rewrite/src/main/java/org/springframework/sbm/project/resource/ProjectResourceSetHolder.java rename to components/sbm-core/src/main/java/org/springframework/sbm/project/resource/ProjectResourceSetHolder.java index ef517587c..b5140bdcd 100644 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/project/resource/ProjectResourceSetHolder.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/project/resource/ProjectResourceSetHolder.java @@ -17,10 +17,14 @@ import lombok.RequiredArgsConstructor; import org.openrewrite.ExecutionContext; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.RewriteMigrationResultMerger; +import org.springframework.stereotype.Component; import java.util.ArrayList; @RequiredArgsConstructor +@Component public class ProjectResourceSetHolder { private ProjectResourceSet projectResourceSet; private final ExecutionContext executionContext; diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/project/resource/ProjectResourceWrapper.java b/components/sbm-core/src/main/java/org/springframework/sbm/project/resource/ProjectResourceWrapper.java similarity index 92% rename from sbm-support-rewrite/src/main/java/org/springframework/sbm/project/resource/ProjectResourceWrapper.java rename to components/sbm-core/src/main/java/org/springframework/sbm/project/resource/ProjectResourceWrapper.java index 9913a78ab..92d5fbb71 100644 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/project/resource/ProjectResourceWrapper.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/project/resource/ProjectResourceWrapper.java @@ -16,9 +16,10 @@ package org.springframework.sbm.project.resource; import org.openrewrite.SourceFile; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; public interface ProjectResourceWrapper> { boolean shouldHandle(RewriteSourceFileHolder rewriteSourceFileHolder); TO wrapRewriteSourceFileHolder(RewriteSourceFileHolder rewriteSourceFileHolder); -} +} \ No newline at end of file diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/project/resource/ProjectResourceWrapperRegistry.java b/components/sbm-core/src/main/java/org/springframework/sbm/project/resource/ProjectResourceWrapperRegistry.java index 06f7f23b9..e8cd78c8b 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/project/resource/ProjectResourceWrapperRegistry.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/project/resource/ProjectResourceWrapperRegistry.java @@ -17,6 +17,7 @@ import lombok.RequiredArgsConstructor; import org.openrewrite.SourceFile; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.stereotype.Component; import java.util.List; diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/project/resource/SbmApplicationProperties.java b/components/sbm-core/src/main/java/org/springframework/sbm/project/resource/SbmApplicationProperties.java similarity index 96% rename from sbm-support-rewrite/src/main/java/org/springframework/sbm/project/resource/SbmApplicationProperties.java rename to components/sbm-core/src/main/java/org/springframework/sbm/project/resource/SbmApplicationProperties.java index cd8391e03..f898128ee 100644 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/project/resource/SbmApplicationProperties.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/project/resource/SbmApplicationProperties.java @@ -18,6 +18,7 @@ import lombok.Getter; import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; @@ -25,6 +26,7 @@ @Setter @Getter +@Component @ConfigurationProperties(prefix = "sbm") public class SbmApplicationProperties { private boolean gitSupportEnabled; @@ -46,4 +48,4 @@ public void setIgnoredPathsPatterns(List patterns) { this.ignoredPathsPatterns = patterns; } -} +} \ No newline at end of file diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/project/resource/StringProjectResource.java b/components/sbm-core/src/main/java/org/springframework/sbm/project/resource/StringProjectResource.java index 98fe10a14..fd6881e2c 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/project/resource/StringProjectResource.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/project/resource/StringProjectResource.java @@ -19,6 +19,7 @@ import org.openrewrite.text.PlainText; import org.openrewrite.text.PlainTextParser; import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import java.nio.file.Path; import java.util.List; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/properties/api/PropertiesSource.java b/components/sbm-core/src/main/java/org/springframework/sbm/properties/api/PropertiesSource.java index 55050f6bd..16fe8f1a3 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/properties/api/PropertiesSource.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/properties/api/PropertiesSource.java @@ -17,7 +17,7 @@ import org.openrewrite.ExecutionContext; import org.openrewrite.internal.InMemoryLargeSourceSet; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.properties.migration.recipes.AddProperty; import lombok.extern.slf4j.Slf4j; import org.openrewrite.Recipe; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/properties/parser/RewritePropertiesParser.java b/components/sbm-core/src/main/java/org/springframework/sbm/properties/parser/RewritePropertiesParser.java index f1d7465b8..ce4242fb4 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/properties/parser/RewritePropertiesParser.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/properties/parser/RewritePropertiesParser.java @@ -15,7 +15,7 @@ */ package org.springframework.sbm.properties.parser; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.openrewrite.properties.PropertiesParser; import org.openrewrite.properties.tree.Properties; import org.springframework.core.io.Resource; diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/xml/parser/RewriteXmlParser.java b/components/sbm-core/src/main/java/org/springframework/sbm/xml/parser/RewriteXmlParser.java index c9e5d5184..381df5bc8 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/xml/parser/RewriteXmlParser.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/xml/parser/RewriteXmlParser.java @@ -16,7 +16,7 @@ package org.springframework.sbm.xml.parser; import org.openrewrite.SourceFile; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.openrewrite.ExecutionContext; import org.openrewrite.xml.XmlParser; import org.openrewrite.xml.tree.Xml; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/archfitfun/ExecutionScopeArchFitTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/archfitfun/ExecutionScopeArchFitTest.java index bb6f0c714..968a91bc4 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/archfitfun/ExecutionScopeArchFitTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/archfitfun/ExecutionScopeArchFitTest.java @@ -26,9 +26,13 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.core.io.FileSystemResource; -import org.springframework.sbm.boot.autoconfigure.SbmSupportRewriteConfiguration; -import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration; -import org.springframework.sbm.parsers.maven.MavenSettingsInitializer; +import org.springframework.rewrite.parsers.RewriteParserConfiguration; +import org.springframework.rewrite.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.parsers.maven.MavenSettingsInitializer; +import org.springframework.rewrite.project.RewriteSourceFileWrapper; +import org.springframework.rewrite.scopes.AbstractBaseScope; +import org.springframework.rewrite.scopes.ProjectMetadata; +import org.springframework.rewrite.scopes.ScanScope; import org.springframework.sbm.engine.commands.ApplicableRecipeListCommand; import org.springframework.sbm.engine.commands.ApplyCommand; import org.springframework.sbm.engine.commands.ScanCommand; @@ -40,18 +44,14 @@ import org.springframework.sbm.java.refactoring.JavaRefactoringFactoryImpl; import org.springframework.sbm.java.util.BasePackageCalculator; import org.springframework.sbm.parsers.JavaParserBuilder; -import org.springframework.sbm.project.RewriteSourceFileWrapper; import org.springframework.sbm.project.parser.*; import org.springframework.sbm.project.resource.ProjectResourceSetHolder; import org.springframework.sbm.project.resource.ProjectResourceWrapperRegistry; import org.springframework.sbm.project.resource.ResourceHelper; import org.springframework.sbm.project.resource.SbmApplicationProperties; -import org.springframework.sbm.scopes.AbstractBaseScope; -import org.springframework.sbm.scopes.ExecutionScope; -import org.springframework.sbm.scopes.ProjectMetadata; -import org.springframework.sbm.scopes.ScanScope; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.validation.beanvalidation.CustomValidatorBean; +import org.springframework.rewrite.scopes.ExecutionScope; import java.nio.file.Path; import java.util.ArrayList; @@ -64,10 +64,10 @@ import static org.springframework.sbm.archfitfun.ExecutionScopeArchFitTest.ScopeCacheHelper.getCacheSnapshot; /** - * Architectural Fitnesse Function for the concept of a `scanScope` ({@link org.springframework.sbm.scopes.annotations.ScanScope}) and `executionScope` ({@link org.springframework.sbm.scopes.annotations.ExecutionScope}). + * Architectural Fitnesse Function for the concept of a `scanScope` ({@link org.springframework.rewrite.scopes.annotations.ScanScope}) and `executionScope` ({@link ExecutionScope}). * * ## executionScope - * Beans annotated with {@link org.springframework.sbm.scopes.annotations.ExecutionScope} will be created on first access and added to the executionScope. + * Beans annotated with {@link ExecutionScope} will be created on first access and added to the executionScope. * Subsequent usages will receive the executionScoped instance from the scope until the scope ends and all scoped beans * get removed from the scope. * @@ -80,7 +80,7 @@ * - or when the application stops. * * ## scanScope - * Beans annotated with {@link org.springframework.sbm.scopes.annotations.ScanScope} will be created on first access during scan/parse and added to the scanScope. + * Beans annotated with {@link org.springframework.rewrite.scopes.annotations.ScanScope} will be created on first access during scan/parse and added to the scanScope. * Subsequent usages will receive instances from the scanScope until the scope ends and all scoped beans get removed * from the scope. * @@ -137,7 +137,7 @@ ApplicableRecipesListHolder.class, SbmRecipeLoader.class, ExecutionScopeArchFitTestContext.class, - SbmSupportRewriteConfiguration.class + RewriteParserConfiguration.class }, properties = { "spring.main.allow-bean-definition-overriding=true", // required to provide custom ProjectMetadata diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/archfitfun/ExecutionScopeArchFitTestContext.java b/components/sbm-core/src/test/java/org/springframework/sbm/archfitfun/ExecutionScopeArchFitTestContext.java index c4dfdbbc0..8b87d47c9 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/archfitfun/ExecutionScopeArchFitTestContext.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/archfitfun/ExecutionScopeArchFitTestContext.java @@ -19,13 +19,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; +import org.springframework.rewrite.parsers.RewriteExecutionContext; +import org.springframework.rewrite.scopes.ProjectMetadata; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.recipe.AbstractAction; import org.springframework.sbm.engine.recipe.Action; import org.springframework.sbm.engine.recipe.Condition; import org.springframework.sbm.engine.recipe.Recipe; -import org.springframework.sbm.parsers.RewriteExecutionContext; -import org.springframework.sbm.scopes.ProjectMetadata; import java.util.UUID; @@ -93,7 +93,7 @@ public boolean evaluate(ProjectContext context) { } @Bean - @org.springframework.sbm.scopes.annotations.ScanScope + @org.springframework.rewrite.scopes.annotations.ScanScope ProjectMetadata projectMetadata() { ProjectMetadata projectMetadata = new ProjectMetadata(); testRecorder().projectMetadataCreated(projectMetadata); @@ -101,7 +101,7 @@ ProjectMetadata projectMetadata() { } @Bean - @org.springframework.sbm.scopes.annotations.ScanScope + @org.springframework.rewrite.scopes.annotations.ScanScope ExecutionContext executionContext(ProjectMetadata projectMetadata) { String id = UUID.randomUUID().toString(); RewriteExecutionContext rewriteExecutionContext = new RewriteExecutionContext(); diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java index 3a4cc2a08..77e6e272f 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java @@ -23,10 +23,10 @@ import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.lang.ArchRule; import org.openrewrite.ExecutionContext; +import org.springframework.rewrite.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.SbmCoreConfig; -import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration; import org.springframework.sbm.java.OpenRewriteTestSupport; -import org.springframework.sbm.parsers.RewriteExecutionContext; import static com.tngtech.archunit.lang.conditions.ArchConditions.notBe; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchMainJava_Test.java b/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchMainJava_Test.java index 700a42c18..924069505 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchMainJava_Test.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchMainJava_Test.java @@ -21,11 +21,11 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.openrewrite.SourceFile; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.resource.TestProjectContext; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; import java.nio.file.Path; import java.util.List; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchMainResources_Test.java b/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchMainResources_Test.java index db9b38a0d..f8336c029 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchMainResources_Test.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchMainResources_Test.java @@ -21,10 +21,10 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.openrewrite.SourceFile; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.resource.TestProjectContext; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; import java.nio.file.Path; import java.util.List; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchTestJava_Test.java b/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchTestJava_Test.java index 2292fa389..8395548eb 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchTestJava_Test.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchTestJava_Test.java @@ -21,11 +21,11 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.openrewrite.SourceFile; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.resource.TestProjectContext; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; import java.nio.file.Path; import java.util.List; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchTestResources_Test.java b/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchTestResources_Test.java index a21d7183e..e6db6c941 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchTestResources_Test.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/build/api/Module_searchTestResources_Test.java @@ -21,10 +21,10 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.openrewrite.SourceFile; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.resource.TestProjectContext; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/build/api/SpringManagedDependenciesTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/build/api/SpringManagedDependenciesTest.java index fd91c2aea..bad2ff385 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/build/api/SpringManagedDependenciesTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/build/api/SpringManagedDependenciesTest.java @@ -17,7 +17,7 @@ import org.junit.jupiter.api.Test; import org.openrewrite.ExecutionContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import static org.assertj.core.api.Assertions.assertThat; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/build/migration/actions/RemovePluginsMatchingRegexTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/build/migration/actions/RemovePluginsMatchingRegexTest.java index 014ccf05a..b0af17e89 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/build/migration/actions/RemovePluginsMatchingRegexTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/build/migration/actions/RemovePluginsMatchingRegexTest.java @@ -129,8 +129,8 @@ void apply() { jar hello-world - 3.5.3 - 2.2.4 + 2.1 + 2.1.0 4.1.5 1.5.4 1.1.5 @@ -138,6 +138,20 @@ void apply() { 11 3.1.2 + + + Mule Releases + mule-releases + https://repository.mulesoft.org/releases/ + + + + + Mule Releases + mule-releases + https://repository.mulesoft.org/releases/ + + diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/common/migration/actions/MoveFilesActionTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/common/migration/actions/MoveFilesActionTest.java index 6318f7221..7b4bd852b 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/common/migration/actions/MoveFilesActionTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/common/migration/actions/MoveFilesActionTest.java @@ -17,10 +17,10 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.springframework.sbm.project.resource.finder.PathPatternMatchingProjectResourceFinder; +import org.springframework.rewrite.project.resource.InternalProjectResource; +import org.springframework.rewrite.project.resource.ProjectResource; +import org.springframework.rewrite.project.resource.finder.PathPatternMatchingProjectResourceFinder; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.InternalProjectResource; -import org.springframework.sbm.project.resource.ProjectResource; import org.springframework.sbm.project.resource.TestProjectContext; import java.nio.file.Path; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/common/util/OsAgnosticPathMatcherTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/common/util/OsAgnosticPathMatcherTest.java index 6451f90af..3157f7b95 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/common/util/OsAgnosticPathMatcherTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/common/util/OsAgnosticPathMatcherTest.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; -import org.springframework.sbm.utils.OsAgnosticPathMatcher; +import org.springframework.rewrite.utils.OsAgnosticPathMatcher; import org.springframework.util.PathMatcher; import static org.assertj.core.api.Assertions.assertThat; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/engine/commands/ApplyCommandTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/engine/commands/ApplyCommandTest.java index c4ab64257..fb5fa7272 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/engine/commands/ApplyCommandTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/engine/commands/ApplyCommandTest.java @@ -21,6 +21,7 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.openrewrite.ExecutionContext; +import org.springframework.rewrite.scopes.ExecutionScope; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.context.ProjectContextSerializer; import org.springframework.sbm.engine.git.GitSupport; @@ -29,7 +30,6 @@ import org.springframework.sbm.engine.recipe.Recipe; import org.springframework.sbm.engine.recipe.Recipes; import org.springframework.sbm.engine.recipe.RecipesBuilder; -import org.springframework.sbm.scopes.ExecutionScope; import java.util.List; import java.util.Optional; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/engine/recipe/OpenRewriteDeclarativeRecipeAdapterIntegrationTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/engine/recipe/OpenRewriteDeclarativeRecipeAdapterIntegrationTest.java index 67d337c37..b3e5673b9 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/engine/recipe/OpenRewriteDeclarativeRecipeAdapterIntegrationTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/engine/recipe/OpenRewriteDeclarativeRecipeAdapterIntegrationTest.java @@ -18,14 +18,14 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.parsers.RewriteExecutionContext; +import org.springframework.rewrite.project.RewriteSourceFileWrapper; +import org.springframework.rewrite.scopes.ExecutionScope; +import org.springframework.rewrite.scopes.ScanScope; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; -import org.springframework.sbm.project.RewriteSourceFileWrapper; import org.springframework.sbm.project.resource.ResourceHelper; import org.springframework.sbm.project.resource.TestProjectContext; -import org.springframework.sbm.scopes.ExecutionScope; -import org.springframework.sbm.scopes.ScanScope; import org.springframework.validation.beanvalidation.CustomValidatorBean; import java.io.IOException; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/engine/recipe/OpenRewriteNamedRecipeAdapterIntegrationTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/engine/recipe/OpenRewriteNamedRecipeAdapterIntegrationTest.java index b8ac480a0..6eca2bdee 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/engine/recipe/OpenRewriteNamedRecipeAdapterIntegrationTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/engine/recipe/OpenRewriteNamedRecipeAdapterIntegrationTest.java @@ -19,14 +19,14 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.boot.autoconfigure.SbmSupportRewriteConfiguration; +import org.springframework.rewrite.parsers.RewriteExecutionContext; +import org.springframework.rewrite.project.RewriteSourceFileWrapper; +import org.springframework.rewrite.scopes.ExecutionScope; +import org.springframework.rewrite.scopes.ScanScope; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; -import org.springframework.sbm.project.RewriteSourceFileWrapper; import org.springframework.sbm.project.resource.ResourceHelper; import org.springframework.sbm.project.resource.TestProjectContext; -import org.springframework.sbm.scopes.ExecutionScope; -import org.springframework.sbm.scopes.ScanScope; import org.springframework.validation.beanvalidation.CustomValidatorBean; import java.io.IOException; @@ -48,7 +48,7 @@ RewriteExecutionContext.class, ScanScope.class, ExecutionScope.class, - ScopeConfiguration.class + SbmSupportRewriteConfiguration.class }) public class OpenRewriteNamedRecipeAdapterIntegrationTest { diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/ClasspathRegistryTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/ClasspathRegistryTest.java index cfa457994..5806010f1 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/ClasspathRegistryTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/ClasspathRegistryTest.java @@ -22,10 +22,10 @@ import org.openrewrite.maven.tree.ResolvedDependency; import org.openrewrite.maven.tree.Scope; import org.openrewrite.xml.tree.Xml; +import org.springframework.rewrite.parsers.RewriteExecutionContext; +import org.springframework.rewrite.parsers.maven.MavenSettingsInitializer; +import org.springframework.rewrite.scopes.ProjectMetadata; import org.springframework.sbm.build.impl.RewriteMavenParser; -import org.springframework.sbm.parsers.RewriteExecutionContext; -import org.springframework.sbm.parsers.maven.MavenSettingsInitializer; -import org.springframework.sbm.scopes.ProjectMetadata; import java.util.List; import java.util.Set; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/DependencyChangeHandlerTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/DependencyChangeHandlerTest.java index a6750ce95..3fdc61528 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/DependencyChangeHandlerTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/DependencyChangeHandlerTest.java @@ -17,13 +17,13 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.build.api.BuildFile; import org.springframework.sbm.build.api.Dependency; import org.springframework.sbm.build.impl.OpenRewriteMavenBuildFile; import org.springframework.sbm.build.util.PomBuilder; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.context.ProjectContextHolder; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.parsers.JavaParserBuilder; import org.springframework.sbm.project.resource.TestProjectContext; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/OpenRewriteSearchAndCommentTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/OpenRewriteSearchAndCommentTest.java index 5c4a3b2e0..f5611785a 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/OpenRewriteSearchAndCommentTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/OpenRewriteSearchAndCommentTest.java @@ -15,15 +15,16 @@ */ package org.springframework.sbm.java.impl; +import org.junit.jupiter.api.Test; import org.openrewrite.SourceFile; import org.openrewrite.internal.InMemoryLargeSourceSet; import org.openrewrite.java.JavaParser; +import org.openrewrite.java.search.FindAnnotations; +import org.springframework.rewrite.parsers.RewriteExecutionContext; +import org.springframework.rewrite.parsers.SpringRewriteProperties; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.SbmApplicationProperties; import org.springframework.sbm.project.resource.TestProjectContext; -import org.junit.jupiter.api.Test; -import org.openrewrite.java.search.FindAnnotations; import static org.assertj.core.api.Assertions.assertThat; @@ -54,7 +55,7 @@ public void test2() {} String markerText = "marker text"; - JavaParser javaParser = new RewriteJavaParser(new SbmApplicationProperties(), executionContext); + JavaParser javaParser = new RewriteJavaParser(new SpringRewriteProperties(), executionContext); OpenRewriteRecipeJavaSearch sut = new OpenRewriteRecipeJavaSearch(compilationUnits -> new FindAnnotations("@java.lang.Deprecated", false).run(new InMemoryLargeSourceSet(compilationUnits.stream().map(SourceFile.class::cast).toList()), executionContext).getChangeset().getAllResults(), javaParser, executionContext); diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/RewriteJavaParserTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/RewriteJavaParserTest.java index a5d422c3f..7b754dd04 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/RewriteJavaParserTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/RewriteJavaParserTest.java @@ -19,11 +19,10 @@ import ch.qos.logback.classic.Logger; import org.junit.jupiter.api.Test; import org.openrewrite.ExecutionContext; -import org.openrewrite.InMemoryExecutionContext; import org.openrewrite.java.tree.J; import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.sbm.parsers.RewriteExecutionContext; +import org.springframework.rewrite.parsers.RewriteExecutionContext; +import org.springframework.rewrite.parsers.SpringRewriteProperties; import org.springframework.sbm.project.resource.SbmApplicationProperties; import java.io.ByteArrayOutputStream; @@ -43,10 +42,10 @@ void shouldDelegateParsingErrorsToExceptionHandler() throws ClassNotFoundExcepti ByteArrayOutputStream sysOutBuffer = new ByteArrayOutputStream(); System.setOut(new PrintStream(sysOutBuffer)); - SbmApplicationProperties sbmApplicationProperties = new SbmApplicationProperties(); - sbmApplicationProperties.setJavaParserLoggingCompilationWarningsAndErrors(true); + SpringRewriteProperties springRewriteProperties = new SpringRewriteProperties(); + springRewriteProperties.setLogCompilationWarningsAndErrors(true); ExecutionContext executionContext = new RewriteExecutionContext((t) -> t.printStackTrace()); - RewriteJavaParser rewriteJavaParser = new RewriteJavaParser(sbmApplicationProperties, executionContext); + RewriteJavaParser rewriteJavaParser = new RewriteJavaParser(springRewriteProperties, executionContext); sysOutBuffer.reset(); List parsed = rewriteJavaParser.parse(executionContext, "public class Broken Class {}").map(J.CompilationUnit.class::cast).toList(); diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/SubTypeHierarchyTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/SubTypeHierarchyTest.java index c3e126902..f351eeecf 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/SubTypeHierarchyTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/java/impl/SubTypeHierarchyTest.java @@ -19,7 +19,7 @@ import org.springframework.sbm.java.api.ProjectJavaSources; import org.springframework.sbm.java.api.SubTypeHierarchy; import org.springframework.sbm.java.api.TypeHierarchyNode; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.resource.TestProjectContext; import org.springframework.sbm.support.openrewrite.java.FindCompilationUnitContainingType; import org.junit.jupiter.api.Test; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/java/migration/conditions/HasMemberAnnotationTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/java/migration/conditions/HasMemberAnnotationTest.java index 3ec5232d1..2954f4905 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/java/migration/conditions/HasMemberAnnotationTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/java/migration/conditions/HasMemberAnnotationTest.java @@ -54,6 +54,7 @@ class AnnotatedClass { sut.setAnnotation(annotation); boolean isTypeInUse = sourceFile.getTypesInUse().getTypesInUse().stream() + .filter(JavaType.FullyQualified.class::isInstance) .anyMatch(t -> ((JavaType.FullyQualified)t).getFullyQualifiedName().equals(annotation)); assertThat(isTypeInUse).isTrue(); diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/project/buildfile/AddDependencyTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/project/buildfile/AddDependencyTest.java index 8a012269e..0eb7a4ed4 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/project/buildfile/AddDependencyTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/project/buildfile/AddDependencyTest.java @@ -34,8 +34,10 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationEventPublisher; +import org.springframework.rewrite.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.scopes.ExecutionScope; +import org.springframework.rewrite.scopes.ScanScope; import org.springframework.sbm.SbmCoreConfig; -import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration; import org.springframework.sbm.build.api.BuildFile; import org.springframework.sbm.build.api.Dependency; import org.springframework.sbm.build.impl.RewriteMavenParser; @@ -53,8 +55,6 @@ import org.springframework.sbm.project.resource.ProjectResourceWrapperRegistry; import org.springframework.sbm.project.resource.SbmApplicationProperties; import org.springframework.sbm.project.resource.TestProjectContext; -import org.springframework.sbm.scopes.ExecutionScope; -import org.springframework.sbm.scopes.ScanScope; import org.springframework.sbm.test.TestProjectContextInfo; import org.springframework.test.util.ReflectionTestUtils; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/project/buildfile/OpenRewriteMavenBuildFileTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/project/buildfile/OpenRewriteMavenBuildFileTest.java index 5242a80b4..264db6ed7 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/project/buildfile/OpenRewriteMavenBuildFileTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/project/buildfile/OpenRewriteMavenBuildFileTest.java @@ -15,30 +15,28 @@ */ package org.springframework.sbm.project.buildfile; -import org.jetbrains.annotations.NotNull; import org.intellij.lang.annotations.Language; +import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.*; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import org.openrewrite.ExecutionContext; import org.openrewrite.maven.tree.Scope; import org.springframework.context.ApplicationEventPublisher; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.GitHubIssue; import org.springframework.sbm.build.api.BuildFile; import org.springframework.sbm.build.api.DependenciesChangedEvent; import org.springframework.sbm.build.api.Dependency; import org.springframework.sbm.build.api.Plugin; -import org.springframework.sbm.build.util.PomBuilder; import org.springframework.sbm.build.impl.OpenRewriteMavenPlugin; +import org.springframework.sbm.build.util.PomBuilder; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.context.ProjectContextHolder; import org.springframework.sbm.java.api.Member; import org.springframework.sbm.java.impl.DependenciesChangedEventHandler; import org.springframework.sbm.java.impl.DependencyChangeHandler; -import org.springframework.sbm.java.impl.RewriteJavaParser; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.parsers.JavaParserBuilder; -import org.springframework.sbm.project.resource.SbmApplicationProperties; import org.springframework.sbm.project.resource.TestProjectContext; import java.nio.file.Path; @@ -47,7 +45,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; public class OpenRewriteMavenBuildFileTest { diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/project/openrewrite/RewriteSourceFileHolderTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/project/openrewrite/RewriteSourceFileHolderTest.java index d01b0f444..a009e654f 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/project/openrewrite/RewriteSourceFileHolderTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/project/openrewrite/RewriteSourceFileHolderTest.java @@ -16,7 +16,7 @@ package org.springframework.sbm.project.openrewrite; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.resource.TestProjectContext; import org.junit.jupiter.api.Test; import org.openrewrite.java.tree.J; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ForgivingParsingOfTestResourcesTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ForgivingParsingOfTestResourcesTest.java index ce66e42df..d57b4567a 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ForgivingParsingOfTestResourcesTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ForgivingParsingOfTestResourcesTest.java @@ -23,7 +23,7 @@ import org.openrewrite.tree.ParsingEventListener; import org.openrewrite.tree.ParsingExecutionContextView; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.resource.TestProjectContext; import org.springframework.sbm.test.TestProjectContextInfo; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/JavaProvenanceMarkerFactoryTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/JavaProvenanceMarkerFactoryTest.java index a3d94d4d5..c3a35ad41 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/JavaProvenanceMarkerFactoryTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/JavaProvenanceMarkerFactoryTest.java @@ -23,10 +23,10 @@ import org.openrewrite.marker.BuildTool; import org.openrewrite.marker.Marker; import org.openrewrite.xml.tree.Xml; +import org.springframework.rewrite.parsers.RewriteExecutionContext; +import org.springframework.rewrite.parsers.maven.MavenSettingsInitializer; +import org.springframework.rewrite.scopes.ProjectMetadata; import org.springframework.sbm.build.impl.RewriteMavenParser; -import org.springframework.sbm.parsers.RewriteExecutionContext; -import org.springframework.sbm.parsers.maven.MavenSettingsInitializer; -import org.springframework.sbm.scopes.ProjectMetadata; import java.nio.file.Path; import java.util.List; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ProjectContextInitializerTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ProjectContextInitializerTest.java index ce8475af8..50eb4e31d 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ProjectContextInitializerTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ProjectContextInitializerTest.java @@ -33,8 +33,14 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; -import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration; -import org.springframework.sbm.parsers.maven.MavenSettingsInitializer; +import org.springframework.rewrite.parsers.RewriteProjectParser; +import org.springframework.rewrite.parsers.maven.MavenSettingsInitializer; +import org.springframework.rewrite.parsers.maven.RewriteMavenArtifactDownloader; +import org.springframework.rewrite.project.RewriteSourceFileWrapper; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.scopes.ExecutionScope; +import org.springframework.rewrite.scopes.ScanScope; import org.springframework.sbm.build.impl.RewriteMavenParser; import org.springframework.sbm.build.migration.MavenPomCacheProvider; import org.springframework.sbm.engine.commands.ScanCommand; @@ -47,12 +53,11 @@ import org.springframework.sbm.java.impl.RewriteJavaParser; import org.springframework.sbm.java.refactoring.JavaRefactoringFactoryImpl; import org.springframework.sbm.java.util.BasePackageCalculator; -import org.springframework.sbm.parsers.RewriteProjectParser; -import org.springframework.sbm.project.RewriteSourceFileWrapper; -import org.springframework.sbm.project.resource.*; +import org.springframework.sbm.project.resource.ProjectResourceSetHolder; +import org.springframework.sbm.project.resource.ProjectResourceWrapperRegistry; +import org.springframework.sbm.project.resource.ResourceHelper; +import org.springframework.sbm.project.resource.SbmApplicationProperties; import org.springframework.sbm.properties.parser.RewritePropertiesParser; -import org.springframework.sbm.scopes.ExecutionScope; -import org.springframework.sbm.scopes.ScanScope; import org.springframework.sbm.xml.parser.RewriteXmlParser; import org.springframework.util.FileSystemUtils; @@ -64,7 +69,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.sbm.project.parser.ResourceVerifierTestHelper.*; -import org.springframework.sbm.parsers.maven.RewriteMavenArtifactDownloader; @SpringBootTest(classes = { ProjectContextInitializer.class, diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ResourceParserTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ResourceParserTest.java index 1298a2555..eb6646739 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ResourceParserTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ResourceParserTest.java @@ -26,11 +26,12 @@ import org.openrewrite.SourceFile; import org.openrewrite.text.PlainText; import org.openrewrite.text.PlainTextParser; +import org.openrewrite.tree.ParsingEventListener; import org.openrewrite.tree.ParsingExecutionContextView; import org.springframework.context.ApplicationEventPublisher; import org.springframework.core.io.Resource; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.engine.events.StartedScanningProjectResourceEvent; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.TestDummyResource; import org.springframework.sbm.properties.parser.RewritePropertiesParser; import org.springframework.sbm.xml.parser.RewriteXmlParser; @@ -96,11 +97,14 @@ void originalPlainTextParserSholdPublishParserEvents() throws InterruptedExcepti ExecutionContext ctx = new RewriteExecutionContext(); AtomicReference parsedInput = new AtomicReference<>(); AtomicReference parsedSourceFile = new AtomicReference<>(); - ParsingExecutionContextView.view(ctx).setParsingListener((Parser.Input input, SourceFile sourceFile) -> { - parsedInput.set(input); - parsedSourceFile.set(sourceFile); - latch.countDown(); - } ); + ParsingExecutionContextView.view(ctx).setParsingListener(new ParsingEventListener() { + @Override + public void parsed(Parser.Input input, SourceFile sourceFile) { + parsedInput.set(input); + parsedSourceFile.set(sourceFile); + latch.countDown(); + } + }); List resources = getResourceAsList("some-file-parsed-by-plaintext.txt", "content"); PlainTextParser sut = new PlainTextParser(); diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ResourceVerifierTestHelper.java b/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ResourceVerifierTestHelper.java index 2b6430a97..79672ac2a 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ResourceVerifierTestHelper.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/ResourceVerifierTestHelper.java @@ -25,7 +25,7 @@ import org.openrewrite.maven.tree.MavenResolutionResult; import org.openrewrite.maven.tree.Scope; import org.openrewrite.xml.tree.Xml; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import java.nio.file.Path; import java.util.Arrays; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/RewriteXmlParserTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/RewriteXmlParserTest.java index dfd07946c..b9ef359aa 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/RewriteXmlParserTest.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/project/parser/RewriteXmlParserTest.java @@ -18,9 +18,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.openrewrite.xml.tree.Xml; -import org.springframework.sbm.parsers.RewriteExecutionContext; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.project.TestDummyResource; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.xml.parser.RewriteXmlParser; import java.nio.file.Path; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/project/resource/TestProjectContext.java b/components/sbm-core/src/test/java/org/springframework/sbm/project/resource/TestProjectContext.java index 52b130190..7705369af 100644 --- a/components/sbm-core/src/test/java/org/springframework/sbm/project/resource/TestProjectContext.java +++ b/components/sbm-core/src/test/java/org/springframework/sbm/project/resource/TestProjectContext.java @@ -27,6 +27,9 @@ import org.springframework.core.annotation.Order; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.Resource; +import org.springframework.rewrite.project.resource.ProjectResourceSerializer; +import org.springframework.rewrite.project.resource.ProjectResourceSetSerializer; +import org.springframework.rewrite.utils.ResourceUtil; import org.springframework.sbm.build.impl.OpenRewriteMavenBuildFile; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.context.ProjectContextSerializer; @@ -37,7 +40,6 @@ import org.springframework.sbm.project.parser.ProjectContextInitializer; import org.springframework.sbm.test.SpringBeanProvider; import org.springframework.sbm.test.TestProjectContextInfo; -import org.springframework.sbm.utils.ResourceUtil; import org.springframework.validation.beanvalidation.CustomValidatorBean; import java.io.ByteArrayInputStream; diff --git a/components/sbm-openrewrite/pom.xml b/components/sbm-openrewrite/pom.xml index f7107386b..0c5935724 100644 --- a/components/sbm-openrewrite/pom.xml +++ b/components/sbm-openrewrite/pom.xml @@ -33,8 +33,8 @@ spring-context - org.springframework.experimental - sbm-support-rewrite + org.springframework.rewrite + spring-rewrite-commons-launcher 0.1.0-SNAPSHOT diff --git a/components/sbm-openrewrite/src/test/java/org/openrewrite/maven/MavenParserTest.java b/components/sbm-openrewrite/src/test/java/org/openrewrite/maven/MavenParserTest.java index ecb02988c..7bee85c36 100644 --- a/components/sbm-openrewrite/src/test/java/org/openrewrite/maven/MavenParserTest.java +++ b/components/sbm-openrewrite/src/test/java/org/openrewrite/maven/MavenParserTest.java @@ -18,14 +18,14 @@ import org.intellij.lang.annotations.Language; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import org.openrewrite.*; -import org.openrewrite.internal.InMemoryLargeSourceSet; +import org.openrewrite.ExecutionContext; +import org.openrewrite.InMemoryExecutionContext; +import org.openrewrite.Parser; +import org.openrewrite.SourceFile; import org.openrewrite.maven.cache.InMemoryMavenPomCache; import org.openrewrite.maven.tree.*; -import org.openrewrite.tree.ParseError; import org.springframework.sbm.GitHubIssue; import org.springframework.sbm.Problem; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; @@ -35,7 +35,8 @@ import java.util.Optional; import java.util.stream.Stream; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * @author Fabian Krüger diff --git a/components/sbm-openrewrite/src/test/java/org/springframework/sbm/openrewrite/MavenRefactoringTestHelper.java b/components/sbm-openrewrite/src/test/java/org/springframework/sbm/openrewrite/MavenRefactoringTestHelper.java index 3fd828d03..1e91b2004 100644 --- a/components/sbm-openrewrite/src/test/java/org/springframework/sbm/openrewrite/MavenRefactoringTestHelper.java +++ b/components/sbm-openrewrite/src/test/java/org/springframework/sbm/openrewrite/MavenRefactoringTestHelper.java @@ -19,10 +19,8 @@ import org.openrewrite.internal.InMemoryLargeSourceSet; import org.openrewrite.maven.MavenParser; import org.openrewrite.maven.MavenVisitor; -import org.openrewrite.xml.tree.Xml; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; +import org.springframework.rewrite.support.openrewrite.GenericOpenRewriteRecipe; -import java.util.List; import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; diff --git a/components/sbm-openrewrite/src/test/java/org/springframework/sbm/support/openrewrite/api/RemoveImportTest.java b/components/sbm-openrewrite/src/test/java/org/springframework/sbm/support/openrewrite/api/RemoveImportTest.java index 2cf84dfb0..d33cbdbb3 100644 --- a/components/sbm-openrewrite/src/test/java/org/springframework/sbm/support/openrewrite/api/RemoveImportTest.java +++ b/components/sbm-openrewrite/src/test/java/org/springframework/sbm/support/openrewrite/api/RemoveImportTest.java @@ -15,14 +15,14 @@ */ package org.springframework.sbm.support.openrewrite.api; +import org.junit.jupiter.api.Test; import org.openrewrite.InMemoryExecutionContext; import org.openrewrite.RecipeRun; import org.openrewrite.internal.InMemoryLargeSourceSet; +import org.openrewrite.java.tree.J; +import org.springframework.rewrite.support.openrewrite.GenericOpenRewriteRecipe; import org.springframework.sbm.java.OpenRewriteTestSupport; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; import org.springframework.sbm.support.openrewrite.java.RemoveAnnotationVisitor; -import org.junit.jupiter.api.Test; -import org.openrewrite.java.tree.J; import java.util.List; diff --git a/components/sbm-openrewrite/src/test/java/org/springframework/sbm/support/openrewrite/java/AddAnnotationVisitorTest.java b/components/sbm-openrewrite/src/test/java/org/springframework/sbm/support/openrewrite/java/AddAnnotationVisitorTest.java index 5e4c45d78..c8150ff3e 100644 --- a/components/sbm-openrewrite/src/test/java/org/springframework/sbm/support/openrewrite/java/AddAnnotationVisitorTest.java +++ b/components/sbm-openrewrite/src/test/java/org/springframework/sbm/support/openrewrite/java/AddAnnotationVisitorTest.java @@ -20,8 +20,8 @@ import org.openrewrite.RecipeRun; import org.openrewrite.internal.InMemoryLargeSourceSet; import org.openrewrite.java.tree.J; +import org.springframework.rewrite.support.openrewrite.GenericOpenRewriteRecipe; import org.springframework.sbm.java.OpenRewriteTestSupport; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; import java.util.List; diff --git a/components/sbm-openrewrite/src/test/java/org/springframework/sbm/support/openrewrite/java/RemoveAnnotationVisitorTest.java b/components/sbm-openrewrite/src/test/java/org/springframework/sbm/support/openrewrite/java/RemoveAnnotationVisitorTest.java index 926b45eae..52b959c21 100644 --- a/components/sbm-openrewrite/src/test/java/org/springframework/sbm/support/openrewrite/java/RemoveAnnotationVisitorTest.java +++ b/components/sbm-openrewrite/src/test/java/org/springframework/sbm/support/openrewrite/java/RemoveAnnotationVisitorTest.java @@ -15,16 +15,16 @@ */ package org.springframework.sbm.support.openrewrite.java; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; import org.openrewrite.InMemoryExecutionContext; import org.openrewrite.RecipeRun; import org.openrewrite.Result; import org.openrewrite.internal.InMemoryLargeSourceSet; -import org.springframework.sbm.java.OpenRewriteTestSupport; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; import org.openrewrite.java.tree.J; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; +import org.springframework.rewrite.support.openrewrite.GenericOpenRewriteRecipe; +import org.springframework.sbm.java.OpenRewriteTestSupport; import java.util.List; import java.util.stream.Collectors; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade/common/actions/CreateAutoconfigurationAction.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade/common/actions/CreateAutoconfigurationAction.java index 0c758de6e..e95f84cf3 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade/common/actions/CreateAutoconfigurationAction.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade/common/actions/CreateAutoconfigurationAction.java @@ -20,11 +20,11 @@ import org.apache.commons.lang3.tuple.Pair; import org.openrewrite.ExecutionContext; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.rewrite.project.resource.ProjectResource; +import org.springframework.rewrite.project.resource.finder.PathPatternMatchingProjectResourceFinder; import org.springframework.sbm.build.api.Module; -import org.springframework.sbm.project.resource.finder.PathPatternMatchingProjectResourceFinder; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.recipe.AbstractAction; -import org.springframework.sbm.project.resource.ProjectResource; import org.springframework.sbm.project.resource.StringProjectResource; import java.io.ByteArrayInputStream; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade/common/conditions/BootHasAutoconfigurationCondition.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade/common/conditions/BootHasAutoconfigurationCondition.java index 61141e028..ea025d9e8 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade/common/conditions/BootHasAutoconfigurationCondition.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade/common/conditions/BootHasAutoconfigurationCondition.java @@ -15,7 +15,7 @@ */ package org.springframework.sbm.boot.upgrade.common.conditions; -import org.springframework.sbm.project.resource.finder.PathPatternMatchingProjectResourceFinder; +import org.springframework.rewrite.project.resource.finder.PathPatternMatchingProjectResourceFinder; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.recipe.Condition; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_24_25/actions/Boot_24_25_CreateDatasourceInitializerAction.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_24_25/actions/Boot_24_25_CreateDatasourceInitializerAction.java index d9bff5de2..112c379b7 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_24_25/actions/Boot_24_25_CreateDatasourceInitializerAction.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_24_25/actions/Boot_24_25_CreateDatasourceInitializerAction.java @@ -19,6 +19,7 @@ import freemarker.template.Configuration; import freemarker.template.Template; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.rewrite.project.resource.ProjectResource; import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; import org.springframework.sbm.boot.properties.search.SpringBootApplicationPropertiesResourceListFinder; import org.springframework.sbm.boot.upgrade_24_25.filter.CreateDatasourceInitializerAnalyzer; @@ -26,7 +27,6 @@ import org.springframework.sbm.build.api.Module; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.recipe.AbstractAction; -import org.springframework.sbm.project.resource.ProjectResource; import java.io.StringWriter; import java.util.HashMap; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_24_25/filter/CreateDatasourceInitializerAnalyzer.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_24_25/filter/CreateDatasourceInitializerAnalyzer.java index 9412c73c5..1a2879134 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_24_25/filter/CreateDatasourceInitializerAnalyzer.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_24_25/filter/CreateDatasourceInitializerAnalyzer.java @@ -15,11 +15,11 @@ */ package org.springframework.sbm.boot.upgrade_24_25.filter; +import org.springframework.rewrite.project.resource.ProjectResource; +import org.springframework.rewrite.project.resource.finder.PathPatternMatchingProjectResourceFinder; +import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; import org.springframework.sbm.boot.properties.search.SpringBootApplicationPropertiesResourceListFinder; import org.springframework.sbm.build.api.Module; -import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; -import org.springframework.sbm.project.resource.ProjectResource; -import org.springframework.sbm.project.resource.finder.PathPatternMatchingProjectResourceFinder; import java.util.List; import java.util.stream.Collectors; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_24_25/report/Boot_24_25_SchemaSqlAndDataSqlFiles.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_24_25/report/Boot_24_25_SchemaSqlAndDataSqlFiles.java index 8fbad3ecc..3038f3911 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_24_25/report/Boot_24_25_SchemaSqlAndDataSqlFiles.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_24_25/report/Boot_24_25_SchemaSqlAndDataSqlFiles.java @@ -16,13 +16,13 @@ package org.springframework.sbm.boot.upgrade_24_25.report; import org.springframework.core.annotation.Order; +import org.springframework.rewrite.project.resource.ProjectResource; +import org.springframework.rewrite.project.resource.finder.PathPatternMatchingProjectResourceFinder; import org.springframework.sbm.boot.UpgradeSectionBuilder; import org.springframework.sbm.boot.asciidoctor.ChangeSection; import org.springframework.sbm.boot.asciidoctor.Section; import org.springframework.sbm.boot.asciidoctor.TodoList; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.ProjectResource; -import org.springframework.sbm.project.resource.finder.PathPatternMatchingProjectResourceFinder; import org.springframework.stereotype.Component; import java.nio.file.Path; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/checks/ApacheSolrRepositoryBeanFinder.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/checks/ApacheSolrRepositoryBeanFinder.java index 64ec4c0d5..85f1367e9 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/checks/ApacheSolrRepositoryBeanFinder.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/checks/ApacheSolrRepositoryBeanFinder.java @@ -15,10 +15,10 @@ */ package org.springframework.sbm.boot.upgrade_27_30.checks; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.java.api.JavaSourceAndType; import org.springframework.sbm.java.impl.OpenRewriteJavaSource; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; import org.springframework.stereotype.Component; import java.util.List; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/checks/SecurityManagerUsagesSectionBuilder.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/checks/SecurityManagerUsagesSectionBuilder.java index 073b9e026..111bd67a7 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/checks/SecurityManagerUsagesSectionBuilder.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/checks/SecurityManagerUsagesSectionBuilder.java @@ -22,7 +22,7 @@ import org.springframework.sbm.boot.upgrade_27_30.Sbu30_UpgradeSectionBuilder; import org.springframework.sbm.boot.upgrade_27_30.openrewrite.SecurityManagerUsagesFinder; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.stereotype.Component; import java.util.List; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/filter/JmxEndpointExposureFinder.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/filter/JmxEndpointExposureFinder.java index e70f7667f..740790bde 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/filter/JmxEndpointExposureFinder.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/filter/JmxEndpointExposureFinder.java @@ -15,10 +15,10 @@ */ package org.springframework.sbm.boot.upgrade_27_30.filter; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; import org.springframework.sbm.boot.properties.search.SpringBootApplicationPropertiesResourceListFinder; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.properties.api.PropertiesSource; import java.util.List; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/filter/LoggingDateFormatPropertyFinder.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/filter/LoggingDateFormatPropertyFinder.java index ed87df383..f10c92e66 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/filter/LoggingDateFormatPropertyFinder.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/filter/LoggingDateFormatPropertyFinder.java @@ -16,10 +16,10 @@ package org.springframework.sbm.boot.upgrade_27_30.filter; import lombok.extern.slf4j.Slf4j; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; import org.springframework.sbm.boot.properties.search.SpringBootApplicationPropertiesResourceListFinder; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.properties.api.PropertiesSource; import java.util.List; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ActuatorEndpointsSanitizationHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ActuatorEndpointsSanitizationHelper.java index da157b703..1aa119971 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ActuatorEndpointsSanitizationHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ActuatorEndpointsSanitizationHelper.java @@ -14,13 +14,13 @@ * limitations under the License. */ package org.springframework.sbm.boot.upgrade_27_30.report.helper; + +import org.springframework.rewrite.project.resource.ProjectResource; import org.springframework.sbm.boot.common.conditions.IsSpringBootProject; -import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.build.api.BuildFile; import org.springframework.sbm.build.api.Module; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.ProjectResource; import java.util.Comparator; import java.util.List; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportHelper.java index 83effb0fd..2c8cdb6f7 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportHelper.java @@ -19,7 +19,7 @@ import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import java.nio.file.Path; import java.util.List; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConstructorBindingHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConstructorBindingHelper.java index af642c2df..1dfc7fb03 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConstructorBindingHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConstructorBindingHelper.java @@ -19,11 +19,11 @@ import org.openrewrite.TreeVisitor; import org.openrewrite.java.search.UsesType; import org.openrewrite.java.tree.J; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.support.openrewrite.GenericOpenRewriteRecipe; import org.springframework.sbm.boot.common.conditions.IsSpringBootProject; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; import java.util.List; import java.util.Map; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/PagingAndSortingHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/PagingAndSortingHelper.java index 0902ebac0..c5a849c61 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/PagingAndSortingHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/PagingAndSortingHelper.java @@ -20,11 +20,11 @@ import org.openrewrite.java.JavaIsoVisitor; import org.openrewrite.java.tree.J; import org.openrewrite.marker.SearchResult; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.support.openrewrite.GenericOpenRewriteRecipe; import org.springframework.sbm.boot.common.conditions.IsSpringBootProject; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; import java.util.HashMap; import java.util.List; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringFactoriesHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringFactoriesHelper.java index 54ad6cf6d..367464e71 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringFactoriesHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringFactoriesHelper.java @@ -15,10 +15,10 @@ */ package org.springframework.sbm.boot.upgrade_27_30.report.helper; +import org.springframework.rewrite.project.resource.ProjectResource; +import org.springframework.rewrite.project.resource.finder.PathPatternMatchingProjectResourceFinder; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; -import org.springframework.sbm.project.resource.finder.PathPatternMatchingProjectResourceFinder; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.ProjectResource; import java.io.ByteArrayInputStream; import java.io.IOException; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringMVCAndWebFluxUrlMatchingChangesHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringMVCAndWebFluxUrlMatchingChangesHelper.java index 1f1c2988a..5e214d62d 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringMVCAndWebFluxUrlMatchingChangesHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringMVCAndWebFluxUrlMatchingChangesHelper.java @@ -17,13 +17,13 @@ import org.openrewrite.ExecutionContext; import org.openrewrite.java.search.UsesType; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.support.openrewrite.GenericOpenRewriteRecipe; import org.springframework.sbm.boot.common.conditions.IsSpringBootProject; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.java.api.JavaSource; import org.springframework.sbm.java.impl.OpenRewriteJavaSource; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; import java.util.*; import java.util.stream.Collectors; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java index 70e08f74f..a2ba1c017 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java @@ -23,8 +23,8 @@ import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.lang.ArchRule; import org.openrewrite.ExecutionContext; -import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration; -import org.springframework.sbm.parsers.RewriteExecutionContext; +import org.springframework.rewrite.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade/common/actions/CreateAutoconfigurationActionTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade/common/actions/CreateAutoconfigurationActionTest.java index 1cbe2456b..71152fe61 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade/common/actions/CreateAutoconfigurationActionTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade/common/actions/CreateAutoconfigurationActionTest.java @@ -18,9 +18,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.sbm.project.resource.finder.PathPatternMatchingProjectResourceFinder; +import org.springframework.rewrite.project.resource.ProjectResource; +import org.springframework.rewrite.project.resource.finder.PathPatternMatchingProjectResourceFinder; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.ProjectResource; import org.springframework.sbm.project.resource.TestProjectContext; import java.util.List; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_24_25/actions/Boot_24_25_SqlScriptDataSourceInitializationActionTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_24_25/actions/Boot_24_25_SqlScriptDataSourceInitializationActionTest.java index 785a42d36..01577daf5 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_24_25/actions/Boot_24_25_SqlScriptDataSourceInitializationActionTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_24_25/actions/Boot_24_25_SqlScriptDataSourceInitializationActionTest.java @@ -15,14 +15,14 @@ */ package org.springframework.sbm.boot.upgrade_24_25.actions; +import org.junit.jupiter.api.Test; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher; +import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; +import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; import org.springframework.sbm.boot.properties.search.SpringBootApplicationPropertiesResourceListFinder; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; -import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.TestProjectContext; -import org.junit.jupiter.api.Test; import java.nio.file.Path; import java.util.List; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_24_25/report/Boot_24_25_SqlScriptDataSourceInitializationTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_24_25/report/Boot_24_25_SqlScriptDataSourceInitializationTest.java index 93ab084e9..e46e5af39 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_24_25/report/Boot_24_25_SqlScriptDataSourceInitializationTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_24_25/report/Boot_24_25_SqlScriptDataSourceInitializationTest.java @@ -15,10 +15,10 @@ */ package org.springframework.sbm.boot.upgrade_24_25.report; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.TestProjectContext; import org.junit.jupiter.api.Test; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/actions/Boot_27_30_AddLoggingDateFormatTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/actions/Boot_27_30_AddLoggingDateFormatTest.java index 796520130..365edce8b 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/actions/Boot_27_30_AddLoggingDateFormatTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/actions/Boot_27_30_AddLoggingDateFormatTest.java @@ -16,12 +16,12 @@ package org.springframework.sbm.boot.upgrade_27_30.actions; import org.junit.jupiter.api.Test; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher; import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; import org.springframework.sbm.boot.properties.search.SpringBootApplicationPropertiesResourceListFinder; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.TestProjectContext; import java.util.List; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/actions/Boot_27_30_JmxEndpointExposureActionTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/actions/Boot_27_30_JmxEndpointExposureActionTest.java index 5f7820e94..e28998fb5 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/actions/Boot_27_30_JmxEndpointExposureActionTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/actions/Boot_27_30_JmxEndpointExposureActionTest.java @@ -16,12 +16,12 @@ package org.springframework.sbm.boot.upgrade_27_30.actions; import org.junit.jupiter.api.Test; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher; import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; import org.springframework.sbm.boot.properties.search.SpringBootApplicationPropertiesResourceListFinder; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.TestProjectContext; import java.util.List; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/conditions/JmxEndpointExposureConditionTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/conditions/JmxEndpointExposureConditionTest.java index fff8e532d..0318a8758 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/conditions/JmxEndpointExposureConditionTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/conditions/JmxEndpointExposureConditionTest.java @@ -16,10 +16,10 @@ package org.springframework.sbm.boot.upgrade_27_30.conditions; import org.junit.jupiter.api.Test; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher; import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.TestProjectContext; import java.nio.file.Path; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/conditions/LoggingDateFormatConditionTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/conditions/LoggingDateFormatConditionTest.java index b177d0530..25bb08d05 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/conditions/LoggingDateFormatConditionTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/conditions/LoggingDateFormatConditionTest.java @@ -16,10 +16,10 @@ package org.springframework.sbm.boot.upgrade_27_30.conditions; import org.junit.jupiter.api.Test; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher; import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.TestProjectContext; import java.nio.file.Path; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/filter/JmxEndpointExposureFinderTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/filter/JmxEndpointExposureFinderTest.java index 184200f8b..0374fe4c7 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/filter/JmxEndpointExposureFinderTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/filter/JmxEndpointExposureFinderTest.java @@ -16,10 +16,10 @@ package org.springframework.sbm.boot.upgrade_27_30.filter; import org.junit.jupiter.api.Test; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher; import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.TestProjectContext; import org.springframework.sbm.properties.api.PropertiesSource; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/filter/LoggingDateFormatPropertyFinderTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/filter/LoggingDateFormatPropertyFinderTest.java index 72a32a249..3e87e653a 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/filter/LoggingDateFormatPropertyFinderTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/filter/LoggingDateFormatPropertyFinderTest.java @@ -16,10 +16,10 @@ package org.springframework.sbm.boot.upgrade_27_30.filter; import org.junit.jupiter.api.Test; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher; import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.TestProjectContext; import org.springframework.sbm.properties.api.PropertiesSource; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/openrewrite/SecurityManagerUsagesFinderTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/openrewrite/SecurityManagerUsagesFinderTest.java index b3727b2df..440419d70 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/openrewrite/SecurityManagerUsagesFinderTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/openrewrite/SecurityManagerUsagesFinderTest.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; import org.openrewrite.java.tree.J; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.resource.TestProjectContext; import java.util.List; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportActionTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportActionTest.java index f4b50e72d..64c90b7e8 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportActionTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportActionTest.java @@ -21,10 +21,10 @@ import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher; import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.TestProjectContext; import org.springframework.sbm.test.RecipeIntegrationTestSupport; import org.w3c.dom.NodeList; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesReportSectionTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesReportSectionTest.java index 5d2cc2311..12ab28df9 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesReportSectionTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesReportSectionTest.java @@ -17,11 +17,11 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher; import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportTestSupport; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.TestProjectContext; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatHelperTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatHelperTest.java index 5153afc92..4fd7e0257 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatHelperTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatHelperTest.java @@ -16,10 +16,10 @@ package org.springframework.sbm.boot.upgrade_27_30.report.helper; import org.junit.jupiter.api.Test; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher; import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.TestProjectContext; import org.springframework.sbm.properties.api.PropertiesSource; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatReportSectionTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatReportSectionTest.java index d8b0577dc..0655cbcd6 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatReportSectionTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatReportSectionTest.java @@ -16,11 +16,11 @@ package org.springframework.sbm.boot.upgrade_27_30.report.helper; import org.junit.jupiter.api.Test; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher; import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportTestSupport; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.TestProjectContext; /** diff --git a/components/sbm-recipes-jee-to-boot/src/main/java/org/springframework/sbm/jee/ejb/actions/MigrateJndiLookup.java b/components/sbm-recipes-jee-to-boot/src/main/java/org/springframework/sbm/jee/ejb/actions/MigrateJndiLookup.java index bda37d7c3..de83366de 100644 --- a/components/sbm-recipes-jee-to-boot/src/main/java/org/springframework/sbm/jee/ejb/actions/MigrateJndiLookup.java +++ b/components/sbm-recipes-jee-to-boot/src/main/java/org/springframework/sbm/jee/ejb/actions/MigrateJndiLookup.java @@ -15,22 +15,20 @@ */ package org.springframework.sbm.jee.ejb.actions; -import org.openrewrite.staticanalysis.RemoveUnusedLocalVariables; -import org.springframework.sbm.engine.recipe.AbstractAction; -import org.springframework.sbm.java.api.JavaSource; -import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; import lombok.Getter; import lombok.RequiredArgsConstructor; import org.openrewrite.ExecutionContext; -import org.openrewrite.Recipe; import org.openrewrite.java.AddImport; import org.openrewrite.java.JavaIsoVisitor; import org.openrewrite.java.JavaTemplate; import org.openrewrite.java.RemoveUnusedImports; -import org.openrewrite.staticanalysis.RemoveUnusedLocalVariables; import org.openrewrite.java.format.AutoFormat; import org.openrewrite.java.tree.*; +import org.openrewrite.staticanalysis.RemoveUnusedLocalVariables; +import org.springframework.rewrite.support.openrewrite.GenericOpenRewriteRecipe; +import org.springframework.sbm.engine.context.ProjectContext; +import org.springframework.sbm.engine.recipe.AbstractAction; +import org.springframework.sbm.java.api.JavaSource; import java.util.ArrayList; import java.util.Iterator; diff --git a/components/sbm-recipes-jee-to-boot/src/main/java/org/springframework/sbm/jee/tx/actions/MigrateJeeTransactionsToSpringBootAction.java b/components/sbm-recipes-jee-to-boot/src/main/java/org/springframework/sbm/jee/tx/actions/MigrateJeeTransactionsToSpringBootAction.java index fd7a7c470..109463166 100644 --- a/components/sbm-recipes-jee-to-boot/src/main/java/org/springframework/sbm/jee/tx/actions/MigrateJeeTransactionsToSpringBootAction.java +++ b/components/sbm-recipes-jee-to-boot/src/main/java/org/springframework/sbm/jee/tx/actions/MigrateJeeTransactionsToSpringBootAction.java @@ -21,7 +21,7 @@ import org.springframework.sbm.java.api.Method; import org.springframework.sbm.java.api.Type; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.jetbrains.annotations.NotNull; import org.openrewrite.java.tree.J; diff --git a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java index 70e08f74f..a2ba1c017 100644 --- a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java +++ b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java @@ -23,8 +23,8 @@ import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.lang.ArchRule; import org.openrewrite.ExecutionContext; -import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration; -import org.springframework.sbm.parsers.RewriteExecutionContext; +import org.springframework.rewrite.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; diff --git a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/ejb/actions/MigrateEjbDeploymentDescriptorTest.java b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/ejb/actions/MigrateEjbDeploymentDescriptorTest.java index 7c310bae3..4560f1938 100644 --- a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/ejb/actions/MigrateEjbDeploymentDescriptorTest.java +++ b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/ejb/actions/MigrateEjbDeploymentDescriptorTest.java @@ -15,12 +15,12 @@ */ package org.springframework.sbm.jee.ejb.actions; +import org.junit.jupiter.api.Test; +import org.springframework.rewrite.project.resource.finder.GenericTypeListFinder; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.jee.ejb.api.EjbJarXml; import org.springframework.sbm.jee.ejb.resource.JeeEjbJarXmlProjectResourceRegistrar; import org.springframework.sbm.project.resource.TestProjectContext; -import org.springframework.sbm.project.resource.finder.GenericTypeListFinder; -import org.junit.jupiter.api.Test; import java.nio.file.Path; import java.util.List; diff --git a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ReplaceMediaTypeTest.java b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ReplaceMediaTypeTest.java index 6be8fa831..c584cbda9 100644 --- a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ReplaceMediaTypeTest.java +++ b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ReplaceMediaTypeTest.java @@ -15,18 +15,12 @@ */ package org.springframework.sbm.jee.jaxrs.recipes; -import org.openrewrite.java.JavaParser; +import org.junit.jupiter.api.Test; +import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.recipe.AbstractAction; import org.springframework.sbm.java.api.JavaSource; -import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.java.impl.RewriteJavaParser; -import org.springframework.sbm.parsers.RewriteExecutionContext; -import org.springframework.sbm.project.resource.SbmApplicationProperties; import org.springframework.sbm.project.resource.TestProjectContext; import org.springframework.sbm.testhelper.common.utils.TestDiff; -import org.junit.jupiter.api.Test; - -import java.util.function.Supplier; import static org.assertj.core.api.Assertions.assertThat; diff --git a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ResponseBuilderTest.java b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ResponseBuilderTest.java index 482372eb5..87de358b4 100644 --- a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ResponseBuilderTest.java +++ b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ResponseBuilderTest.java @@ -15,18 +15,17 @@ */ package org.springframework.sbm.jee.jaxrs.recipes; +import org.junit.jupiter.api.Test; import org.openrewrite.SourceFile; -import org.openrewrite.java.tree.J; -import org.springframework.sbm.engine.recipe.AbstractAction; +import org.springframework.rewrite.parsers.RewriteExecutionContext; +import org.springframework.rewrite.parsers.SpringRewriteProperties; import org.springframework.sbm.engine.context.ProjectContext; +import org.springframework.sbm.engine.recipe.AbstractAction; import org.springframework.sbm.java.impl.RewriteJavaParser; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.SbmApplicationProperties; import org.springframework.sbm.project.resource.TestProjectContext; import org.springframework.sbm.testhelper.common.utils.TestDiff; -import org.junit.jupiter.api.Test; -import java.util.List; import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; @@ -377,7 +376,7 @@ void type() { String actual = projectContext.getProjectJavaSources().list().get(0).print(); // verify it compiles - Stream parse = new RewriteJavaParser(new SbmApplicationProperties(), + Stream parse = new RewriteJavaParser(new SpringRewriteProperties(), new RewriteExecutionContext()).parse(actual); assertThat(actual) diff --git a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ResponseEntityReplacementTest.java b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ResponseEntityReplacementTest.java index 74b430101..46a76181f 100644 --- a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ResponseEntityReplacementTest.java +++ b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ResponseEntityReplacementTest.java @@ -15,18 +15,11 @@ */ package org.springframework.sbm.jee.jaxrs.recipes; -import org.openrewrite.java.JavaParser; -import org.springframework.sbm.engine.recipe.AbstractAction; +import org.junit.jupiter.api.Test; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.java.impl.RewriteJavaParser; -import org.springframework.sbm.parsers.RewriteExecutionContext; -import org.springframework.sbm.project.resource.SbmApplicationProperties; +import org.springframework.sbm.engine.recipe.AbstractAction; import org.springframework.sbm.project.resource.TestProjectContext; import org.springframework.sbm.testhelper.common.utils.TestDiff; -import org.junit.jupiter.api.Test; -import org.openrewrite.Recipe; - -import java.util.function.Supplier; import static org.assertj.core.api.Assertions.assertThat; diff --git a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ResponseStatusTest.java b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ResponseStatusTest.java index a195c80a0..df94b89c7 100644 --- a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ResponseStatusTest.java +++ b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxrs/recipes/ResponseStatusTest.java @@ -15,14 +15,11 @@ */ package org.springframework.sbm.jee.jaxrs.recipes; -import org.springframework.sbm.engine.recipe.AbstractAction; +import org.junit.jupiter.api.Test; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.java.impl.RewriteJavaParser; -import org.springframework.sbm.parsers.RewriteExecutionContext; -import org.springframework.sbm.project.resource.SbmApplicationProperties; +import org.springframework.sbm.engine.recipe.AbstractAction; import org.springframework.sbm.project.resource.TestProjectContext; import org.springframework.sbm.testhelper.common.utils.TestDiff; -import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxws/GenerateWebServicesTest.java b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxws/GenerateWebServicesTest.java index 7da6e7d0b..d2609e2eb 100644 --- a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxws/GenerateWebServicesTest.java +++ b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxws/GenerateWebServicesTest.java @@ -17,7 +17,7 @@ import org.springframework.sbm.engine.recipe.UserInteractions; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.resource.TestProjectContext; import freemarker.template.Configuration; import org.apache.commons.io.IOUtils; diff --git a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxws/WebServiceDescriptorTest.java b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxws/WebServiceDescriptorTest.java index 274a723a4..9ed8dda94 100644 --- a/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxws/WebServiceDescriptorTest.java +++ b/components/sbm-recipes-jee-to-boot/src/test/java/org/springframework/sbm/jee/jaxws/WebServiceDescriptorTest.java @@ -15,14 +15,14 @@ */ package org.springframework.sbm.jee.jaxws; -import org.springframework.sbm.GitHubIssue; -import org.springframework.sbm.java.api.Type; -import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; -import org.springframework.sbm.project.resource.TestProjectContext; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import org.openrewrite.xml.tree.Xml; +import org.springframework.rewrite.parsers.RewriteExecutionContext; +import org.springframework.sbm.GitHubIssue; +import org.springframework.sbm.engine.context.ProjectContext; +import org.springframework.sbm.java.api.Type; +import org.springframework.sbm.project.resource.TestProjectContext; import java.io.IOException; import java.nio.file.Files; diff --git a/components/sbm-recipes-mule-to-boot/src/main/java/org/springframework/sbm/mule/resource/MuleXml.java b/components/sbm-recipes-mule-to-boot/src/main/java/org/springframework/sbm/mule/resource/MuleXml.java index 9cd953f2a..af8ddcde5 100644 --- a/components/sbm-recipes-mule-to-boot/src/main/java/org/springframework/sbm/mule/resource/MuleXml.java +++ b/components/sbm-recipes-mule-to-boot/src/main/java/org/springframework/sbm/mule/resource/MuleXml.java @@ -15,7 +15,7 @@ */ package org.springframework.sbm.mule.resource; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import lombok.Getter; import org.mulesoft.schema.mule.core.MuleType; import org.openrewrite.xml.tree.Xml; diff --git a/components/sbm-recipes-mule-to-boot/src/main/java/org/springframework/sbm/mule/resource/MuleXmlProjectResourceRegistrar.java b/components/sbm-recipes-mule-to-boot/src/main/java/org/springframework/sbm/mule/resource/MuleXmlProjectResourceRegistrar.java index 3e18a9545..22780f8dd 100644 --- a/components/sbm-recipes-mule-to-boot/src/main/java/org/springframework/sbm/mule/resource/MuleXmlProjectResourceRegistrar.java +++ b/components/sbm-recipes-mule-to-boot/src/main/java/org/springframework/sbm/mule/resource/MuleXmlProjectResourceRegistrar.java @@ -24,7 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.ProjectResourceWrapper; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.stereotype.Component; import java.io.ByteArrayInputStream; diff --git a/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java b/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java index 4ca962036..6c372f5f7 100644 --- a/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java +++ b/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java @@ -23,7 +23,7 @@ import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.lang.ArchRule; import org.openrewrite.ExecutionContext; -import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.boot.autoconfigure.ScopeConfiguration; import org.springframework.sbm.openrewrite.RewriteExecutionContext; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; diff --git a/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/JavaDSLActionBaseTest.java b/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/JavaDSLActionBaseTest.java index 98244d640..125ec50bb 100644 --- a/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/JavaDSLActionBaseTest.java +++ b/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/JavaDSLActionBaseTest.java @@ -46,7 +46,7 @@ import org.springframework.sbm.mule.api.toplevel.configuration.MuleConfigurationsExtractor; import org.springframework.sbm.mule.resource.MuleXmlProjectResourceRegistrar; import org.springframework.sbm.parsers.RewriteExecutionContext; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.resource.SbmApplicationProperties; import org.springframework.sbm.project.resource.TestProjectContext; import org.springframework.sbm.test.TestProjectContextInfo; diff --git a/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/MuleToJavaDSLAmqpTest.java b/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/MuleToJavaDSLAmqpTest.java index 998220225..6853b5e0f 100644 --- a/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/MuleToJavaDSLAmqpTest.java +++ b/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/MuleToJavaDSLAmqpTest.java @@ -17,7 +17,7 @@ import org.junit.jupiter.api.Test; import org.openrewrite.SourceFile; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import java.util.List; import java.util.stream.Collectors; diff --git a/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/MuleToJavaDSLHttpTest.java b/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/MuleToJavaDSLHttpTest.java index 111466228..d6acfabc1 100644 --- a/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/MuleToJavaDSLHttpTest.java +++ b/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/MuleToJavaDSLHttpTest.java @@ -17,7 +17,7 @@ import org.junit.jupiter.api.Test; import org.openrewrite.SourceFile; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import java.util.List; import java.util.stream.Collectors; diff --git a/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/wmq/MuleToJavaDSLWmqTest.java b/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/wmq/MuleToJavaDSLWmqTest.java index 4c2f56694..3d3d66a08 100644 --- a/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/wmq/MuleToJavaDSLWmqTest.java +++ b/components/sbm-recipes-mule-to-boot/src/test/java/org/springframework/sbm/mule/actions/wmq/MuleToJavaDSLWmqTest.java @@ -20,7 +20,7 @@ import org.openrewrite.SourceFile; import org.springframework.sbm.build.api.Dependency; import org.springframework.sbm.mule.actions.JavaDSLActionBaseTest; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import java.util.List; import java.util.stream.Collectors; diff --git a/components/sbm-recipes-spring-cloud/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java b/components/sbm-recipes-spring-cloud/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java index 70e08f74f..a2ba1c017 100644 --- a/components/sbm-recipes-spring-cloud/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java +++ b/components/sbm-recipes-spring-cloud/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java @@ -23,8 +23,8 @@ import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.lang.ArchRule; import org.openrewrite.ExecutionContext; -import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration; -import org.springframework.sbm.parsers.RewriteExecutionContext; +import org.springframework.rewrite.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; diff --git a/components/sbm-recipes-spring-cloud/src/test/java/org/springframework/sbm/sccs/MigrateToSpringCloudConfigServerHelperTest.java b/components/sbm-recipes-spring-cloud/src/test/java/org/springframework/sbm/sccs/MigrateToSpringCloudConfigServerHelperTest.java index abd2bee04..7d10f3641 100644 --- a/components/sbm-recipes-spring-cloud/src/test/java/org/springframework/sbm/sccs/MigrateToSpringCloudConfigServerHelperTest.java +++ b/components/sbm-recipes-spring-cloud/src/test/java/org/springframework/sbm/sccs/MigrateToSpringCloudConfigServerHelperTest.java @@ -15,19 +15,19 @@ */ package org.springframework.sbm.sccs; -import org.springframework.sbm.parsers.RewriteExecutionContext; -import org.springframework.sbm.test.ProjectContextFileSystemTestSupport; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher; import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; import org.springframework.sbm.boot.properties.api.SpringProfile; import org.springframework.sbm.boot.properties.search.SpringBootApplicationPropertiesResourceListFinder; -import org.springframework.sbm.engine.git.GitSupport; import org.springframework.sbm.engine.context.ProjectContext; +import org.springframework.sbm.engine.git.GitSupport; import org.springframework.sbm.project.resource.SbmApplicationProperties; import org.springframework.sbm.project.resource.TestProjectContext; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; +import org.springframework.sbm.test.ProjectContextFileSystemTestSupport; import java.io.IOException; import java.nio.file.Files; diff --git a/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/include/ImportSpringXmlConfigAction.java b/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/include/ImportSpringXmlConfigAction.java index 795417dea..e576c4812 100644 --- a/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/include/ImportSpringXmlConfigAction.java +++ b/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/include/ImportSpringXmlConfigAction.java @@ -23,7 +23,7 @@ import org.springframework.sbm.build.api.Module; import org.springframework.sbm.build.api.JavaSourceSet; import org.springframework.sbm.java.api.JavaSourceLocation; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.resource.filter.XmlSpringBeanConfigurationFilter; import freemarker.template.Configuration; import freemarker.template.Template; diff --git a/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/migration/MigrateXmlToJavaConfigurationAction.java b/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/migration/MigrateXmlToJavaConfigurationAction.java index d284e1afe..ea68b2e98 100644 --- a/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/migration/MigrateXmlToJavaConfigurationAction.java +++ b/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/migration/MigrateXmlToJavaConfigurationAction.java @@ -17,7 +17,7 @@ import org.springframework.sbm.engine.recipe.AbstractAction; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.beans.factory.annotation.Autowired; import java.util.List; diff --git a/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/migration/MigrateXmlToJavaConfigurationActionHelper.java b/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/migration/MigrateXmlToJavaConfigurationActionHelper.java index 7a3c3fb4a..8d5f0554d 100644 --- a/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/migration/MigrateXmlToJavaConfigurationActionHelper.java +++ b/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/migration/MigrateXmlToJavaConfigurationActionHelper.java @@ -17,7 +17,7 @@ import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.project.resource.ProjectResource; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.stereotype.Component; import java.nio.file.Path; diff --git a/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/migration/XmlToJavaConfigurationMigration.java b/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/migration/XmlToJavaConfigurationMigration.java index 744259363..11e5b22f9 100644 --- a/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/migration/XmlToJavaConfigurationMigration.java +++ b/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/actions/spring/xml/migration/XmlToJavaConfigurationMigration.java @@ -18,7 +18,7 @@ import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.TypeSpec; import org.springframework.sbm.build.api.Module; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; diff --git a/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/project/resource/filter/XmlSpringBeanConfigurationFilter.java b/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/project/resource/filter/XmlSpringBeanConfigurationFilter.java index 51d29f35e..6e8e048d2 100644 --- a/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/project/resource/filter/XmlSpringBeanConfigurationFilter.java +++ b/components/sbm-recipes-spring-framework/src/main/java/org/springframework/sbm/project/resource/filter/XmlSpringBeanConfigurationFilter.java @@ -15,7 +15,7 @@ */ package org.springframework.sbm.project.resource.filter; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.resource.ProjectResourceSet; import java.util.List; diff --git a/components/sbm-recipes-spring-framework/src/test/java/org/springframework/sbm/actions/spring/xml/migration/MigrateXmlToJavaConfigurationActionTest.java b/components/sbm-recipes-spring-framework/src/test/java/org/springframework/sbm/actions/spring/xml/migration/MigrateXmlToJavaConfigurationActionTest.java index e0e412699..0a53c7575 100644 --- a/components/sbm-recipes-spring-framework/src/test/java/org/springframework/sbm/actions/spring/xml/migration/MigrateXmlToJavaConfigurationActionTest.java +++ b/components/sbm-recipes-spring-framework/src/test/java/org/springframework/sbm/actions/spring/xml/migration/MigrateXmlToJavaConfigurationActionTest.java @@ -18,7 +18,7 @@ import org.springframework.sbm.build.api.ApplicationModules; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.build.api.Module; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; diff --git a/components/sbm-recipes-spring-framework/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java b/components/sbm-recipes-spring-framework/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java index 4ca962036..6c372f5f7 100644 --- a/components/sbm-recipes-spring-framework/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java +++ b/components/sbm-recipes-spring-framework/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java @@ -23,7 +23,7 @@ import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.lang.ArchRule; import org.openrewrite.ExecutionContext; -import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.boot.autoconfigure.ScopeConfiguration; import org.springframework.sbm.openrewrite.RewriteExecutionContext; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; diff --git a/components/sbm-support-boot/pom.xml b/components/sbm-support-boot/pom.xml index bad82b587..6fb7c9f7b 100644 --- a/components/sbm-support-boot/pom.xml +++ b/components/sbm-support-boot/pom.xml @@ -83,5 +83,10 @@ archunit-junit5 1.0.1 + + org.antlr + ST4 + test + \ No newline at end of file diff --git a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/common/finder/SpringBeanMethodDeclarationFinder.java b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/common/finder/SpringBeanMethodDeclarationFinder.java index 81bba841b..f269f8491 100644 --- a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/common/finder/SpringBeanMethodDeclarationFinder.java +++ b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/common/finder/SpringBeanMethodDeclarationFinder.java @@ -16,9 +16,9 @@ package org.springframework.sbm.boot.common.finder; import lombok.RequiredArgsConstructor; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.java.filter.JavaSourceListFinder; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; import java.util.ArrayList; import java.util.List; diff --git a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/SpringApplicationPropertiesPathMatcher.java b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/SpringApplicationPropertiesPathMatcher.java index 68ca110f9..4f17d0a03 100644 --- a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/SpringApplicationPropertiesPathMatcher.java +++ b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/SpringApplicationPropertiesPathMatcher.java @@ -15,7 +15,7 @@ */ package org.springframework.sbm.boot.properties; -import org.springframework.sbm.utils.LinuxWindowsPathUnifier; +import org.springframework.rewrite.utils.LinuxWindowsPathUnifier; import org.springframework.stereotype.Component; import java.util.regex.Matcher; @@ -28,7 +28,7 @@ public class SpringApplicationPropertiesPathMatcher { private Pattern profilePattern = Pattern.compile(regex); public Matcher match(String path) { - String unifiedPath = new LinuxWindowsPathUnifier().unifyPath(path); + String unifiedPath = LinuxWindowsPathUnifier.unifiedPathString(path); return profilePattern.matcher(unifiedPath); } } diff --git a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/SpringBootApplicationPropertiesRegistrar.java b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/SpringBootApplicationPropertiesRegistrar.java index c08c26f18..c3288e7c0 100644 --- a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/SpringBootApplicationPropertiesRegistrar.java +++ b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/SpringBootApplicationPropertiesRegistrar.java @@ -19,11 +19,11 @@ import org.openrewrite.ExecutionContext; import org.openrewrite.SourceFile; import org.openrewrite.properties.tree.Properties; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.utils.OsAgnosticPathMatcher; import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; import org.springframework.sbm.boot.properties.api.SpringProfile; -import org.springframework.sbm.utils.OsAgnosticPathMatcher; import org.springframework.sbm.project.resource.ProjectResourceWrapper; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import org.springframework.stereotype.Component; import org.springframework.util.PathMatcher; diff --git a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/api/SpringBootApplicationProperties.java b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/api/SpringBootApplicationProperties.java index cc2ff8b3c..bce3b96f8 100644 --- a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/api/SpringBootApplicationProperties.java +++ b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/api/SpringBootApplicationProperties.java @@ -15,15 +15,12 @@ */ package org.springframework.sbm.boot.properties.api; -import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.Setter; import org.openrewrite.ExecutionContext; import org.openrewrite.Tree; import org.openrewrite.marker.Markers; import org.openrewrite.properties.tree.Properties.File; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.properties.api.PropertiesSource; import org.springframework.util.Assert; diff --git a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/finder/SpringBootDefaultPropertiesFinder.java b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/finder/SpringBootDefaultPropertiesFinder.java index 7ccc0c56a..4da33e3cb 100644 --- a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/finder/SpringBootDefaultPropertiesFinder.java +++ b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/finder/SpringBootDefaultPropertiesFinder.java @@ -15,9 +15,9 @@ */ package org.springframework.sbm.boot.properties.finder; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; import java.util.Optional; diff --git a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/search/SpringBootApplicationPropertiesResourceListFinder.java b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/search/SpringBootApplicationPropertiesResourceListFinder.java index ca730a8d9..e40fc9dc3 100644 --- a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/search/SpringBootApplicationPropertiesResourceListFinder.java +++ b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/search/SpringBootApplicationPropertiesResourceListFinder.java @@ -15,8 +15,8 @@ */ package org.springframework.sbm.boot.properties.search; +import org.springframework.rewrite.project.resource.finder.GenericTypeListFinder; import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; -import org.springframework.sbm.project.resource.finder.GenericTypeListFinder; public class SpringBootApplicationPropertiesResourceListFinder extends GenericTypeListFinder { diff --git a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/web/finder/FindRestControllerBeans.java b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/web/finder/FindRestControllerBeans.java index 73bdf7134..f787836ba 100644 --- a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/web/finder/FindRestControllerBeans.java +++ b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/web/finder/FindRestControllerBeans.java @@ -15,10 +15,10 @@ */ package org.springframework.sbm.boot.web.finder; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.boot.web.api.RestControllerBean; import org.springframework.sbm.java.filter.JavaSourceListFinder; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; import java.util.List; import java.util.stream.Collectors; diff --git a/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/SpringBootApplicationPropertiesRegistrarTest.java b/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/SpringBootApplicationPropertiesRegistrarTest.java index 810eee221..3b547be40 100644 --- a/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/SpringBootApplicationPropertiesRegistrarTest.java +++ b/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/SpringBootApplicationPropertiesRegistrarTest.java @@ -15,14 +15,12 @@ */ package org.springframework.sbm.boot.properties; -import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; -import org.springframework.sbm.parsers.RewriteExecutionContext; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; -import org.springframework.sbm.properties.parser.RewritePropertiesParser; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; import org.openrewrite.properties.tree.Properties; +import org.springframework.rewrite.parsers.RewriteExecutionContext; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; +import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; +import org.springframework.sbm.properties.parser.RewritePropertiesParser; import java.nio.file.Path; diff --git a/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/actions/AddSpringBootApplicationPropertiesActionTest.java b/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/actions/AddSpringBootApplicationPropertiesActionTest.java index 8e7e4d8a9..ac8aa2ccd 100644 --- a/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/actions/AddSpringBootApplicationPropertiesActionTest.java +++ b/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/actions/AddSpringBootApplicationPropertiesActionTest.java @@ -15,16 +15,16 @@ */ package org.springframework.sbm.boot.properties.actions; -import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; -import org.springframework.sbm.boot.properties.search.SpringBootApplicationPropertiesResourceListFinder; -import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; -import org.springframework.sbm.project.resource.TestProjectContext; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.rewrite.parsers.RewriteExecutionContext; +import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; +import org.springframework.sbm.boot.properties.search.SpringBootApplicationPropertiesResourceListFinder; +import org.springframework.sbm.engine.context.ProjectContext; +import org.springframework.sbm.project.resource.TestProjectContext; import org.springframework.sbm.test.ActionTest; import java.nio.file.Path; diff --git a/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/api/SpringBootApplicationPropertiesTest.java b/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/api/SpringBootApplicationPropertiesTest.java index c3ad24bf6..db8622d43 100644 --- a/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/api/SpringBootApplicationPropertiesTest.java +++ b/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/api/SpringBootApplicationPropertiesTest.java @@ -20,7 +20,7 @@ import org.openrewrite.SourceFile; import org.openrewrite.properties.PropertiesParser; import org.openrewrite.properties.tree.Properties; -import org.springframework.sbm.parsers.RewriteExecutionContext; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import java.nio.file.Path; import java.util.List; diff --git a/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/finder/SpringBootDefaultPropertiesFinderTest.java b/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/finder/SpringBootDefaultPropertiesFinderTest.java index 0b6f3b27e..072ec7936 100644 --- a/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/finder/SpringBootDefaultPropertiesFinderTest.java +++ b/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/finder/SpringBootDefaultPropertiesFinderTest.java @@ -16,10 +16,10 @@ package org.springframework.sbm.boot.properties.finder; import org.junit.jupiter.api.Test; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher; import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.TestProjectContext; import java.nio.file.Path; diff --git a/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/search/SpringBootApplicationPropertiesResourceFilterTest.java b/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/search/SpringBootApplicationPropertiesResourceFilterTest.java index d100a0d20..462b58873 100644 --- a/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/search/SpringBootApplicationPropertiesResourceFilterTest.java +++ b/components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/properties/search/SpringBootApplicationPropertiesResourceFilterTest.java @@ -15,11 +15,11 @@ */ package org.springframework.sbm.boot.properties.search; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher; import org.springframework.sbm.boot.properties.SpringBootApplicationPropertiesRegistrar; import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.parsers.RewriteExecutionContext; import org.springframework.sbm.project.resource.TestProjectContext; import org.junit.jupiter.api.Test; diff --git a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/ejb/api/EjbJarXml.java b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/ejb/api/EjbJarXml.java index d79feb0a8..1efea5c98 100644 --- a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/ejb/api/EjbJarXml.java +++ b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/ejb/api/EjbJarXml.java @@ -16,7 +16,7 @@ package org.springframework.sbm.jee.ejb.api; import org.openrewrite.xml.tree.Xml; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.xml.sax.InputSource; import javax.xml.bind.*; diff --git a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/ejb/filter/EjbJarXmlResourceFinder.java b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/ejb/filter/EjbJarXmlResourceFinder.java index 678ec683f..b10a60663 100644 --- a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/ejb/filter/EjbJarXmlResourceFinder.java +++ b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/ejb/filter/EjbJarXmlResourceFinder.java @@ -15,9 +15,9 @@ */ package org.springframework.sbm.jee.ejb.filter; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.jee.ejb.api.EjbJarXml; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; import java.util.Optional; diff --git a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/ejb/resource/JeeEjbJarXmlProjectResourceRegistrar.java b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/ejb/resource/JeeEjbJarXmlProjectResourceRegistrar.java index c587a2e5e..2d8b51d05 100644 --- a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/ejb/resource/JeeEjbJarXmlProjectResourceRegistrar.java +++ b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/ejb/resource/JeeEjbJarXmlProjectResourceRegistrar.java @@ -15,9 +15,9 @@ */ package org.springframework.sbm.jee.ejb.resource; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.jee.ejb.api.EjbJarXml; import org.springframework.sbm.project.resource.ProjectResourceWrapper; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import org.openrewrite.SourceFile; import org.openrewrite.xml.tree.Xml; import org.springframework.stereotype.Component; diff --git a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/jpa/api/PersistenceXml.java b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/jpa/api/PersistenceXml.java index a93f1a669..3e1b2ce7f 100644 --- a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/jpa/api/PersistenceXml.java +++ b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/jpa/api/PersistenceXml.java @@ -15,7 +15,7 @@ */ package org.springframework.sbm.jee.jpa.api; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import lombok.Getter; import org.openrewrite.xml.tree.Xml; diff --git a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/jpa/filter/PersistenceXmlResourceFinder.java b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/jpa/filter/PersistenceXmlResourceFinder.java index 8fe693ccb..185a223ba 100644 --- a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/jpa/filter/PersistenceXmlResourceFinder.java +++ b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/jpa/filter/PersistenceXmlResourceFinder.java @@ -15,8 +15,8 @@ */ package org.springframework.sbm.jee.jpa.filter; +import org.springframework.rewrite.project.resource.finder.GenericTypeFinder; import org.springframework.sbm.jee.jpa.api.PersistenceXml; -import org.springframework.sbm.project.resource.finder.GenericTypeFinder; // FIXME: what if persistence.xml in src/test/resources also exists?! public class PersistenceXmlResourceFinder extends GenericTypeFinder { diff --git a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/jpa/resource/PersistenceXmlProjectResourceRegistrar.java b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/jpa/resource/PersistenceXmlProjectResourceRegistrar.java index 09851296c..34970d208 100644 --- a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/jpa/resource/PersistenceXmlProjectResourceRegistrar.java +++ b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/jpa/resource/PersistenceXmlProjectResourceRegistrar.java @@ -17,14 +17,14 @@ import org.openrewrite.ExecutionContext; import org.openrewrite.internal.InMemoryLargeSourceSet; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.jee.jpa.api.PersistenceXml; -import org.springframework.sbm.project.resource.ProjectResourceWrapper; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import lombok.RequiredArgsConstructor; import org.openrewrite.Result; import org.openrewrite.SourceFile; import org.openrewrite.xml.search.FindTags; import org.openrewrite.xml.tree.Xml; +import org.springframework.sbm.project.resource.ProjectResourceWrapper; import org.springframework.stereotype.Component; import java.util.List; diff --git a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/web/api/JeeWebXmlProjectResourceRegistrar.java b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/web/api/JeeWebXmlProjectResourceRegistrar.java index a1254b6eb..f677afed5 100644 --- a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/web/api/JeeWebXmlProjectResourceRegistrar.java +++ b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/web/api/JeeWebXmlProjectResourceRegistrar.java @@ -18,8 +18,8 @@ import org.openrewrite.ExecutionContext; import org.openrewrite.internal.InMemoryLargeSourceSet; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.resource.ProjectResourceWrapper; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.web.api.WebAppType; import org.openrewrite.SourceFile; import org.openrewrite.xml.search.FindTags; diff --git a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/web/api/WebXml.java b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/web/api/WebXml.java index 087c27c92..f10b4b5be 100644 --- a/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/web/api/WebXml.java +++ b/components/sbm-support-jee/src/main/java/org/springframework/sbm/jee/web/api/WebXml.java @@ -16,7 +16,7 @@ package org.springframework.sbm.jee.web.api; import com.sun.xml.bind.marshaller.NamespacePrefixMapper; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.web.api.ServletMappingType; import org.springframework.sbm.project.web.api.ServletType; import org.springframework.sbm.project.web.api.UrlPatternType; diff --git a/components/sbm-support-jee/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java b/components/sbm-support-jee/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java index 70e08f74f..a2ba1c017 100644 --- a/components/sbm-support-jee/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java +++ b/components/sbm-support-jee/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java @@ -23,8 +23,8 @@ import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.lang.ArchRule; import org.openrewrite.ExecutionContext; -import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration; -import org.springframework.sbm.parsers.RewriteExecutionContext; +import org.springframework.rewrite.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; diff --git a/components/sbm-support-weblogic/src/main/java/org/springframework/sbm/jee/wls/JeeWlsEjbJarProjectResourceRegistrar.java b/components/sbm-support-weblogic/src/main/java/org/springframework/sbm/jee/wls/JeeWlsEjbJarProjectResourceRegistrar.java index 0c2938283..742417dfb 100644 --- a/components/sbm-support-weblogic/src/main/java/org/springframework/sbm/jee/wls/JeeWlsEjbJarProjectResourceRegistrar.java +++ b/components/sbm-support-weblogic/src/main/java/org/springframework/sbm/jee/wls/JeeWlsEjbJarProjectResourceRegistrar.java @@ -15,8 +15,8 @@ */ package org.springframework.sbm.jee.wls; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.project.resource.ProjectResourceWrapper; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import org.openrewrite.SourceFile; import org.springframework.stereotype.Component; diff --git a/components/sbm-support-weblogic/src/main/java/org/springframework/sbm/jee/wls/WlsEjbDeploymentDescriptor.java b/components/sbm-support-weblogic/src/main/java/org/springframework/sbm/jee/wls/WlsEjbDeploymentDescriptor.java index 90c887add..9ad856b1b 100644 --- a/components/sbm-support-weblogic/src/main/java/org/springframework/sbm/jee/wls/WlsEjbDeploymentDescriptor.java +++ b/components/sbm-support-weblogic/src/main/java/org/springframework/sbm/jee/wls/WlsEjbDeploymentDescriptor.java @@ -15,7 +15,7 @@ */ package org.springframework.sbm.jee.wls; -import org.springframework.sbm.project.resource.RewriteSourceFileHolder; +import org.springframework.rewrite.project.resource.RewriteSourceFileHolder; import org.openrewrite.xml.XmlParser; import org.openrewrite.xml.tree.Xml; diff --git a/components/sbm-support-weblogic/src/main/java/org/springframework/sbm/jee/wls/finder/JeeWlsEjbDeploymentDescriptorFilter.java b/components/sbm-support-weblogic/src/main/java/org/springframework/sbm/jee/wls/finder/JeeWlsEjbDeploymentDescriptorFilter.java index 893222a88..a0f92a86d 100644 --- a/components/sbm-support-weblogic/src/main/java/org/springframework/sbm/jee/wls/finder/JeeWlsEjbDeploymentDescriptorFilter.java +++ b/components/sbm-support-weblogic/src/main/java/org/springframework/sbm/jee/wls/finder/JeeWlsEjbDeploymentDescriptorFilter.java @@ -15,9 +15,9 @@ */ package org.springframework.sbm.jee.wls.finder; -import org.springframework.sbm.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.ProjectResourceSet; +import org.springframework.rewrite.project.resource.finder.ProjectResourceFinder; import org.springframework.sbm.jee.wls.WlsEjbDeploymentDescriptor; -import org.springframework.sbm.project.resource.finder.ProjectResourceFinder; import java.util.Optional; diff --git a/components/sbm-support-weblogic/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java b/components/sbm-support-weblogic/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java index 70e08f74f..a2ba1c017 100644 --- a/components/sbm-support-weblogic/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java +++ b/components/sbm-support-weblogic/src/test/java/org/springframework/sbm/architecture/ControlledInstantiationOfExecutionContextTest.java @@ -23,8 +23,8 @@ import com.tngtech.archunit.junit.ArchTest; import com.tngtech.archunit.lang.ArchRule; import org.openrewrite.ExecutionContext; -import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration; -import org.springframework.sbm.parsers.RewriteExecutionContext; +import org.springframework.rewrite.boot.autoconfigure.ScopeConfiguration; +import org.springframework.rewrite.parsers.RewriteExecutionContext; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; diff --git a/pom.xml b/pom.xml index 28f1cf545..cf52dfd6f 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,8 @@ spring-boot-migrator UTF-8 UTF-8 - 8.1.8 + 8.12.0 + 0.1.0-SNAPSHOT 3.1.2 2.5.0 17 @@ -31,7 +32,6 @@ UTF-8 src/generated/java 1.33 - 0.1.0-SNAPSHOT 0.0.5 @@ -62,6 +62,24 @@ components/sbm-recipes-spring-cloud components/sbm-recipes-boot-upgrade + + + + spring-milestone + https://repo.spring.io/milestone + + false + + + + spring-snapshot + https://repo.spring.io/snapshot + + false + + + + @@ -238,9 +256,9 @@ 2.0.6 - org.springframework.experimental - sbm-support-rewrite - ${sbm-support-rewrite.version} + org.springframework.rewrite + spring-rewrite-commons-launcher + ${spring-rewrite-commons-launcher.version} diff --git a/sbm-support-rewrite-integration-test/src/main/java/com/acme/example/SpringBoot3Upgrade.java b/sbm-support-rewrite-integration-test/src/main/java/com/acme/example/SpringBoot3Upgrade.java index e1b9b9693..682e5b1a7 100644 --- a/sbm-support-rewrite-integration-test/src/main/java/com/acme/example/SpringBoot3Upgrade.java +++ b/sbm-support-rewrite-integration-test/src/main/java/com/acme/example/SpringBoot3Upgrade.java @@ -23,7 +23,7 @@ import org.springframework.context.event.EventListener; import org.springframework.core.io.Resource; import org.springframework.sbm.parsers.ProjectScanner; -import org.springframework.sbm.parsers.RewriteProjectParser; +import org.springframework.rewrite.parsers.RewriteProjectParser; import org.springframework.sbm.parsers.RewriteProjectParsingResult; import org.springframework.sbm.parsers.events.StartedParsingResourceEvent; import org.springframework.sbm.project.RewriteSourceFileWrapper; diff --git a/sbm-support-rewrite/.gitignore b/sbm-support-rewrite/.gitignore deleted file mode 100644 index 3fffeaa1f..000000000 --- a/sbm-support-rewrite/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/testcode/**/target/** -/testcode/**/.rewrite-cache/** \ No newline at end of file diff --git a/sbm-support-rewrite/README.adoc b/sbm-support-rewrite/README.adoc deleted file mode 100644 index 69ee28662..000000000 --- a/sbm-support-rewrite/README.adoc +++ /dev/null @@ -1,311 +0,0 @@ -# sbm-support-rewrite - -The `sbm-support-rewrite` project provides Spring beans classes to parse a given project to an OpenRewrite abstract syntax tree (AST) which can then be used to run OpenRewrite recipes that were discovered on the classpath. - -## Components -The following components can be used to parse a project, run recipes and write changes back to the filesystem. -These components are provided as Spring beans and can be injected into other Spring beans that require them. - -_Example: Inject RewriteProjectParser into your Spring bean_ -[source,java] -.... -@Autowired -RewriteProjectParser parser; -.... - -### ProjectScanner -Scan a given path to a list of resources using filter definitions provided as application properties. - -### RewriteProjectParser -Parses a project to OpenRewrite's AST representation. - -### RewriteExecutionContext -OpenRewrite's `ExecutionContext` gets initialized during parsing. -This `ExecutionContext` is required for some recipes and inner workings of OpenRewrite. - -### RecipeDiscovery -Discover OpenRewrite recipes on classpath - -### ProjectResourceSet -Abstraction of OpenRewrite SourceFiles that allows execution of recipes against the SourceFiles while -synchronizing changes with the underlying list of SourceFiles. - -### ProjectResourceSetSerializer -Write back the in-memory changed SourceFiles from the ProjectResourceSet to the filesystem. - -## Getting started - -### Adding the dependency -Currently only SNAPSHOT releases are available from https://repo.spring.io. -To access these, a repository must be added. - -[source,xml] -..... - - - spring-snapshot - https://repo.spring.io/snapshot - - false - - - -..... - -Then the dependency can be retrieved. - -[source,xml] -..... - - org.springframwork.experimental - sbm-support-rewrite - 0.1.0-SNAPSHOT - -..... - -### (Optional) Scan a project -`ProjectScanner` scans a given `Path` to a list of ``Resource``s. -It filters out resources and directories matching any of the ignore patterns in -`parser.ignoredPathPatterns`. - -### Parse a project -`RewriteProjectParser` parses a project to OpenRewrite AST. - -The provided `parse(Path)` method can be used to parse a project under a given `Path` to OpenRewrite AST. - -[source,java] -..... -Path baseDir = ... -List ast = parser.parse(baseDir); -..... - -### ExecutionContext -OpenRewrite's `ExecutionContext` is populated during parsing and the settings might be required for recipes executed later. -The `ExecutionContext` is provided as scoped Spring bean and can be injected into other Spring beans. -It has the same scope as the parsing and a new instance is automatically created with every parse. - -NOTE: The ExecutionContext should always be injected and should not be created programmatically. - -### Discover and run recipes - -OpenRewrite recipes can be discovered from classpath with `RewriteRecipeDiscovery` which is provided as Spring bean. - -[source,java] -.... -@Autowired -RewriteRecipeDiscovery discovery; - -@Autowired -ExecutionContext ctx; -... -Recipe recipe = discovery.getRecipe("org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_1"); -RecipeRun recipe = recipe.run(new InMemoryLargeSourceSet(ast), ctx)); -.... - -### Use ProjectResourceSet -A successful recipe run will return the modified ``SourceFile``s. -Before another recipe can be applied to the AST the changed ``SourceFile``s need to be merged into the original list of ``SourceFile``s (the AST). -The `ProjectResourceSet` provides this capability. - -[source,java] -.... -@Component -public class SomeClass { - - @Autowired - ProjectResourceSetFactory factory; - - @Autowired - RewriteProjectParser parser; - - void method() { - Recipe r1 = ... - Recipe r2 = ... - RewriteProjectParsingResult parsingResult = parser.parse(baseDir); - List sourceFiles = parsingResult.sourceFiles(); - ProjectResourceSet projectResourceSet = factory.create(baseDir, sourceFiles); - projectResourceSet.apply(r1); // internally changes get merged back to AST - projectResourceSet.apply(r2); // r2 applied against the AST with changes from r1 - } -} -.... - -### Write changes back to filesystem -The `ProjectResourceSetSerializer` can be used to write all changes (modify, delete, add) in `ProjectResourceSet` to the filesystem. - -[source,java] -.... -@Autowired -private ProjectResourceSetSerializer serializer; -... -public void method() { - ... - serializer.writeChanges(projectResourceSet); -} -.... - - - -### Listen to ParserEvents - -``ParserEvent``s get published during parsing. -The events can be used to provide progress information to users. -This is especially useful when parsing large projects where parsing can take some time. - - -* `StartedParsingProjectEvent` - Gets published when the parsing started -* `ParsedResourceEvent` - Gets published after every parsed pom or Java file -* `SuccessfullyParsedProjectEvent` - Gets published when the parsing was successful - -[source,java] -..... -@EventListener(ParsedResourceEvent.class) -public void onParsedResourceEvent(ParsedResourceEvent event) { - Parser.Input input = event.input(); - SourceFile sourceFile = event.sourceFile(); - log("parsed %s to %s".formatted(input.getRelativePath(), sourceFile.getClass().getName())); -} -..... - -## Configuration - -Some behaviour can be configured through application properties or by providing custom Spring beans. - -### Maven Artifact Cache -OpenRewrite uses a `MavenArtifactCache` to store downloaded jar dependencies. -The provided `MavenArtifactCache` bean tries to retrieve jars from local Maven cache `~/.m2/repository` first. -If the dependency doesn't exist it is searched under `~/.rewrite/cache/artifacts` and if it doesn't exist it is downloaded to this dir. - -[source,java] -..... -@Bean -MavenArtifactCache mavenArtifactCache() { - Path userHome = Path.of(System.getProperty("user.home")); - Path localMavenRepo = userHome.resolve(".m2/repository"); - Path localRewriteRepo = userHome.resolve(".rewrite/cache/artifacts"); - return new LocalMavenArtifactCache(localMavenRepo) - .orElse(localRewriteRepo)); -} -..... - -#### Custom Maven Artifact Cache - -The provided cache configuration can be replaced with a custom bean. - -[source,java] -..... -@Bean -MavenArtifactCache mavenArtifactCache() { - return new CustomMavenArtifactCache(); -} - -..... - - - - -### Maven Pom Cache -OpenRewrite downloads Maven Pom files to resolve dependencies. -The pom files get cached and the cache depends on the system. - -- 32-Bit systems use the `InMemoryPomCache`. -- 64-Bit systems use the `RocksdbMavenPomCache`. - - -#### Pom Cache Properties - -|=== -|Name |Description |Default Value - -|`parser.isPomCacheEnabled` -|If the flag is set to false, only the default, in-memory cache is used. -|`false` - -|`parser.pomCacheDirectory` -|Defines the cache dir for RocksdbMavenPomCache when `parser.isPomCacheEnabled` is `true` -|`~/.rewrite-cache` -|=== - -#### Custom Pom Cache -A custom `MavenPomCache` implementation can be provided through a custom Spring bean declaration. - -[source,java] -..... -@Bean -public MavenPomCache mavenPomCache() { - return new CustomMavenPomCache(); -} -..... - - -## Example - -Example code showing how to apply OpenRewrite's UpgradeSpringBoot_3_1 recipe - -[source, java] -..... -package com.example; - -import org.openrewrite.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.sbm.parsers.ProjectScanner; -import org.springframework.sbm.parsers.RewriteProjectParser; -import org.springframework.sbm.parsers.RewriteProjectParsingResult; -import org.springframework.sbm.project.resource.ProjectResourceSet; -import org.springframework.sbm.project.resource.ProjectResourceSetFactory; -import org.springframework.sbm.project.resource.ProjectResourceSetSerializer; -import org.springframework.sbm.recipes.RewriteRecipeDiscovery; - -import java.nio.file.Path; -import java.util.List; - -@SpringBootApplication -public class BootUpgrade implements CommandLineRunner { - public static void main(String[] args) { - SpringApplication.run(BootUpgrade.class, args); - } - - @Autowired - ProjectScanner scanner; - @Autowired - RewriteProjectParser parser; - @Autowired - RewriteRecipeDiscovery discovery; - @Autowired - ProjectResourceSetSerializer serializer; - @Autowired - ProjectResourceSetFactory factory; - - @Override - public void run(String... args) throws Exception { - - String path = "demo-spring-song-app"; - Path baseDir = Path.of(path ).toAbsolutePath().normalize(); - System.out.println(baseDir); - if(!baseDir.toFile().exists() || !baseDir.toFile().isDirectory()) { - throw new IllegalArgumentException("Given path '%s' does not exist or is not a directory.".formatted(path)); - } - - // parse - RewriteProjectParsingResult parsingResult = parser.parse(baseDir); - List sourceFiles = parsingResult.sourceFiles(); - - // create ProjectResourceSet - ProjectResourceSet projectResourceSet = factory.create(baseDir, sourceFiles); - - // find recipe - String recipeName = "org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_1"; - List recipes = discovery.discoverRecipes(); - Recipe recipe = findRecipe(recipes, recipeName); - - // apply recipe - projectResourceSet.apply(recipe); - - // write changes to fs - serializer.writeChanges(projectResourceSet); - } -} -..... \ No newline at end of file diff --git a/sbm-support-rewrite/pom.xml b/sbm-support-rewrite/pom.xml deleted file mode 100644 index 7a64eeb1f..000000000 --- a/sbm-support-rewrite/pom.xml +++ /dev/null @@ -1,523 +0,0 @@ - - - 4.0.0 - - org.springframework.experimental - 0.1.0-SNAPSHOT - sbm-support-rewrite - - Spring Boot Migrator OpenRewrite Support - Parse projects and run OpenRewrite recipes without a build tool plugin - https://github.com/spring-projects-experimental/spring-boot-migrator/sbm-support-rewrite - - - VMware Inc. - https://spring.io - - - - 17 - 17 - UTF-8 - 3.1.3 - 8.5.1 - 5.3.2 - 3.9.1 - 1.9.13 - 3.5.3 - 3.6.1 - 1.8 - 3.2.0 - 2.3.1 - 2.1.0 - 3.0.0-M7 - 3.11.0 - - - - - fkrueger - Fabian Krüger - fkrueger at vmware.com - VMware - http://www.spring.io - - lead - - - - - - scm:git:https://github.com/spring-projects-experimental/spring-boot-migrator.git - scm:git:https://github.com/spring-projects-experimental/spring-boot-migrator - https://github.com/spring-projects-experimental/spring-boot-migrator/sbm-support-openrewrite - 0.1.0-SNAPSHOT - - - - - Apache License, Version 2.0 - https://www.apache.org/licenses/LICENSE-2.0 - - Copyright 2022-2023 the original author or authors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied. - - See the License for the specific language governing permissions and - limitations under the License. - - - - - - - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - - - org.openrewrite - rewrite-bom - ${rewrite.version} - pom - import - - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-configuration-processor - true - - - com.squareup.okhttp3 - okhttp - - - org.openrewrite - rewrite-gradle - - - org.openrewrite - rewrite-groovy - - - org.openrewrite - rewrite-hcl - - - org.openrewrite - rewrite-java - - - org.openrewrite - rewrite-json - - - org.openrewrite - rewrite-maven - - - org.openrewrite - rewrite-properties - - - org.openrewrite - rewrite-protobuf - - - org.openrewrite - rewrite-xml - - - org.openrewrite - rewrite-yaml - - - org.openrewrite.maven - rewrite-maven-plugin - ${rewrite-maven-plugin.version} - test - - - org.projectlombok - lombok - provided - - - javax.xml.bind - jaxb-api - ${jaxb-api.version} - - - - org.codehaus.plexus - plexus-sec-dispatcher - 2.0 - - - - org.apache.maven - maven-embedder - ${maven.version} - - - org.sonatype.plexus - plexus-cipher - - - - - commons-cli - commons-cli - 1.4 - - - org.apache.maven.wagon - wagon-http - ${maven-wagon-http.version} - test - - - org.apache.maven.resolver - maven-resolver-transport-wagon - ${maven-resolver.version} - test - - - org.apache.maven.resolver - maven-resolver-connector-basic - ${maven-resolver.version} - test - - - org.apache.maven.resolver - maven-resolver-impl - ${maven-resolver.version} - test - - - org.apache.maven - maven-resolver-provider - ${maven.version} - test - - - org.apache.maven - maven-compat - ${maven.version} - test - - - org.codehaus.plexus - plexus-cipher - ${plexus-cypher.version} - - - org.apache.maven.shared - maven-invoker - ${maven-invoker.version} - test - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit-pioneer - junit-pioneer - ${junit-pioneer.version} - test - - - - - org.springframework.boot - spring-boot-testcontainers - test - - - org.testcontainers - junit-jupiter - test - - - org.apache.commons - commons-text - 1.10.0 - test - - - org.powermock - powermock-core - 2.0.9 - test - - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.4.1 - - accessibility,html,reference,syntax - package - true - public - author - true - false - false - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - - -parameters - - - - org.projectlombok - lombok - 1.18.28 - - - org.springframework.boot - spring-boot-configuration-processor - ${spring-boot.version} - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - org.junit.jupiter - junit-jupiter-engine - 5.4.0 - - - - - org.codehaus.mojo - versions-maven-plugin - 2.16.0 - - - com.mycila - license-maven-plugin - 4.1 - - - validate - - check - - - - - - the original author or authors. - - 2023 - - - - - -Copyright 2021 - ${year} the original author or authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - - - - **/demo/** - **/.sdkmanrc - **/*.adoc - **/*.puml - **/.rewrite*/** - **/src/main/resources/banner.txt - **/testcode/** - **/test-code/** - **/pom.xml - **/*.properties - **/*.yaml - **/*.yml - **/*.map - **/*.html - **/*.xhtml - **/*.jsp - **/*.js - **/*.css - **/*.txt - **/*.xjb - **/*.ftl - **/*.xsd - **/*.xml - **/*.sh - **/generated/** - **/Dockerfile - **/META-INF/** - - - - - - - - - - delombok - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.4.1 - - - org.projectlombok - lombok-maven-plugin - 1.18.20.0 - - - package - - delombok - - - ${basedir}/src/main/java - ${basedir}/target/delomboked - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.3.0 - - - create-sources-jar - package - - jar - - - ${project.build.directory}/delomboked - - **/*.java - - sources - - - - - - - - - artifactory - - true - - - - - org.jfrog.buildinfo - artifactory-maven-plugin - ${artifactory-maven-plugin.version} - false - - - deploy-to-artifactory - - publish - - - - https://repo.spring.io - ${env.ARTIFACTORY_USERNAME} - ${env.ARTIFACTORY_PASSWORD} - libs-milestone-local - libs-snapshot-local - - - CI build for sbm-support-rewrite ${project.version} - - - - - - - - - - spring-milestone - https://repo.spring.io/milestone - - false - - - - spring-snapshot - https://repo.spring.io/snapshot - - false - - - - - - repo.spring.io - https://repo.spring.io/snapshot - default - - false - - - - - - \ No newline at end of file diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/DiscoveryConfiguration.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/DiscoveryConfiguration.java deleted file mode 100644 index 4acce4ea2..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/DiscoveryConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.boot.autoconfigure; - -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; -import org.springframework.sbm.parsers.ParserProperties; -import org.springframework.sbm.parsers.RewriteParserConfiguration; -import org.springframework.sbm.recipes.RewriteRecipeDiscovery; - -/** - * @author Fabian Krüger - */ -@AutoConfiguration(after = RewriteParserConfiguration.class) -@Import(RewriteParserConfiguration.class) -@EnableConfigurationProperties(ParserProperties.class) -public class DiscoveryConfiguration { - @Bean - RewriteRecipeDiscovery rewriteRecipeDiscovery(ParserProperties parserProperties) { - return new RewriteRecipeDiscovery(parserProperties); - } -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/ParserPropertiesPostProcessor.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/ParserPropertiesPostProcessor.java deleted file mode 100644 index 3eaa2f590..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/ParserPropertiesPostProcessor.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.boot.autoconfigure; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.env.EnvironmentPostProcessor; -import org.springframework.boot.env.PropertiesPropertySourceLoader; -import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.core.env.PropertySource; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.util.Assert; - -import java.io.IOException; - -/** - * Add default values from 'sbm-support-rewrite.properties' to environment. - */ -public class ParserPropertiesPostProcessor implements EnvironmentPostProcessor { - - private final PropertiesPropertySourceLoader loader = new PropertiesPropertySourceLoader(); - - @Override - public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { - Resource path = new ClassPathResource("/META-INF/sbm-support-rewrite.properties"); - PropertySource propertySource = loadProperties(path); - environment.getPropertySources().addLast(propertySource); - } - - private PropertySource loadProperties(Resource path) { - Assert.isTrue(path.exists(), () -> "Resource " + path + " does not exist"); - try { - return this.loader.load("custom-resource", path).get(0); - } - catch (IOException ex) { - throw new IllegalStateException("Failed to load properties configuration from " + path, ex); - } - } - -} \ No newline at end of file diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/ProjectResourceSetConfiguration.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/ProjectResourceSetConfiguration.java deleted file mode 100644 index 5020736f7..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/ProjectResourceSetConfiguration.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.boot.autoconfigure; - -import org.openrewrite.ExecutionContext; -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.sbm.project.RewriteSourceFileWrapper; -import org.springframework.sbm.project.resource.ProjectResourceSerializer; -import org.springframework.sbm.project.resource.ProjectResourceSetFactory; -import org.springframework.sbm.project.resource.ProjectResourceSetSerializer; -import org.springframework.sbm.project.resource.RewriteMigrationResultMerger; - -/** - * @author Fabian Krüger - */ -@AutoConfiguration -public class ProjectResourceSetConfiguration { - @Bean - RewriteSourceFileWrapper rewriteSourceFileWrapper() { - return new RewriteSourceFileWrapper(); - } - - @Bean - RewriteMigrationResultMerger rewriteMigrationResultMerger(RewriteSourceFileWrapper rewriteSourceFileWrapper) { - return new RewriteMigrationResultMerger(rewriteSourceFileWrapper); - } - - @Bean - ProjectResourceSerializer projectResourceSerializer() { - return new ProjectResourceSerializer(); - } - - @Bean - ProjectResourceSetSerializer projectResourceSetSerializer(ProjectResourceSerializer resourceSerializer) { - return new ProjectResourceSetSerializer(resourceSerializer); - } - - @Bean - ProjectResourceSetFactory projectResourceSetFactory(RewriteMigrationResultMerger rewriteMigrationResultMerger, RewriteSourceFileWrapper sourceFileWrapper, ExecutionContext executionContext) { - return new ProjectResourceSetFactory(rewriteMigrationResultMerger, sourceFileWrapper, executionContext); - } - -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/SbmSupportRewriteConfiguration.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/SbmSupportRewriteConfiguration.java deleted file mode 100644 index 316109822..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/SbmSupportRewriteConfiguration.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.boot.autoconfigure; - -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.context.annotation.Import; - -/** - * @author Fabian Krüger - */ -@AutoConfiguration -@Import({DiscoveryConfiguration.class, ScannerConfiguration.class, ProjectResourceSetConfiguration.class}) -public class SbmSupportRewriteConfiguration { -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/ScannerConfiguration.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/ScannerConfiguration.java deleted file mode 100644 index 287d5c47c..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/ScannerConfiguration.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.boot.autoconfigure; - -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; -import org.springframework.core.io.ResourceLoader; -import org.springframework.sbm.parsers.ParserProperties; -import org.springframework.sbm.parsers.ProjectScanner; -import org.springframework.sbm.parsers.RewriteParserConfiguration; - -/** - * @author Fabian Krüger - */ -@AutoConfiguration(after = RewriteParserConfiguration.class) -@Import(RewriteParserConfiguration.class) -public class ScannerConfiguration { - @Bean - ProjectScanner projectScanner(ResourceLoader resourceLoader, ParserProperties parserProperties) { - return new ProjectScanner(resourceLoader, parserProperties); - } -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/ScopeConfiguration.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/ScopeConfiguration.java deleted file mode 100644 index 60e5ff889..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/boot/autoconfigure/ScopeConfiguration.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.boot.autoconfigure; - -import org.openrewrite.ExecutionContext; -import org.openrewrite.InMemoryExecutionContext; -import org.openrewrite.maven.cache.MavenPomCache; -import org.springframework.beans.factory.config.BeanFactoryPostProcessor; -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.sbm.scopes.ExecutionScope; -import org.springframework.sbm.scopes.ProjectMetadata; -import org.springframework.sbm.scopes.ScanScope; - -import java.util.function.Supplier; - -/** - * @author Fabian Krüger - */ -@AutoConfiguration -public class ScopeConfiguration { - - - @Bean - ExecutionScope executionScope() { - return new ExecutionScope(); - } - - @Bean - ScanScope scanScope() { - return new ScanScope(); - } - - /** - * Register {@link ScanScope} and {@link ExecutionScope}. - */ - @Bean - public static BeanFactoryPostProcessor beanFactoryPostProcessor(ExecutionScope executionScope, ScanScope scanScope) { - return beanFactory -> { - beanFactory.registerScope(ScanScope.SCOPE_NAME, scanScope); - beanFactory.registerScope(ExecutionScope.SCOPE_NAME, executionScope); - }; - } - - @Bean - @org.springframework.sbm.scopes.annotations.ScanScope - ProjectMetadata projectMetadata() { - return new ProjectMetadata(); - } - - @Bean - @ConditionalOnMissingBean(name = "executionContextSupplier") - Supplier executionContextSupplier() { - return () -> new InMemoryExecutionContext(t -> {throw new RuntimeException(t);}); - } - - @Bean - @org.springframework.sbm.scopes.annotations.ScanScope - ExecutionContext executionContext(ProjectMetadata projectMetadata, Supplier executionContextSupplier, MavenPomCache mavenPomCache) { - ExecutionContext executionContext = executionContextSupplier.get(); - return executionContext; - } - -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/JavaParserBuilder.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/JavaParserBuilder.java deleted file mode 100644 index b68be1340..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/JavaParserBuilder.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers; - -import lombok.Getter; -import lombok.Setter; -import org.openrewrite.ExecutionContext; -import org.openrewrite.java.JavaParser; -import org.openrewrite.java.internal.JavaTypeCache; - -import java.nio.charset.Charset; -import java.util.Collection; - -public class JavaParserBuilder extends JavaParser.Builder{ - - @Getter - @Setter - private JavaParser.Builder delegate = JavaParser.fromJavaVersion(); - - @Override - public JavaParser build() { - return delegate.build(); - } - - @Override - public JavaParser.Builder charset(Charset charset) { - return delegate.charset(charset); - } - - @Override - public JavaParser.Builder classpath(Collection classpath) { - return delegate.classpath(classpath); - } - - @Override - public JavaParser.Builder classpath(String... classpath) { - return delegate.classpath(classpath); - } - - @Override - public JavaParser.Builder classpathFromResources(ExecutionContext ctx, String... classpath) { - return delegate.classpathFromResources(ctx, classpath); - } - - @Override - public JavaParser.Builder classpath(byte[]... classpath) { - return delegate.classpath(classpath); - } - - @Override - public JavaParser.Builder logCompilationWarningsAndErrors(boolean logCompilationWarningsAndErrors) { - return delegate.logCompilationWarningsAndErrors(logCompilationWarningsAndErrors); - } - - @Override - public JavaParser.Builder typeCache(JavaTypeCache javaTypeCache) { - return delegate.typeCache(javaTypeCache); - } - - @Override - public JavaParser.Builder dependsOn(Collection collection) { - return delegate.dependsOn(collection); - } - - @Override - public JavaParser.Builder dependsOn(String... inputsAsStrings) { - return delegate.dependsOn(inputsAsStrings); - } - - @Override - public JavaParser.Builder styles(Iterable iterable) { - return delegate.styles(iterable); - } - - @Override - public String getDslName() { - return delegate.getDslName(); - } - - // -// public Supplier getSupplier() { -// return () -> builder; -// } -// -// @Override -// public JavaParser build() { -// if(builder == null) { -// builder = JavaParser.fromJavaVersion(); -// } -// return builder.build(); -// } -// -// @Override -// public JavaParser.Builder classpath(Collection classpath) { -// return delegate.classpath(classpath); -// } -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/ParserContext.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/ParserContext.java deleted file mode 100644 index 033673a17..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/ParserContext.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.openrewrite.xml.tree.Xml; -import org.springframework.core.io.Resource; -import org.springframework.sbm.parsers.maven.MavenProject; -import org.springframework.sbm.utils.ResourceUtil; - -import java.nio.file.Path; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * @author Fabian Krüger - */ -@RequiredArgsConstructor -public class ParserContext { - - private final Path baseDir; - @Getter - private final List resources; - @Getter - private final List sortedProjects; - @Getter - private Map pathDocumentMap; - - - - public List getActiveProfiles() { - // FIXME: Add support for Maven profiles - return List.of("default"); - } - - public Resource getMatchingBuildFileResource(MavenProject pom) { - return resources.stream() - .filter(r -> ResourceUtil.getPath(r).toString().equals(pom.getPomFilePath().toString())) - .findFirst() - .orElseThrow(() -> new IllegalStateException("Could not find a resource in the list of resources that matches the path of MavenProject '%s'".formatted(pom.getPomFile().toString()))); - } - - public List getBuildFileResources() { - return sortedProjects.stream() - .map(p -> p.getPomFile()) - .toList(); - } - - public Xml.Document getXmlDocument(Path path) { - return pathDocumentMap.get(path); - } - - public void setParsedBuildFiles(List xmlDocuments) { - this.pathDocumentMap = xmlDocuments.stream() - .peek(doc -> addSourceFileToModel(baseDir, getSortedProjects(), doc)) - .collect(Collectors.toMap(doc -> baseDir.resolve(doc.getSourcePath()), doc -> doc)); - } - - public List getSortedBuildFileDocuments() { - return getSortedProjects().stream().map(p -> pathDocumentMap.get(p.getFile().toPath())).toList(); - } - - private void addSourceFileToModel(Path baseDir, List sortedProjectsList, Xml.Document s) { - sortedProjectsList.stream() - .filter(p -> ResourceUtil.getPath(p.getPomFile()).toString().equals(baseDir.resolve(s.getSourcePath()).toString())) - .forEach(p -> p.setSourceFile(s)); - } - -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/ParserProperties.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/ParserProperties.java deleted file mode 100644 index 0d45e60f1..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/ParserProperties.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers; - -import lombok.Getter; -import lombok.Setter; -import org.springframework.boot.context.properties.ConfigurationProperties; - -import java.nio.file.Path; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * ConfigurationProperties with prefix {@code parser}. - * Defaults coming from {@code META-INF/sbm-support-rewrite.properties} - * - * @author Fabian Krüger - */ -@ConfigurationProperties(prefix = "parser") -@Getter -@Setter -public class ParserProperties { - - /** - * Whether to skip parsing maven pom files - */ - private boolean skipMavenParsing = false; - - /** - * Enable org.openrewrite.maven.cache.RocksdbMavenPomCache on 64-Bit system - */ - private boolean pomCacheEnabled = false; - - /** - * Directory used by RocksdbMavenPomCache when pomCacheEnabled is true - */ - private String pomCacheDirectory = Path.of(System.getProperty("user.home")).resolve(".rewrite-cache").toAbsolutePath().normalize().toString(); - - /** - * Comma-separated list of patterns used to create PathMatcher - * The pattern should not contain a leading 'glob:' - */ - private Set plainTextMasks = new HashSet<>(); - - /** - * Project resources exceeding this threshold will not be parsed and provided as org.openrewrite.quark.Quark - */ - private int sizeThresholdMb = -1; - - /** - * Whether only the current Maven module will be parsed - */ - private boolean runPerSubmodule = false; - - /** - * Whether the discovery should fail on invalid active recipes. - * TODO: Move to 'discovery' prefix - */ - private boolean failOnInvalidActiveRecipes = true; - - /** - * Comma-separated list of active Maven profiles - */ - private List activeProfiles = List.of("default"); - - /** - * Comma-separated list of patterns used to create PathMatcher to exclude paths from being parsed. - */ - private Set ignoredPathPatterns = Set.of("**/target/**", "target/**", "**/.idea/**", ".idea/**", "**/.git/**", ".git/**", ".mvn/**", "**/.mvn/**", "node_modules/**", "**/node_modules/**"); - -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/ProjectScanner.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/ProjectScanner.java deleted file mode 100644 index f5b688566..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/ProjectScanner.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.jetbrains.annotations.NotNull; -import org.springframework.core.io.Resource; -import org.springframework.core.io.ResourceLoader; -import org.springframework.core.io.support.ResourcePatternUtils; -import org.springframework.sbm.utils.LinuxWindowsPathUnifier; -import org.springframework.sbm.utils.ResourceUtil; - -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.PathMatcher; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * @author Fabian Krüger - */ -@Slf4j -@RequiredArgsConstructor -public class ProjectScanner { - private final ResourceLoader resourceLoader; - private final ParserProperties parserProperties; - - public List scan(Path baseDir) { - if(!baseDir.isAbsolute()) { - baseDir = baseDir.toAbsolutePath().normalize(); - } - if(!baseDir.toFile().exists()) { - throw new IllegalArgumentException("Provided path does not exist: " + baseDir); - } - Path absoluteRootPath = baseDir.toAbsolutePath(); - String unifiedPath = new LinuxWindowsPathUnifier().unifyPath(absoluteRootPath.toString() + "/**"); - String pattern = "file:" + unifiedPath; - try { - Resource[] resources = ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources(pattern); - - log.debug("Scanned %d resources in dir: '%s'".formatted(resources.length, absoluteRootPath.toString())); - - List resultingResources = filterIgnoredResources(absoluteRootPath, resources); - - int numResulting = resultingResources.size(); - int numIgnored = resources.length - numResulting; - log.debug("Scan returns %s resources, %d resources were ignored.".formatted(numResulting, numIgnored)); - log.trace("Resources resulting from scan: %s".formatted(resultingResources.stream().map(r -> absoluteRootPath.relativize(ResourceUtil.getPath(r)).toString()).collect(Collectors.joining(", ")))); - - return resultingResources; - } catch (IOException e) { - throw new RuntimeException("Can't get resources for pattern '" + pattern + "'", e); - } - } - - @NotNull - private List filterIgnoredResources(Path baseDir, Resource[] resources) { - Set effectivePathMatcherPatterns = new HashSet<>(); - List pathMatchers = parserProperties.getIgnoredPathPatterns().stream() - .map(p -> p.startsWith("glob:") ? p : "glob:" + p) - .peek(p -> effectivePathMatcherPatterns.add(p)) - .map(baseDir.getFileSystem()::getPathMatcher) - .toList(); - - log.trace("Ignore resources matching any of these PathMatchers: %s".formatted(effectivePathMatcherPatterns.stream().collect(Collectors.joining(", ")))); - - List resultingResources = Stream.of(resources) - .filter(r -> isAccepted(baseDir, r, pathMatchers)) - .toList(); - - if(resultingResources.isEmpty()) { - throw new IllegalArgumentException("No resources were scanned. Check directory and ignore patterns."); - } - - return resultingResources; - } - - private boolean isAccepted(Path baseDir, Resource r, List pathMatchers) { - if(ResourceUtil.getPath(r).toFile().isDirectory()) { - return false; - } - Optional isIgnored = pathMatchers - .stream() - .filter(matcher -> { - Path resourcePath = ResourceUtil.getPath(r); - boolean matches = matcher.matches(resourcePath); - return matches; - }) - .findFirst(); - if(isIgnored.isPresent() && log.isInfoEnabled()) { - Set ignoredPathPatterns = parserProperties.getIgnoredPathPatterns(); - log.info("Ignoring scanned resource '%s' given these path matchers: %s.".formatted(baseDir.relativize(ResourceUtil.getPath(r)), ignoredPathPatterns)); - } - return isIgnored.isEmpty(); - } -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteExecutionContext.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteExecutionContext.java deleted file mode 100644 index 466957d28..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteExecutionContext.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers; - -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import org.openrewrite.ExecutionContext; -import org.openrewrite.InMemoryExecutionContext; -import org.openrewrite.Recipe; -import org.openrewrite.internal.lang.Nullable; - -import java.util.Collection; -import java.util.Set; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.function.Supplier; - - -@Getter -@Slf4j -public class RewriteExecutionContext implements ExecutionContext { - - - private ExecutionContext delegate; - - public RewriteExecutionContext(Consumer onError) { - this(new InMemoryExecutionContext(onError)); - } - - public RewriteExecutionContext() { - this(new InMemoryExecutionContext(new RewriteExecutionContextErrorHandler(new RewriteExecutionContextErrorHandler.ThrowExceptionSwitch()))); - } - - public RewriteExecutionContext(ExecutionContext delegate) { - this.delegate = delegate; - } - - @Override - public void putMessage(String key, @Nullable Object value) { - delegate.putMessage(key, value); - } - - @Override - public @Nullable T getMessage(String key) { - return delegate.getMessage(key); - } - - @Override - public > C putMessageInCollection(String key, V value, Supplier newCollection) { - return delegate.putMessageInCollection(key, value, newCollection); - } - - @Override - public Set putMessageInSet(String key, T value) { - return delegate.putMessageInSet(key, value); - } - - @Override - public @Nullable T pollMessage(String key) { - return delegate.pollMessage(key); - } - - @Override - public T pollMessage(String key, T defaultValue) { - return delegate.pollMessage(key, defaultValue); - } - - @Override - public void putCurrentRecipe(Recipe recipe) { - delegate.putCurrentRecipe(recipe); - } - - @Override - public Consumer getOnError() { - return delegate.getOnError(); - } - - @Override - public BiConsumer getOnTimeout() { - return delegate.getOnTimeout(); - } - -} - - diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteExecutionContextErrorHandler.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteExecutionContextErrorHandler.java deleted file mode 100644 index b8a7aea5f..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteExecutionContextErrorHandler.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers; - -import lombok.Getter; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import org.openrewrite.java.JavaParsingException; -import org.openrewrite.maven.MavenDownloadingException; -import org.openrewrite.maven.internal.MavenParsingException; - -import java.util.function.Consumer; - -@Slf4j -public class RewriteExecutionContextErrorHandler implements Consumer { - - private final ThrowExceptionSwitch throwExceptionSwitch; - - RewriteExecutionContextErrorHandler(ThrowExceptionSwitch throwExceptionSwitch) { - this.throwExceptionSwitch = throwExceptionSwitch; - } - - @Override - public void accept(Throwable t) { - if (t instanceof MavenParsingException) { - log.warn(t.getMessage()); - } else if(t instanceof MavenDownloadingException) { - log.warn(t.getMessage()); - } else if(t instanceof JavaParsingException) { - if(t.getMessage().equals("Failed symbol entering or attribution")) { - throw new RuntimeException("This could be a broken jar. Activate logging on WARN level for 'org.openrewrite' might reveal more information.", t); - } - } else { - throw new RuntimeException(t.getMessage(), t); - } - } - - @Getter - @Setter - public static class ThrowExceptionSwitch { - private boolean throwExceptions = true; - } -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteParserConfiguration.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteParserConfiguration.java deleted file mode 100644 index 9a4466623..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteParserConfiguration.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers; - -import lombok.extern.slf4j.Slf4j; -import org.openrewrite.ExecutionContext; -import org.openrewrite.maven.cache.*; -import org.openrewrite.maven.utilities.MavenArtifactDownloader; -import org.openrewrite.tree.ParsingEventListener; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; -import org.springframework.sbm.boot.autoconfigure.ParserPropertiesPostProcessor; -import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration; -import org.springframework.sbm.parsers.events.RewriteParsingEventListenerAdapter; -import org.springframework.sbm.parsers.maven.*; -import org.springframework.sbm.project.resource.SbmApplicationProperties; -import org.springframework.sbm.scopes.ScanScope; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.nio.file.Path; -import java.util.function.Consumer; - - -/** - * Module configuration. - * - * @author Fabian Krüger - */ -@Slf4j -@AutoConfiguration(after = {ScopeConfiguration.class}) -@EnableConfigurationProperties({ParserProperties.class, SbmApplicationProperties.class}) -@Import({ScanScope.class, ScopeConfiguration.class, RewriteParserMavenConfiguration.class}) -public class RewriteParserConfiguration { - - @Bean - ProvenanceMarkerFactory provenanceMarkerFactory(MavenProvenanceMarkerFactory mavenPovenanceMarkerFactory) { - return new ProvenanceMarkerFactory(mavenPovenanceMarkerFactory); - } - - @Bean - @org.springframework.sbm.scopes.annotations.ScanScope - JavaParserBuilder javaParserBuilder() { - return new JavaParserBuilder(); - } - - @Bean - Consumer artifactDownloaderErrorConsumer() { - return (t) -> {throw new RuntimeException(t);}; - } - - @Bean - MavenModuleParser mavenModuleParser(ParserProperties parserProperties) { - return new MavenModuleParser(parserProperties); - } - - @Bean - SourceFileParser sourceFileParser(MavenModuleParser mavenModuleParser) { - return new SourceFileParser(mavenModuleParser); - } - - @Bean - StyleDetector styleDetector() { - return new StyleDetector(); - } - - @Bean - @ConditionalOnMissingBean(ParsingEventListener.class) - ParsingEventListener parsingEventListener(ApplicationEventPublisher eventPublisher) { - return new RewriteParsingEventListenerAdapter(eventPublisher); - } - - // FIXME: 945 -// @Bean -// RewriteMavenProjectParser rewriteMavenProjectParser(MavenPlexusContainer plexusContainer, ParsingEventListener parsingListener, MavenExecutor mavenExecutor, MavenMojoProjectParserFactory projectParserFactory, ScanScope scanScope, ConfigurableListableBeanFactory beanFactory, ExecutionContext executionContext) { -// return new RewriteMavenProjectParser( -// plexusContainer, -// parsingListener, -// mavenExecutor, -// projectParserFactory, -// scanScope, -// beanFactory, -// executionContext); -// } - - @Bean - MavenProjectAnalyzer mavenProjectAnalyzer(MavenArtifactDownloader artifactDownloader) { - return new MavenProjectAnalyzer(artifactDownloader); - } - - @Bean - RewriteProjectParser rewriteProjectParser( - ProvenanceMarkerFactory provenanceMarkerFactory, - BuildFileParser buildFileParser, - SourceFileParser sourceFileParser, - StyleDetector styleDetector, - ParserProperties parserProperties, - ParsingEventListener parsingEventListener, - ApplicationEventPublisher eventPublisher, - ScanScope scanScope, - ConfigurableListableBeanFactory beanFactory, - ProjectScanner projectScanner, - ExecutionContext executionContext, - MavenProjectAnalyzer mavenProjectAnalyzer) { - return new RewriteProjectParser( - provenanceMarkerFactory, - buildFileParser, - sourceFileParser, - styleDetector, - parserProperties, - parsingEventListener, - eventPublisher, - scanScope, - beanFactory, - projectScanner, - executionContext, - mavenProjectAnalyzer); - } - - @Bean - ParserPropertiesPostProcessor parserPropertiesPostProcessor() { - return new ParserPropertiesPostProcessor(); - } - - @Bean - @ConditionalOnMissingBean(MavenPomCache.class) - MavenPomCache mavenPomCache(ParserProperties parserProperties) { - MavenPomCache mavenPomCache = new InMemoryMavenPomCache(); - if (parserProperties.isPomCacheEnabled()) { - if (!"64".equals(System.getProperty("sun.arch.data.model", "64"))) { - log.warn("parser.isPomCacheEnabled was set to true but RocksdbMavenPomCache is not supported on 32-bit JVM. falling back to InMemoryMavenPomCache"); - } else { - try { - mavenPomCache = new CompositeMavenPomCache( - new InMemoryMavenPomCache(), - new RocksdbMavenPomCache(Path.of(parserProperties.getPomCacheDirectory())) - ); - } catch (Exception e) { - log.warn("Unable to initialize RocksdbMavenPomCache, falling back to InMemoryMavenPomCache"); - if (log.isDebugEnabled()) { - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); - String exceptionAsString = sw.toString(); - log.debug(exceptionAsString); - } - } - } - } - return mavenPomCache; - } -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteProjectParser.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteProjectParser.java deleted file mode 100644 index 31f52e867..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteProjectParser.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.jetbrains.annotations.NotNull; -import org.openrewrite.ExecutionContext; -import org.openrewrite.SourceFile; -import org.openrewrite.marker.Marker; -import org.openrewrite.maven.MavenExecutionContextView; -import org.openrewrite.maven.MavenSettings; -import org.openrewrite.style.NamedStyles; -import org.openrewrite.tree.ParsingEventListener; -import org.openrewrite.tree.ParsingExecutionContextView; -import org.openrewrite.xml.tree.Xml; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.core.io.Resource; -import org.springframework.sbm.parsers.events.StartedParsingProjectEvent; -import org.springframework.sbm.parsers.events.SuccessfullyParsedProjectEvent; -import org.springframework.sbm.parsers.maven.BuildFileParser; -import org.springframework.sbm.parsers.maven.MavenProjectAnalyzer; -import org.springframework.sbm.parsers.maven.ProvenanceMarkerFactory; -import org.springframework.sbm.scopes.ScanScope; - -import java.net.URI; -import java.nio.charset.Charset; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * Project parser parsing resources under a given {@link Path} to OpenRewrite abstract syntax tree (AST). - * The implementation aims to produce the exact same result as the build tool plugins provided by OpenRewrite. - * The AST is provided as {@code List<}{@link SourceFile}{@code >}. - * - *

- * This dummy code shows how the AST can be used to run OpenRewrite recipes: - * - *

{@code
- *  Path projectBaseDir = ...
- *  RewriteProjectParser parser = ...
- *  RewriteRecipeDiscovery discovery = ...
- *  RewriteProjectParsingResult parsingResult = parser.parse(projectBaseDir);
- *  List ast = parsingResult.sourceFiles();
- *  ExecutionContext ctx = parsingResult.executionContext();
- *  List recipes = discovery.discoverRecipes();
- *  RecipeRun recipeRun = recipes.get(0).run(ast, ctx);
- *  }
- * 
- * - * @author Fabian Krüger - * @see org.springframework.sbm.recipes.RewriteRecipeDiscovery - */ -@Slf4j -@RequiredArgsConstructor -public class RewriteProjectParser { - - private final ProvenanceMarkerFactory provenanceMarkerFactory; - private final BuildFileParser buildFileParser; - private final SourceFileParser sourceFileParser; - private final StyleDetector styleDetector; - private final ParserProperties parserProperties; - private final ParsingEventListener parsingEventListener; - private final ApplicationEventPublisher eventPublisher; - private final ScanScope scanScope; - private final ConfigurableListableBeanFactory beanFactory; - private final ProjectScanner scanner; - private final ExecutionContext executionContext; - private final MavenProjectAnalyzer mavenProjectAnalyzer; - - - /** - * Parse the given {@code baseDir} to OpenRewrite AST. - */ - public RewriteProjectParsingResult parse(Path baseDir) { - List resources = scanner.scan(baseDir); - return this.parse(baseDir, resources); - } - - /** - * Parse given {@link Resource}s in {@code baseDir} to OpenRewrite AST representation. - */ - public RewriteProjectParsingResult parse(Path givenBaseDir, List resources) { - scanScope.clear(beanFactory); - - final Path baseDir = normalizePath(givenBaseDir); - - eventPublisher.publishEvent(new StartedParsingProjectEvent(resources)); - - ParsingExecutionContextView.view(executionContext).setParsingListener(parsingEventListener); - - // TODO: "runPerSubmodule" - // TODO: See ConfigurableRewriteMojo#getPlainTextMasks() - // TODO: where to retrieve styles from? --> see AbstractRewriteMojo#getActiveStyles() & AbstractRewriteMojo#loadStyles() - List styles = List.of(); - - // Get the ordered otherSourceFiles of projects - ParserContext parserContext = mavenProjectAnalyzer.createParserContext(baseDir, resources); - - // generate provenance - Map> provenanceMarkers = provenanceMarkerFactory.generateProvenanceMarkers(baseDir, parserContext); - - // 127: parse build files - // TODO: 945 this map is only used to lookup module pom by path in SourceFileParser. If possible provide the build file from ParserContext and remove this map. - List parsedBuildFiles = buildFileParser.parseBuildFiles(baseDir, parserContext.getBuildFileResources(), parserContext.getActiveProfiles(), executionContext, parserProperties.isSkipMavenParsing(), provenanceMarkers); - parserContext.setParsedBuildFiles(parsedBuildFiles); - - log.trace("Start to parse %d source files in %d modules".formatted(resources.size() + parsedBuildFiles.size(), parsedBuildFiles.size())); - List otherSourceFiles = sourceFileParser.parseOtherSourceFiles(baseDir, parserContext, resources, provenanceMarkers, styles, executionContext); - - List sortedBuildFileDocuments = parserContext.getSortedBuildFileDocuments(); - - List resultingList = new ArrayList<>(); - resultingList.addAll(sortedBuildFileDocuments); - resultingList.addAll(otherSourceFiles); - List sourceFiles = styleDetector.sourcesWithAutoDetectedStyles(resultingList.stream()); - - eventPublisher.publishEvent(new SuccessfullyParsedProjectEvent(sourceFiles)); - - return new RewriteProjectParsingResult(sourceFiles, executionContext); - } - - @NotNull - private static Path normalizePath(Path givenBaseDir) { - if (!givenBaseDir.isAbsolute()) { - givenBaseDir = givenBaseDir.toAbsolutePath().normalize(); - } - final Path baseDir = givenBaseDir; - return baseDir; - } - -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteProjectParsingResult.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteProjectParsingResult.java deleted file mode 100644 index 4c5350949..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteProjectParsingResult.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers; - -import org.openrewrite.ExecutionContext; -import org.openrewrite.SourceFile; - -import java.util.List; - -/** - * @author Fabian Krüger - */ -public record RewriteProjectParsingResult(List sourceFiles, ExecutionContext executionContext) { -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteResourceParser.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteResourceParser.java deleted file mode 100644 index 6d7e91c8f..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/RewriteResourceParser.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers; - -import lombok.extern.slf4j.Slf4j; -import org.jetbrains.annotations.NotNull; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Parser; -import org.openrewrite.SourceFile; -import org.openrewrite.hcl.HclParser; -import org.openrewrite.java.JavaParser; -import org.openrewrite.json.JsonParser; -import org.openrewrite.properties.PropertiesParser; -import org.openrewrite.protobuf.ProtoParser; -import org.openrewrite.quark.QuarkParser; -import org.openrewrite.text.PlainTextParser; -import org.openrewrite.xml.XmlParser; -import org.openrewrite.yaml.YamlParser; -import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.Resource; -import org.springframework.sbm.utils.ResourceUtil; - -import java.nio.file.Path; -import java.nio.file.PathMatcher; -import java.nio.file.Paths; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * Code from https://github.com/fabapp2/rewrite-maven-plugin/blob/83d184ea9ffe3046429f16c91aa56a9610bae832/src/main/java/org/openrewrite/maven/ResourceParser.java - * The motivation was to decouple the parser from file access. - */ -@Slf4j -public class RewriteResourceParser { - private static final Set DEFAULT_IGNORED_DIRECTORIES = new HashSet<>(Arrays.asList("build", "target", "out", ".sonar", ".gradle", ".idea", ".project", "node_modules", ".git", ".metadata", ".DS_Store")); - - private final Path baseDir; - private final Collection exclusions; - private final int sizeThresholdMb; - private final Collection excludedDirectories; - private final Collection plainTextMasks; - - /** - * Sometimes java files will exist in the src/main/resources directory. For example, Drools: - */ - private final JavaParser.Builder javaParserBuilder; - private final ExecutionContext executionContext; - - public RewriteResourceParser( - Path baseDir, - Collection exclusions, - Collection plainTextMasks, - int sizeThresholdMb, - Collection excludedDirectories, - JavaParser.Builder javaParserBuilder, - ExecutionContext executionContext - ) { - this.baseDir = baseDir; - this.javaParserBuilder = javaParserBuilder; - this.executionContext = executionContext; - this.exclusions = pathMatchers(baseDir, exclusions); - this.sizeThresholdMb = sizeThresholdMb; - this.excludedDirectories = excludedDirectories; - this.plainTextMasks = pathMatchers(baseDir, plainTextMasks); - } - - private Collection pathMatchers(Path basePath, Collection pathExpressions) { - return pathExpressions.stream() - .map(o -> basePath.getFileSystem().getPathMatcher("glob:" + o)) - .collect(Collectors.toList()); - } - - public Stream parse(Path searchDir, List resources, Set alreadyParsed) { - // TODO: 945 remove/clean this up - List resourcesLeft = resources.stream() - .filter(r -> alreadyParsed.stream().noneMatch(path -> ResourceUtil.getPath(r).toString().startsWith(path.toString()))) - .toList(); - return this.parseSourceFiles(searchDir, resourcesLeft, alreadyParsed, executionContext); - - -// -// Stream sourceFiles = Stream.empty(); -// if (!searchDir.toFile().exists()) { -// return sourceFiles; -// } else { -// Consumer errorConsumer = (t) -> { -// this.logger.debug("Error parsing", t); -// }; -// InMemoryExecutionContext ctx = new InMemoryExecutionContext(errorConsumer); -// -// try { -// sourceFiles = Stream.concat(sourceFiles, this.parseSourceFiles(searchDir, alreadyParsed, ctx)); -// return sourceFiles; -// } catch (IOException var7) { -// this.logger.error(var7.getMessage(), var7); -// throw new UncheckedIOException(var7); -// } -// } - } - - @SuppressWarnings({"DuplicatedCode", "unchecked"}) - public Stream parseSourceFiles( - Path searchDir, - List resources, - Set alreadyParsed, - ExecutionContext ctx) { - - List resourcesLeft = new ArrayList<>(); - List quarkPaths = new ArrayList<>(); - List plainTextPaths = new ArrayList<>(); - - List filteredResources = resources - .stream() - .filter(r -> ResourceUtil.getPath(r).toString().startsWith(searchDir.toString())) - .toList(); - - filteredResources.forEach(resource -> { - Path file = ResourceUtil.getPath(resource); - Path dir = file.getParent(); - if (isExcluded(dir) || isIgnoredDirectory(searchDir, dir) || excludedDirectories.contains(dir) || alreadyParsed.contains(new FileSystemResource(dir)) || alreadyParsed.contains(resource)) { - return; - } else { - // FIXME: 945 only check threshold if value > 0 is given - long fileSize = ResourceUtil.contentLength(resource); - if (isOverSizeThreshold(fileSize)) { - log.info("Parsing as quark " + file + " as its size " + fileSize / (1024L * 1024L) + - "Mb exceeds size threshold " + sizeThresholdMb + "Mb"); - quarkPaths.add(file); - } else if (isParsedAsPlainText(file)) { - plainTextPaths.add(file); - } else { - resourcesLeft.add(file); - } - } - }); - - Stream sourceFiles = Stream.empty(); - - JavaParser javaParser = javaParserBuilder.build(); - List javaPaths = new ArrayList<>(); - - JsonParser jsonParser = new JsonParser(); - List jsonPaths = new ArrayList<>(); - - XmlParser xmlParser = new XmlParser(); - List xmlPaths = new ArrayList<>(); - - YamlParser yamlParser = new YamlParser(); - List yamlPaths = new ArrayList<>(); - - PropertiesParser propertiesParser = new PropertiesParser(); - List propertiesPaths = new ArrayList<>(); - - ProtoParser protoParser = new ProtoParser(); - List protoPaths = new ArrayList<>(); - - // Python currently not supported -// PythonParser pythonParser = PythonParser.builder().build(); -// List pythonPaths = new ArrayList<>(); - - HclParser hclParser = HclParser.builder().build(); - List hclPaths = new ArrayList<>(); - - PlainTextParser plainTextParser = new PlainTextParser(); - - QuarkParser quarkParser = new QuarkParser(); - - filteredResources - .forEach(resource -> { - // See https://github.com/quarkusio/quarkus/blob/main/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/resteasy-reactive-codestart/java/src/main/java/org/acme/%7Bresource.class-name%7D.tpl.qute.java - // for an example of why we don't want qute files be parsed as java - Path path = ResourceUtil.getPath(resource); -// if (javaParser.accept(path) && !path.toString().endsWith(".qute.java")) { -// javaPaths.add(path); -// } - if (jsonParser.accept(path)) { - jsonPaths.add(path); - } else if (xmlParser.accept(path)) { - xmlPaths.add(path); - } else if (yamlParser.accept(path)) { - yamlPaths.add(path); - } else if (propertiesParser.accept(path)) { - propertiesPaths.add(path); - } else if (protoParser.accept(path)) { - protoPaths.add(path); - } /*else if(pythonParser.accept(path)) { - pythonPaths.add(path); - }*/ else if (hclParser.accept(path)) { - hclPaths.add(path); - } else if (quarkParser.accept(path)) { - quarkPaths.add(path); - } - }); - - Map pathToResource = filteredResources.stream().collect(Collectors.toMap(r -> ResourceUtil.getPath(r), r -> r)); - - if (!javaPaths.isEmpty()) { - List inputs = getInputs(pathToResource, javaPaths); - sourceFiles = Stream.concat(sourceFiles, (Stream) javaParser.parseInputs(inputs, baseDir, ctx)); - alreadyParsed.addAll(javaPaths); - } - - if (!jsonPaths.isEmpty()) { - List inputs = getInputs(pathToResource, jsonPaths); - sourceFiles = Stream.concat(sourceFiles, (Stream) jsonParser.parseInputs(inputs, baseDir, ctx)); - alreadyParsed.addAll(jsonPaths); - } - - if (!xmlPaths.isEmpty()) { - List inputs = getInputs(pathToResource, xmlPaths); - sourceFiles = Stream.concat(sourceFiles, (Stream) xmlParser.parseInputs(inputs, baseDir, ctx)); - alreadyParsed.addAll(xmlPaths); - } - - if (!yamlPaths.isEmpty()) { - List inputs = getInputs(pathToResource, yamlPaths); - sourceFiles = Stream.concat(sourceFiles, (Stream) yamlParser.parseInputs(inputs, baseDir, ctx)); - alreadyParsed.addAll(yamlPaths); - } - - if (!propertiesPaths.isEmpty()) { - List inputs = getInputs(pathToResource, propertiesPaths); - sourceFiles = Stream.concat(sourceFiles, (Stream) propertiesParser.parseInputs(inputs, baseDir, ctx)); - alreadyParsed.addAll(propertiesPaths); - } - - if (!protoPaths.isEmpty()) { - List inputs = getInputs(pathToResource, protoPaths); - sourceFiles = Stream.concat(sourceFiles, (Stream) protoParser.parseInputs(inputs, baseDir, ctx)); - alreadyParsed.addAll(protoPaths); - } - -// if (!pythonPaths.isEmpty()) { -// List inputs = getInputs(pathToResource, pythonPaths); -// sourceFiles = Stream.concat(sourceFiles, (Stream) pythonParser.parseInputs(inputs, baseDir, ctx)); -// alreadyParsed.addAll(pythonPaths); -// } - - if (!hclPaths.isEmpty()) { - List inputs = getInputs(pathToResource, hclPaths); - sourceFiles = Stream.concat(sourceFiles, (Stream) hclParser.parseInputs(inputs, baseDir, ctx)); - alreadyParsed.addAll(hclPaths); - } - - if (!plainTextPaths.isEmpty()) { - List inputs = getInputs(pathToResource, plainTextPaths); - sourceFiles = Stream.concat(sourceFiles, (Stream) plainTextParser.parseInputs(inputs, baseDir, ctx)); - alreadyParsed.addAll(plainTextPaths); - } - - if (!quarkPaths.isEmpty()) { - List inputs = getInputs(pathToResource, quarkPaths); - sourceFiles = Stream.concat(sourceFiles, (Stream) quarkParser.parseInputs(inputs, baseDir, ctx)); - alreadyParsed.addAll(quarkPaths); - } - - return sourceFiles; - } - - @NotNull - private static List getInputs(Map pathResourceMap, List paths) { - return paths.stream() - .map(path -> new Parser.Input(path, () -> ResourceUtil.getInputStream(pathResourceMap.get(path)))).toList(); - } - - private boolean isOverSizeThreshold(long fileSize) { - return sizeThresholdMb > 0 && fileSize > sizeThresholdMb * 1024L * 1024L; - } - - private boolean isExcluded(Path path) { - if (!exclusions.isEmpty()) { - for (PathMatcher excluded : exclusions) { - if (excluded.matches(baseDir.relativize(path))) { - return true; - } - } - } - return false; - } - - private boolean isParsedAsPlainText(Path path) { - if (!plainTextMasks.isEmpty()) { - Path computed = baseDir.relativize(path); - if (!computed.startsWith("/")) { - computed = Paths.get("/").resolve(computed); - } - for (PathMatcher matcher : plainTextMasks) { - if (matcher.matches(computed)) { - return true; - } - } - } - return false; - } - - private boolean isIgnoredDirectory(Path searchDir, Path path) { - for (Path pathSegment : searchDir.relativize(path)) { - if (DEFAULT_IGNORED_DIRECTORIES.contains(pathSegment.toString())) { - return true; - } - } - return false; - } -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/SourceFileParser.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/SourceFileParser.java deleted file mode 100644 index ec573f7a5..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/SourceFileParser.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.openrewrite.ExecutionContext; -import org.openrewrite.SourceFile; -import org.openrewrite.marker.Marker; -import org.openrewrite.style.NamedStyles; -import org.openrewrite.xml.tree.Xml; -import org.springframework.core.io.Resource; -import org.springframework.sbm.parsers.maven.MavenModuleParser; - -import java.nio.file.Path; -import java.util.*; - -/** - * @author Fabian Krüger - */ -@Slf4j - -@RequiredArgsConstructor -public class SourceFileParser { - - private final MavenModuleParser moduleParser; - - public List parseOtherSourceFiles( - Path baseDir, - ParserContext parserContext, - List resources, - Map> provenanceMarkers, - List styles, - ExecutionContext executionContext) { - - Set parsedSourceFiles = new LinkedHashSet<>(); - - parserContext.getSortedProjects().forEach(currentMavenProject -> { - Xml.Document moduleBuildFile = currentMavenProject.getSourceFile(); - List markers = provenanceMarkers.get(currentMavenProject.getPomFilePath()); - if(markers == null || markers.isEmpty()) { - log.warn("Could not find provenance markers for resource '%s'".formatted(parserContext.getMatchingBuildFileResource(currentMavenProject))); - } - List sourceFiles = moduleParser.parseModuleSourceFiles(resources, currentMavenProject, moduleBuildFile, markers, styles, executionContext, baseDir); - parsedSourceFiles.addAll(sourceFiles); - }); - - return new ArrayList<>(parsedSourceFiles); - } -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/SourceSetParsingResult.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/SourceSetParsingResult.java deleted file mode 100644 index cba9db43b..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/SourceSetParsingResult.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers; - -import org.openrewrite.SourceFile; -import org.openrewrite.java.tree.JavaType; - -import java.util.List; - -/** - * @author Fabian Krüger - */ -public record SourceSetParsingResult(List sourceFiles, List classpath) { -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/StyleDetector.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/StyleDetector.java deleted file mode 100644 index 6b51bf0b4..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/StyleDetector.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers; - -import org.openrewrite.SourceFile; -import org.openrewrite.Tree; -import org.openrewrite.internal.ListUtils; -import org.openrewrite.java.tree.JavaSourceFile; -import org.openrewrite.marker.Marker; -import org.openrewrite.style.NamedStyles; -import org.openrewrite.xml.tree.Xml; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.function.UnaryOperator; -import java.util.stream.Stream; - -/** - * @author Fabian Krüger - */ - -public class StyleDetector { - - List sourcesWithAutoDetectedStyles(Stream sourceFiles) { - org.openrewrite.java.style.Autodetect.Detector javaDetector = org.openrewrite.java.style.Autodetect.detector(); - org.openrewrite.xml.style.Autodetect.Detector xmlDetector = org.openrewrite.xml.style.Autodetect.detector(); - List sourceFileList = sourceFiles - .peek(javaDetector::sample) - .peek(xmlDetector::sample) - .toList(); - - Map, NamedStyles> stylesByType = new HashMap<>(); - stylesByType.put(JavaSourceFile.class, javaDetector.build()); - stylesByType.put(Xml.Document.class, xmlDetector.build()); - - return ListUtils.map(sourceFileList, applyAutodetectedStyle(stylesByType)); - } - - private UnaryOperator applyAutodetectedStyle(Map, NamedStyles> stylesByType) { - return (before) -> { - Iterator var2 = stylesByType.entrySet().iterator(); - - while(var2.hasNext()) { - Map.Entry, NamedStyles> styleTypeEntry = (Map.Entry)var2.next(); - if (((Class)styleTypeEntry.getKey()).isAssignableFrom(before.getClass())) { - before = (SourceFile)before.withMarkers(before.getMarkers().add((Marker)styleTypeEntry.getValue())); - } - } - - return before; - }; - } - -// public List sourcesWithAutoDetectedStyles(Stream sourceFilesStream) { -// OpenedRewriteMojo m = new OpenedRewriteMojo(); -// Method method = ReflectionUtils.findMethod(OpenedRewriteMojo.class, "sourcesWithAutoDetectedStyles", Stream.class); -// ReflectionUtils.makeAccessible(method); -// return (List) ReflectionUtils.invokeMethod(method, m, sourceFilesStream); -// } -// -// static class OpenedRewriteMojo extends AbstractRewriteMojo { -// -// @Override -// public void execute() throws MojoExecutionException, MojoFailureException { -// throw new UnsupportedOperationException(); -// } -// } -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/FinishedParsingResourceEvent.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/FinishedParsingResourceEvent.java deleted file mode 100644 index 65135eef2..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/FinishedParsingResourceEvent.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers.events; - -import org.openrewrite.Parser; -import org.openrewrite.SourceFile; - -/** - * @author Fabian Krüger - */ -public record FinishedParsingResourceEvent(Parser.Input input, SourceFile sourceFile){ -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/IntermediateParsingEvent.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/IntermediateParsingEvent.java deleted file mode 100644 index 8a2b036b5..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/IntermediateParsingEvent.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.sbm.parsers.events; - -/** - * @author Fabian Krüger - */ -public record IntermediateParsingEvent(String stateMessage) { -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/RewriteParsingEventListenerAdapter.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/RewriteParsingEventListenerAdapter.java deleted file mode 100644 index 923194440..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/RewriteParsingEventListenerAdapter.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers.events; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.openrewrite.Parser; -import org.openrewrite.SourceFile; -import org.openrewrite.tree.ParsingEventListener; -import org.springframework.context.ApplicationEventPublisher; - -/** - * Adapter listening to OpenRewrite ParsingEvents and publishing them as Spring application events. - * - * @author Fabian Krüger - */ -@Slf4j -@RequiredArgsConstructor -public class RewriteParsingEventListenerAdapter implements ParsingEventListener { - - private final ApplicationEventPublisher eventPublisher; - - @Override - public void intermediateMessage(String stateMessage) { - eventPublisher.publishEvent(new IntermediateParsingEvent(stateMessage)); - } - - @Override - public void startedParsing(Parser.Input input) { - eventPublisher.publishEvent(new StartedParsingResourceEvent(input)); - } - - @Override - public void parsed(Parser.Input input, SourceFile sourceFile) { - log.debug("Parsed %s to %s".formatted(input.getPath(), sourceFile.getSourcePath())); - eventPublisher.publishEvent(new FinishedParsingResourceEvent(input, sourceFile)); - } -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/StartedParsingProjectEvent.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/StartedParsingProjectEvent.java deleted file mode 100644 index d91d2fe77..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/StartedParsingProjectEvent.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers.events; - -import org.springframework.core.io.Resource; - -import java.util.List; - -/** - * @author Fabian Krüger - */ -public record StartedParsingProjectEvent(List resources) { -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/StartedParsingResourceEvent.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/StartedParsingResourceEvent.java deleted file mode 100644 index ac3d4db9f..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/StartedParsingResourceEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers.events; - -import org.openrewrite.Parser; - -/** - * @author Fabian Krüger - */ -public record StartedParsingResourceEvent(Parser.Input input){ -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/SuccessfullyParsedProjectEvent.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/SuccessfullyParsedProjectEvent.java deleted file mode 100644 index 3866603be..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/events/SuccessfullyParsedProjectEvent.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers.events; - -import org.openrewrite.SourceFile; - -import java.util.List; - -/** - * @author Fabian Krüger - */ -public record SuccessfullyParsedProjectEvent(List sourceFiles) { -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/maven/BuildFileParser.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/maven/BuildFileParser.java deleted file mode 100644 index 82f84440a..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/maven/BuildFileParser.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers.maven; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Parser; -import org.openrewrite.SourceFile; -import org.openrewrite.marker.Marker; -import org.openrewrite.maven.MavenParser; -import org.openrewrite.xml.tree.Xml; -import org.springframework.core.io.Resource; -import org.springframework.sbm.utils.ResourceUtil; -import org.springframework.util.Assert; - -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static java.util.Collections.emptyList; - -/** - * Copies behaviour from rewrite-maven-plugin:5.2.2 - * - * @author Fabian Krüger - */ -@Slf4j -@RequiredArgsConstructor -public class BuildFileParser { - - private final MavenSettingsInitializer mavenSettingsInitilizer; - - /** - * Parse a list of Maven Pom files to a {@code List} of {@link Xml.Document}s. - * The {@link Xml.Document}s get marked with {@link org.openrewrite.maven.tree.MavenResolutionResult} and the provided provenance markers. - * - * @param baseDir the {@link Path} to the root of the scanned project - * @param buildFiles the list of resources for relevant pom files. - * @param activeProfiles the active Maven profiles - * @param executionContext the ExecutionContext to use - * @param skipMavenParsing skip parsing Maven files - * @param provenanceMarkers the map of markers to be added - */ - public List parseBuildFiles( - Path baseDir, - List buildFiles, - List activeProfiles, - ExecutionContext executionContext, - boolean skipMavenParsing, - Map> provenanceMarkers - ) { - Assert.notNull(baseDir, "Base directory must be provided but was null."); - Assert.notEmpty(buildFiles, "No build files provided."); - List nonPomFiles = retrieveNonPomFiles(buildFiles); - Assert.isTrue(nonPomFiles.isEmpty(), "Provided resources which are not Maven build files: '%s'".formatted(nonPomFiles.stream().map(r -> ResourceUtil.getPath(r).toAbsolutePath()).toList())); - List resourcesWithoutProvenanceMarker = findResourcesWithoutProvenanceMarker(baseDir, buildFiles, provenanceMarkers); - Assert.isTrue(resourcesWithoutProvenanceMarker.isEmpty(), "No provenance marker provided for these pom files %s".formatted(resourcesWithoutProvenanceMarker.stream().map(r -> ResourceUtil.getPath(r).toAbsolutePath()).toList())); - - if(skipMavenParsing) { - log.info("Maven parsing skipped [parser.skipMavenParsing=true]."); - return List.of(); - } - - // 380 : 382 - // already -// List upstreamPoms = collectUpstreamPomFiles(pomFiles); -// pomFiles.addAll(upstreamPoms); - - // 383 - MavenParser.Builder mavenParserBuilder = MavenParser.builder().mavenConfig(baseDir.resolve(".mvn/maven.config")); - - // 385 : 387 - mavenSettingsInitilizer.initializeMavenSettings(); - - // 395 : 398 - mavenParserBuilder.activeProfiles(activeProfiles.toArray(new String[]{})); - - // 400 : 402 - List parsedPoms = parsePoms(baseDir, buildFiles, mavenParserBuilder, executionContext) - .map(pp -> this.markPomFile(pp, provenanceMarkers.getOrDefault(baseDir.resolve(pp.getSourcePath()), emptyList()))) - .toList(); - - return parsedPoms; - } - - private List findResourcesWithoutProvenanceMarker(Path baseDir, List buildFileResources, Map> provenanceMarkers) { - return buildFileResources.stream() - .filter(r -> !provenanceMarkers.containsKey(baseDir.resolve(ResourceUtil.getPath(r)).normalize())) - .toList(); - } - - private static List retrieveNonPomFiles(List buildFileResources) { - return buildFileResources.stream().filter(r -> !"pom.xml".equals(ResourceUtil.getPath(r).getFileName().toString())).toList(); - } - - private Xml.Document markPomFile(Xml.Document pp, List markers) { - for (Marker marker : markers) { - pp = pp.withMarkers(pp.getMarkers().addIfAbsent(marker)); - } - return pp; - } - - private Map createResult(Path basePath, List pomFiles, List parsedPoms) { - return parsedPoms.stream() - .map(pom -> mapResourceToDocument(basePath, pom, pomFiles)) - .collect(Collectors.toMap(e-> ResourceUtil.getPath(e.getKey()), e -> e.getValue())); - } - - private Map.Entry mapResourceToDocument(Path basePath, SourceFile pom, List parsedPoms) { - Xml.Document doc = (Xml.Document) pom; - Resource resource = parsedPoms.stream() - .filter(p -> ResourceUtil.getPath(p).toString().equals(basePath.resolve(pom.getSourcePath()).toAbsolutePath().normalize().toString())) - .findFirst() - .orElseThrow(() -> new IllegalStateException("Could not find matching path for Xml.Document '%s'".formatted(pom.getSourcePath().toAbsolutePath().normalize().toString()))); - return Map.entry(resource, doc); - } - - private Stream parsePoms(Path baseDir, List pomFiles, MavenParser.Builder mavenParserBuilder, ExecutionContext executionContext) { - Iterable pomFileInputs = pomFiles.stream() - .map(p -> new Parser.Input(ResourceUtil.getPath(p), () -> ResourceUtil.getInputStream(p))) - .toList(); - return mavenParserBuilder.build().parseInputs(pomFileInputs, baseDir, executionContext).map(Xml.Document.class::cast); - } - - public List filterAndSortBuildFiles(List resources) { - return resources.stream() - .filter(r -> "pom.xml".equals(ResourceUtil.getPath(r).toFile().getName())) - .filter(r -> filterTestResources(r)) - .sorted((r1, r2) -> { - - Path r1Path = ResourceUtil.getPath(r1); - ArrayList r1PathParts = new ArrayList<>(); - r1Path.iterator().forEachRemaining(it -> r1PathParts.add(it.toString())); - - Path r2Path = ResourceUtil.getPath(r2); - ArrayList r2PathParts = new ArrayList<>(); - r2Path.iterator().forEachRemaining(it -> r2PathParts.add(it.toString())); - return Integer.compare(r1PathParts.size(), r2PathParts.size()); - }) - .toList(); - } - - private static boolean filterTestResources(Resource r) { - String path = ResourceUtil.getPath(r).toString(); - boolean underTest = path.contains("src/test"); - if(underTest) { - log.info("Ignore build file '%s' having 'src/test' in its path indicating it's a build file for tests.".formatted(path)); - } - return !underTest; - } - -} diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/maven/MavenConfigFileParser.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/maven/MavenConfigFileParser.java deleted file mode 100644 index 29c4d13e2..000000000 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/maven/MavenConfigFileParser.java +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright 2021 - 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.sbm.parsers.maven; - -import org.apache.commons.cli.*; -import org.apache.maven.cli.CleanArgument; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * Parse {@code .mvn/maven.config/} and provide access to relevant settings. - * Code thankfully taken from org.apache.maven.cli.CLIManager. - * - * @author Fabian Krüger - */ -class MavenConfigFileParser { - - private static final char ALTERNATE_POM_FILE = 'f'; - - private static final char BATCH_MODE = 'B'; - - private static final char SET_USER_PROPERTY = 'D'; - - private static final char OFFLINE = 'o'; - - private static final char QUIET = 'q'; - - private static final char DEBUG = 'X'; - - private static final char ERRORS = 'e'; - - private static final char HELP = 'h'; - - private static final char VERSION = 'v'; - - private static final char SHOW_VERSION = 'V'; - - private static final char NON_RECURSIVE = 'N'; - - private static final char UPDATE_SNAPSHOTS = 'U'; - - private static final char ACTIVATE_PROFILES = 'P'; - - private static final String SUPRESS_SNAPSHOT_UPDATES = "nsu"; - - private static final char CHECKSUM_FAILURE_POLICY = 'C'; - - private static final char CHECKSUM_WARNING_POLICY = 'c'; - - private static final char ALTERNATE_USER_SETTINGS = 's'; - - private static final String ALTERNATE_GLOBAL_SETTINGS = "gs"; - - private static final char ALTERNATE_USER_TOOLCHAINS = 't'; - - private static final String ALTERNATE_GLOBAL_TOOLCHAINS = "gt"; - - private static final String FAIL_FAST = "ff"; - - private static final String FAIL_AT_END = "fae"; - - private static final String FAIL_NEVER = "fn"; - - private static final String RESUME_FROM = "rf"; - - private static final String PROJECT_LIST = "pl"; - - private static final String ALSO_MAKE = "am"; - - private static final String ALSO_MAKE_DEPENDENTS = "amd"; - - private static final String LOG_FILE = "l"; - - private static final String ENCRYPT_MASTER_PASSWORD = "emp"; - - private static final String ENCRYPT_PASSWORD = "ep"; - - private static final String THREADS = "T"; - - private static final String BUILDER = "b"; - - private static final String NO_TRANSFER_PROGRESS = "ntp"; - - private static final String COLOR = "color"; - private static final String MVN_MAVEN_CONFIG = ".mvn/maven.config"; - public List getActivatedProfiles(Path baseDir) { - File configFile = baseDir.resolve(MVN_MAVEN_CONFIG).toFile(); - if (configFile.isFile()) { - try (Stream lines = Files.lines(configFile.toPath(), Charset.defaultCharset())) { - String[] args = readFile(lines); - return parse(args).stream() - .filter(o -> String.valueOf(ACTIVATE_PROFILES).equals(o.getOpt())) - .map(Option::getValue) - .map(v -> v.split(",")) - .flatMap(Arrays::stream) - .map(String::trim) - .toList(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } else { - return List.of(); - } - } - - public Map getUserProperties(Path baseDir) { - File configFile = baseDir.resolve(MVN_MAVEN_CONFIG).toFile(); - if (configFile.isFile()) { - try (Stream lines = Files.lines(configFile.toPath(), Charset.defaultCharset())) { - String[] args = readFile(lines); - return parse(args).stream() - .filter(o -> String.valueOf(SET_USER_PROPERTY).equals(o.getOpt())) - .map(Option::getValue) - .filter(v -> v.contains("=")) - .map(v -> v.split("=")) - .collect(Collectors.toMap(a -> a[0], a -> a[1])); - } catch (IOException e) { - throw new RuntimeException(e); - } - } else { - return Map.of(); - } - } - - @NotNull - private static String[] readFile(Stream lines) { - return lines.filter(arg -> !arg.isEmpty() && !arg.startsWith("#")) - .toArray(String[]::new); - } - - public List