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

Start work on the maven plugin #102

Closed
gaganis opened this issue Apr 13, 2017 · 29 comments
Closed

Start work on the maven plugin #102

gaganis opened this issue Apr 13, 2017 · 29 comments

Comments

@gaganis
Copy link

gaganis commented Apr 13, 2017

Hello All,

I was thinking on starting work for the maven plugin, so this issue is to ask whether anyone has already started to work, and to act as a placeholder for related discussion.

Thanks
Giorgos

@jbduncan
Copy link
Member

Hi @gaganis, I haven't done any work towards the Maven plugin myself, but I don't know about @nedtwigg...

@nedtwigg
Copy link
Member

The maven plugin is completely greenfield. It's all yours :)

@jbduncan
Copy link
Member

@gaganis Do you have any initial work that you can share with us, or has this fallen off your radar?

@gaganis
Copy link
Author

gaganis commented May 30, 2017

@jbduncan Unfortunately I have nothing working to share. I tried starting with building a hello world maven plugin in the gradle build of spotless but despite putting quite an effort I was unable to make it work.

I tried using https://dev.liferay.com/develop/reference/-/knowledge_base/7-0/maven-plugin-builder-gradle-plugin and also using mavenEmbedder directly but I got stuck which is why I did no progress.

My latest non-working attempt was using the following maven-plugin build.gradle file:
https://gist.github.com/gaganis/fb0a8d1e27bbaf61281b9314a62bd95b

This is definitely still on my radar and I am planning to give it another try.

Any help on building the plugin would be very welcome 😄

@jbduncan
Copy link
Member

jbduncan commented May 31, 2017

May I suggest applying maven-plugin-builder-gradle-plugin to a brand-new Gradle Java project, where its only Java source file is a "Hello World" Mojo (as described near the start of https://maven.apache.org/guides/plugin/guide-java-plugin-development.html)?

If you can get your head around that, then you may be able to gradually build up the build.gradle in this brand-new project so it looks more like Spotless's, and then track down what's causing you problems.

@gaganis
Copy link
Author

gaganis commented Jun 5, 2017

Thank you for the feedback @jbduncan 😄 I will try your suggestion.

@jbduncan
Copy link
Member

jbduncan commented Jun 5, 2017

You're welcome @gaganis. I'm sorry that I can't provide any easier-to-follow or more specific advice in this situation. I wish you best of luck with these endeavours. :)

@leonard84
Copy link

An alternative would be to use maven directly, with maven-wrapper and a pom.xml. The reason for that being that maven has great support for generating its plugins, e.g. maven-invoker integration tests and so on.

@jbduncan
Copy link
Member

jbduncan commented Jun 8, 2017

@leonard84 That could be done, but it would mean that we couldn't share Gradle build script settings in build.gradle and gradle/*.gradle with the pom.xml, which would introduce build logic duplication, I suspect.

@nedtwigg
Copy link
Member

nedtwigg commented Jun 8, 2017

We're happy to take whatever is easiest - duplicating build logic in maven might be easier than reinventing maven's plugin development in gradle. Author's choice :)

@leonard84
Copy link

Spring Boot does it the other way round (building gradle-plugin within a maven project) https://github.com/spring-projects/spring-boot/tree/master/spring-boot-tools. You basically need to write an adapter build.gradle file that calls maven.

@jbduncan
Copy link
Member

jbduncan commented Jun 9, 2017

@leonard84 That sounds like a neat idea IMO. (Having viewed how Spring Boot does it with Maven-to-Gradle, it seems perfectly doable the other way around.)

In that case, I'm happy regardless of whether the Maven plugin is managed with Gradle or Maven, since we can eventually tie everything with Gradle if needed (as future work). :)

@leonard84
Copy link

@jbduncan I created a small proof of concept here https://github.com/leonard84/spotless/tree/mvn-plugin
It works by using a templated pom.xml and injects the gradle.properties, then it uses the maven-wrapper in an exec task to execute the maven build.

What still needs to be done:

  • configure the maven plugins
  • figure out a way to use the spotless lib from the current project build
    • one way would be to depend on the install task of the lib to use the local maven repository
    • currently it just depends on the stable version
  • write the actual plugin
  • add mvn-invoker integration tests

@jbduncan
Copy link
Member

jbduncan commented Jun 9, 2017

Looks good so far @leonard84! I just have a couple of comments (1, 2) about the current implementation, but other than that, it looks like a good starting point.

But first of all, if you're intending continue, then I'd encourage you to wait a bit, as I believe @gaganis is still working on this himself.

@gaganis, do you find @leonard84's contribution so far helpful for your own efforts? Would you be happy if @leonard84 continues down his own avenue, on the understanding that he may tread on your toes? Overall, is this issue something that you still want to work on?

@jbduncan
Copy link
Member

jbduncan commented Jun 9, 2017

@leonard84 Sorry, didn't actually link the comments that I talked about. Here they are: 1, 2.

@jbduncan
Copy link
Member

jbduncan commented Jun 9, 2017

@leonard84 Oh I beg your pardon! 🙇‍♂️ @nedtwigg tells me that it's much better to freely allow people to develop code on GitHub without feeling that they're being co-ordinated; to allow so-called "permissionless innovation", since it gets things done quicker.

So please disregard my earlier comment on waiting up a bit. By all means, continue with your efforts at whatever pace that you feel comfortable with. :)

@nedtwigg
Copy link
Member

Thanks to a tremendous effort from @lutovich, we now have a fantastic implementation of spotless-maven-plugin deployed to maven-central. You can see the docs here.

We've currently shipped as 1.0.0.BETA1, but there are no known defects. It's only BETA because it hasn't been battle-tested on many projects yet.

We'd love some example projects to link to for the example configurations section, please give it a try and let us know how it goes. Once we've got a couple examples to link to, we'll release the real 1.0 and trumpet its arrival more broadly.

@matthiasbalke
Copy link
Contributor

matthiasbalke commented Feb 15, 2018

First of all thank you very very much @lutovich for implementing the first version of the maven plugin of spotless! This is a big step for maven projects!

Second I would like to contribute some more steps like generic.EndWithNewlineStep, generic.IndentStep, generic.TrimTrailingWhitespaceStep, generic.ReplaceStep and generic.ReplaceRegexStep. As soon as I'm finished with these simple steps I would like to implement a more complex one. Maybe groovy.GrEclipseFormatterStep. But let's start with the simple ones 😏

I'll plan to start this afternoon (~ 16:00 MEZ / 8:00 PST). Just let me know if any of you are already implementing those, so we don't do the same work.

@nedtwigg
Copy link
Member

A publishing bug was found in 1.0.0.BETA1, fixed in 1.0.0.BETA2.

@matthiasbalke - great, I think you're the only one working on these, and they would be great to have! If you have any questions, feel free to ask in https://gitter.im/diffplug/spotless

@nedtwigg
Copy link
Member

We introduced another bug in 1.0.0.BETA3, but fixed it in 1.0.0.BETA4. Thanks to #223, we now support Kotlin in addition to the Java and Scala we supported before. It seems to me that we're ready to cut the 1.0.0 release, and do some publicity, except that we don't have an open-source example project that we can point to. Anybody have anything open-source they can get a PR merged-in to?

I think we've had something really useful to people for about a month now, would be a shame to keep it under wraps for longer just cuz there's no example project.

@jbduncan
Copy link
Member

jbduncan commented Mar 13, 2018

@nedtwigg For various reasons, it's taking longer than expected for jrtom/jung#198 to be merged in to allow JUNG to be used as an example project.

I'll let you know when I know more. :)

@nedtwigg
Copy link
Member

Anybody have an example project we can link to yet?

@jbduncan
Copy link
Member

So sorry @nedtwigg, not sure yet still when my PR for JUNG will be looked at. :(

I'll let you know when I know more.

@nedtwigg
Copy link
Member

Bump: any opensource projects we can point to as an example?

@jbduncan
Copy link
Member

Oops, JUNG still can't be used as an example, as @jrtom and I have not been doing anything for that project for quite a while now!

Any others?

@nedtwigg
Copy link
Member

Great work @jbduncan, looks like spotless got merged into jung. Can I include this in the examples from the readme?

@jbduncan
Copy link
Member

Certainly, go ahead! I'm sure @jrtom would be ok with this. :)

@jrtom
Copy link

jrtom commented Jul 30, 2018

Yep, fine by me. :)

@nedtwigg
Copy link
Member

nedtwigg commented Aug 8, 2018

Huge thanks to @lutovich for pushing this to the finish line, but also to everybody who contributed great bug reports and fixes. Now that we have an example project thanks to @jbduncan and @jrtom, I think we're ready to publicize this a little. Here's the announcement tweet:

https://twitter.com/NedTwigg/status/1027216025853415425

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants