Skip to content

Refactor ConventionsPlugin class #20805

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

Conversation

mikesmithson
Copy link
Contributor

This class was extracted from several private methods in the ConventionsPlugin class. While trying to make a PR for an issue, I had some difficulty following the flow of this class and noticed that it had a lot of private methods that probably should be extracted to a separate class. I found several similar methods related to Maven pom conventions. There are probably a few more, but this one stood out as one obvious candidate.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 2, 2020
Copy link
Member

@wilkinsona wilkinsona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the proposal, @mikesmithson. I've left a few comments for your consideration. In addition to those, if we're going to go down this route, I think the Java-related conventions should be pulled out into a separate class as well. Would you like to update the PR to do that as well?

*
* @author Mike Smithson
*/
public class MavenPomConventions implements Plugin<Project> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class doesn't need to be a Plugin. It can also be package-private. The existing AsciidoctorConventions class sets a good precedent here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class applies more than pom conventions. I think MavenPublishingConventions would be a better name.

@@ -123,53 +116,81 @@ public void apply(Project project) {

private void applyJavaConventions(Project project) {
project.getPlugins().withType(JavaBasePlugin.class, (java) -> {
project.getPlugins().apply(TestFailuresPlugin.class);
applyTestFailuresPlugin(project);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that applying the plugin is a single line and wrapping it in a method doesn't make the intent any clearer, I'd prefer to keep it inlined here.

compile.getOptions().setFork(true);
compile.getOptions().getForkOptions().setJavaHome(new File(javaHome));
compile.getOptions().getForkOptions().setExecutable(javaHome + "/bin/javac");
setSourceCompatibility(project);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to set the property directly here rather than wrapping it in a method call.

@@ -111,6 +103,7 @@
*
* @author Andy Wilkinson
* @author Christoph Dreis
* @author Mike Smithson
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The javadoc above should be updated to replace the list of actions when the MavenPublishPlugin is applied and to link to the new Maven conventions class instead.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Apr 2, 2020
@mikesmithson
Copy link
Contributor Author

@wilkinsona - sure, I would be happy to accommodate your requests. I was thinking of going further but wanted to put out this proposal to you to see if there was any interest in pursuing it.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Apr 2, 2020
@mikesmithson
Copy link
Contributor Author

@wilkinsona - made another push to address your requested changes.

@mikesmithson mikesmithson changed the title Create MavenPomConventions class Refactor ConventionsPlugin class Apr 3, 2020
Copy link
Member

@wilkinsona wilkinsona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates, @mikesmithson. It's looking pretty good now. I'm not sure I like the separate DocumentConventions class. As mentioned in the comment, I'd prefer to see that logic remain alongside the other Java-related conventions.

* @author Christoph Dreis
* @author Mike Smithson
*/
class DocumentConventions {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to keep these in the same class as the other Java-related conventions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I inlined all of the methods in DocumentConventions into JavaConventions.

…line all methods into JavaConventions class
@mikesmithson
Copy link
Contributor Author

latest requested changes are in commit 13e7406.

@wilkinsona wilkinsona added type: task A general task and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Apr 9, 2020
@wilkinsona wilkinsona added this to the 2.3.0.RC1 milestone Apr 9, 2020
@wilkinsona wilkinsona self-assigned this Apr 9, 2020
@wilkinsona
Copy link
Member

Thanks very much, @mikesmithson. The proposed changes are now in master along with a small polishing commit to make things a little more consistent across the three …Conventions classes.

@mikesmithson mikesmithson deleted the refactor-conventions-plugin branch April 9, 2020 14:05
@mikesmithson
Copy link
Contributor Author

@wilkinsona - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants