-
Notifications
You must be signed in to change notification settings - Fork 89
2.7: Changes to Auto-configuration #156 #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.7: Changes to Auto-configuration #156 #182
Conversation
@ijusti Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@ijusti Thank you for signing the Contributor License Agreement! |
...nts/sbm-core/src/main/java/org/springframework/sbm/build/impl/OpenRewriteMavenBuildFile.java
Show resolved
Hide resolved
Hi @ijusti! |
} | ||
|
||
@Override | ||
public boolean evaluate(ProjectContext context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use e.g. PathPatternMatchingProjectResourceFinder
instead?
This would also remove the dependency from Condition
to Action
and remove the assumption that the resources in the ProjectContext
exist as files.
return !context.search(new PathPatternMatchingProjectResourceFinder("**/src/main/resources/META-INF/spring.factories")).isEmpty();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i need to check that near spring.factories no new file exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, that's a good idea. What about something like this?
return !context.search(new PathPatternMatchingProjectResourceFinder("**/src/main/resources/META-INF/spring.factories")).isEmpty() &&
context.search(new PathPatternMatchingProjectResourceFinder("**/src/main/resources/META-INF/org.springframework.boot.autoconfigure.AutoConfiguration.imports")).isEmpty()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this good, and I tried to make this way? but there is no spring.factories in context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like this, that mean that there is no new imports near spring.factories
return context.search(new PathPatternMatchingProjectResourceFinder("**/src/main/resources/META-INF/spring.factories"))
.stream()
.anyMatch(resource-> context.search(new PathPatternMatchingProjectResourceFinder("resource.path.parent +"org.springframework.boot.autoconfigure.AutoConfiguration.imports")).isEmpty())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I got your valid point here.
I am thinking that if we replace all old with new factories in one go and remove the old ones (or move with MoveFilesAction
), there should not be both (old and new) in one project. If this is "guaranteed" we can skip the second part of the check?
You could replace resource.path.parent
with resource.getAbsoluetPath().getParent().resolve("org.springframework.boot.autoconfigure.AutoConfiguration.imports")
and then use AbsolutePathResourceFinder
with this path.
...ngframework/sbm/boot/upgrade_24_25/actions/Boot_24_25_CreateDatasourceInitializerAction.java
Show resolved
Hide resolved
.../java/org/springframework/sbm/boot/upgrade_24_25/actions/Boot_24_25_UpgradeReportAction.java
Show resolved
Hide resolved
import static java.nio.file.StandardOpenOption.WRITE; | ||
import static java.util.function.Predicate.not; | ||
|
||
public class CreateAutoconfigurationAction extends AbstractAction { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide a test for this class.
You can create a synthetic ProjectContext
with TestProjectContext
helper class.
Run the Action against the created ProjectConetxt
and verify the result.
You can have a look at existing tests for examples.
.../java/org/springframework/sbm/boot/upgrade/common/actions/CreateAutoconfigurationAction.java
Show resolved
Hide resolved
...nents/sbm-recipes-boot-upgrade/src/main/resources/recipes/boot-autoconfiguration-update.yaml
Show resolved
Hide resolved
} | ||
|
||
@Override | ||
public boolean evaluate(ProjectContext context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, that's a good idea. What about something like this?
return !context.search(new PathPatternMatchingProjectResourceFinder("**/src/main/resources/META-INF/spring.factories")).isEmpty() &&
context.search(new PathPatternMatchingProjectResourceFinder("**/src/main/resources/META-INF/org.springframework.boot.autoconfigure.AutoConfiguration.imports")).isEmpty()
Hi @ijusti ! |
9a0d8bc
to
9a81c94
Compare
9a81c94
to
8413ea1
Compare
No description provided.