phoenixnap / springmvc-raml-plugin

Spring MVC - RAML Spec Synchroniser Plugin. A Maven plugin designed to Generate Server & Client code in Spring from a RAML API descriptor and conversely, a RAML API document from the SpringMVC Server implementation.
Apache License 2.0
136 stars 84 forks source link

Project refactoring broke future gradle support #274

Open tburny opened 5 years ago

tburny commented 5 years ago

Hello everyone, I took a look into Gradle support with https://github.com/netfalo/gradle-raml-plugin as a working base. In v1 the springmvc-raml-plugin had a structure that allowed only to include the required parts as a dependency to the gradle plugin, whereas for v2 there is only the maven plugin as artifact.

Additionally due to renamings the code is not quite portable. In summary the refactoring of V2 as in the current state of the project architecturally breaks gradle support for the near future, as

I understand that this is still work in progress (as in https://github.com/phoenixnap/springmvc-raml-plugin/projects/1), so maybe we can adjust the whole thing a little?

I would like to suggest something along the lines of

Figuratively speaking springmvc-raml would be the car and there are different kinds of drivers (such as Maven, Gradle, Ant(?!), Integration tests or a simple console application).

Otherwise I think the Maven Plugin is great and stands for itself, so thanks a lot for all the time and effort! :)

stojsavljevic commented 5 years ago

Hi,

Thanks for reaching us.

Gradle support would be great addition to this project. IIRC, the main problem with 2.0 is that is distributed as single jar tightly coupled with maven. So splitting project in two modules where one contains main parsing logic without being dependent on maven would help.

Is that correct?

tburny commented 5 years ago

Basically, yes. There is also lot of code thats currently in the Maven Mojo itself which could probably be refactored into a common foundation. Currently the Mojo is the main entry point as far as I can see, we need to change that so that the mojo is one entry point of many and they all delegate to a common base.

My main goal is the RAML 1.0 -> Java Path (which is not supported by https://github.com/netfalo/gradle-raml-plugin yet). I would help porting the plugin's code to the RAML Plugin 2.0 "core" and add the RAML to Code path.

stojsavljevic commented 5 years ago

I will start refactoring master branch as soon as I find some time.

I would help porting the plugin's code to the RAML Plugin 2.0 "core" and add the RAML to Code path.

Yes please. RAML to Code path is the only one supported in 2.0 and will probably stay like that.

stojsavljevic commented 5 years ago

Relates to #65

tburny commented 5 years ago

Do you think it is possible to allow customized code generation? Architecturally speaking I'm thinking about a more general framework for transforming RAML into Java Code, where the Models, Controllers and Interfaces are just three implementations (but more are easily possible).

Also it would be great to apply the plugin repeatedly with a set of generation rules (Models, Controllers, Clients) :)

tburny commented 5 years ago

I spent a few hours trying to split apart the Maven stuff from the generation stuff (still work in progress), here is what I found so far:

Not that I meant this as a "everything is bad" thing, there has been a lot of great work by many people which is really amazing! I just wanted to point out that it won't be an easy thing to do.

I think that the rule approach is quite powerful and - if one understands it - allows writing new generation rules easily. Progressing further, I changed the rules so that instead of asking the configuration, they are told via constructor parameters. This still leaves a gap between rule parameters and the global configuration, which I currently solved by introducing factories that know the configuration and that can create preconfigured rules using that (blending in more parameters).

tburny commented 5 years ago

@stojsavljevic I did a first shot, basically I refactored the configuration quite a lot (and its still quite dirty) and split up the project.

tburny commented 5 years ago

I updated my fork as requested :)