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

feat: extend project to run as maven plugin #898

Merged
merged 43 commits into from
Oct 17, 2022
Merged

feat: extend project to run as maven plugin #898

merged 43 commits into from
Oct 17, 2022

Conversation

algomaster99
Copy link
Member

@algomaster99 algomaster99 commented Oct 6, 2022

Reference: #892

This PR extends the project to be used as a maven plugin. I have added two goals to the maven plugin, mine and repair. However, only a few options are available at the moment. The main objective right now is to release a maven plugin that is used in the demo at EclipseCon 2022.

Design Philosophy

  1. We do not want to duplicate the command line spec for both sub-commands. This is to ensure that the CLI and maven plugin behaves exactly the same.

There will be a slight variation in how the parameters are passed in the plugin (no change in CLI). The parameter that follows the -D option in maven cannot be in kebab-case. I did not find an article citing this, but the code is not working if I do so. For example, -Dhandled-rules won't be post-processed by the plugin so we need to pass -DhandledRules

  1. We do not want to introduce any breaking changes. The CLI should continue working as before.

Usage of new feature

Before using the plugin, you need to install the plugin locally. Follow these steps to set it up:

  1. Have mavenv3.8.6. The repair command does not work on different versions.
  2. Run mvn install -DskipUnitTests -DskipIntegrationTests.

mine goal

mvn se.kth.castor:sorald:0.6.1-SNAPSHOT:mine [-DhandledRules]

Run this on any maven project and you should get a list of mined violations. -DhandledRules is optional and it works exactly how it is written here.

repair goal

mvn se.kth.castor:sorald:0.6.1-SNAPSHOT:repair -DruleKey=<>

The ruleKey parameter is required here and again, see its input here . This should also run on any maven project and produce repairs or does nothing if there are no violations found.

ToDo

  • Make the CI pass on Windows and MacOS. The plugin works locally on Windows though. Resolved in 6f777a9.
  • Try that repair goal works with 3.6.3 as well because I assume this version is used by a majority of people since it is shipped by apt package manager. Resolved in b05ece5 (#898)
  • Update documentation

@sonatype-lift
Copy link

sonatype-lift bot commented Oct 6, 2022

⚠️ 1 God Class was detected by Lift in this project. Visit the Lift web console for more details.

@algomaster99
Copy link
Member Author

algomaster99 commented Oct 8, 2022

@khaes-kth I have updated the details about the new feature in the description. Do check it out.

sorald/pom.xml Outdated Show resolved Hide resolved
sorald-api/pom.xml Outdated Show resolved Hide resolved
@algomaster99
Copy link
Member Author

The tests finally work on Windows and macOS as well. 😌 Time to update the documentation.

@algomaster99
Copy link
Member Author

algomaster99 commented Oct 10, 2022

@khaes-kth @monperrus

Please try out sorald maven-plugin and drop your reviews.

Summary of changes

  1. I have managed to extend the Sorald to be used as a maven-plugin. My goal is to make it as analogous as possible to the CLI. Hence, two goals are added - repair and mine. See "Usage of new feature" in the PR description.
  2. We also have integration tests now, thanks @cesarsotovalero for the guidance here. -DskipTests has been split into two parameters now -DskipUnitTests and -DskipIntegrationTests. Keep in mind that the integration tests are triggered in much fewer phases than the unit tests so you may not need to pass -DskipIntegrationTests most of the time. You can see how it used in the updated workflow.

Since we are not meeting this week, I will attach demos of the respective goals.
mine.webm
repair.webm

Future work

A lot of work is left, but we can delegate them to later PRs.

  • Fix the error message when -DruleKey is not passed. The error message, as of now, suggests passing -Drules instead.
  • Release maven-plugin
  • Extend option for generating stats-output-file.
  • Extend the leftover options. Their priority can be decided later.

Needless to say, the documentation has to be updated whenever deemed necessary.

@algomaster99 algomaster99 marked this pull request as ready for review October 10, 2022 11:35
@algomaster99
Copy link
Member Author

[ERROR] 

Some dependencies of Maven Plugins are expected to be in provided scope.
Please make sure that dependencies listed below declared in POM
have set '<scope>provided</scope>' as well.

The following dependencies are in wrong scope:
 * org.apache.maven:maven-plugin-api:jar:3.8.6:compile
 * org.apache.maven:maven-model:jar:3.8.6:compile
 * org.apache.maven:maven-artifact:jar:3.8.6:compile

Investigate why this "error" is logged while building the maven plugin.

Copy link
Collaborator

@khesoem khesoem left a comment

Choose a reason for hiding this comment

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

Awesome PR. Thanks @algomaster99

@khesoem khesoem merged commit 087e3c1 into master Oct 17, 2022
@khesoem khesoem deleted the maven-plugin branch October 17, 2022 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants