Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix calculation of base package #49

Closed
fabapp2 opened this issue Mar 28, 2022 · 1 comment · Fixed by #706
Closed

Fix calculation of base package #49

fabapp2 opened this issue Mar 28, 2022 · 1 comment · Fixed by #706
Assignees
Labels
good first issue Good for newcomers

Comments

@fabapp2
Copy link
Collaborator

fabapp2 commented Mar 28, 2022

What needs to be done

Calculating base packages should return the common parent package, even if it is the default (no) package.
In BasePackageCalculator.calculateBasePackage(List<JavaSource> javaSources)

Why it needs to be done

For e.g. two classes com.acme.some.A and com.acme.other.B the current calculation does fail as it does not recognize com.acme as possible common base package.

Acceptance Criteria

Given base package should be calculated for an application
When two classes com.acme.some.A and com.acme.other.B exist
Then the returned base package should be com.acme

Given base package should be calculated for an application
When two classes com.acme.some.A and com.example.other.B exist
Then the returned base package should be com

Given base package should be calculated for an application
When two classes com.acme.some.A and org.example.other.B exist
Then the returned base package should be ""

See JavaSourceSetImplTest.getBasePackageShouldReturnDefaultIfNoDistinctRootPackageExists()
This test should expect com.vmware.sbm instead of the default base package.

Additional Information

All recipes/actions calculating the base package for Spring components and configurations should check if the returned base package is the default package/empty and handle this situation. At least initialize-spring-boot-migration would be affected.
For Spring applications to work without one common base package, a @ComponentScan could be used.

@soumyaPrakashB
Copy link
Contributor

I have raised a PR for this issue: #706
Please review.

@fabapp2 fabapp2 linked a pull request Jan 29, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants