Dealing with a generated project

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Dealing with a generated project

Sander Verhagen
Hi list,


The REST API of our application is using Swagger for documentation. During build we spin up our application, extract the Swagger JSON document, and feed it into the Swagger Codegen Maven Plugin to generate an API client. This plugin spits out a complete Maven project (and Gradle for that matter), including Java files that represent this API client, even Java files with unit tests. Great!

So, now I have a generated project, that's not part of my current Maven build. (Could it be?) I've used generated code plenty, but I struggle to fully comprehend what the best pattern is for this generated project. I would like this project to be published to our Artifactory (its artifact) and to Git (its source code). All preferably from the same build. For the publish to Git I'm afraid to get into the vendor branch pattern, which I've never done well at. I'm anyway not even sure if I'd want to publish to Git on every build, and every commit of my application, or maybe publish to Git based on a source JAR (is that even a thing?), so yeah, I could use some pointers, if anyone has any some good ideas or examples to look at.

Thanks, Sander.



Sander Verhagen
[  [hidden email]<mailto:[hidden email]>  ]

Reply | Threaded
Open this post in threaded view
|

RE: Dealing with a generated project

Sander Verhagen
Apparently no one had ideas about this. That hurts :)

Just circling back with what ended up being my approach. So we generate a Maven project using Swagger Codegen Maven Plugin. I now generate it somewhere below the "target/" folder of the POM project that has this configuration. Then use the Maven Invoker Plugin in the compile phase to do an install on the generated project, and in the deploy phase to do a deploy on the generated project (the latter with skipTest=true, to not repeat too much). The later Invoker run also has the following configured, so that the generated project ends up in our company POM (without itself carrying this information, as the generated project is ultimately aimed at public consumption):

<altDeploymentRepository>${project.distributionManagement.snapshotRepository.id}::default::${project.distributionManagement.snapshotRepository.url}</altDeploymentRepository>

I probably left out some small but fancy details. I code reviewed this with some colleagues, who praised me for my wicked Maven skills. Now... that's not necessarily a good thing, because this is one of those cases where little is left from Maven's "convention over configuration" philosophy, and others may have a hard time figuring out how this all works. (Including future versions of myself. That wouldn't be a first either.)

That's all.



Sander Verhagen
[hidden email]  ]

-----Original Message-----
From: Sander Verhagen [mailto:[hidden email]]
Sent: Saturday, July 22, 2017 01:10
To: Maven Users List <[hidden email]>
Subject: Dealing with a generated project

Hi list,


The REST API of our application is using Swagger for documentation. During build we spin up our application, extract the Swagger JSON document, and feed it into the Swagger Codegen Maven Plugin to generate an API client. This plugin spits out a complete Maven project (and Gradle for that matter), including Java files that represent this API client, even Java files with unit tests. Great!

So, now I have a generated project, that's not part of my current Maven build. (Could it be?) I've used generated code plenty, but I struggle to fully comprehend what the best pattern is for this generated project. I would like this project to be published to our Artifactory (its artifact) and to Git (its source code). All preferably from the same build. For the publish to Git I'm afraid to get into the vendor branch pattern, which I've never done well at. I'm anyway not even sure if I'd want to publish to Git on every build, and every commit of my application, or maybe publish to Git based on a source JAR (is that even a thing?), so yeah, I could use some pointers, if anyone has any some good ideas or examples to look at.

Thanks, Sander.



Sander Verhagen
[  [hidden email]<mailto:[hidden email]>  ]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Dealing with a generated project

james northrup
Archetype with swagger Params in -D

On Sun, Aug 27, 2017, 11:32 AM Sander Verhagen <[hidden email]>
wrote:

> Apparently no one had ideas about this. That hurts :)
>
> Just circling back with what ended up being my approach. So we generate a
> Maven project using Swagger Codegen Maven Plugin. I now generate it
> somewhere below the "target/" folder of the POM project that has this
> configuration. Then use the Maven Invoker Plugin in the compile phase to do
> an install on the generated project, and in the deploy phase to do a deploy
> on the generated project (the latter with skipTest=true, to not repeat too
> much). The later Invoker run also has the following configured, so that the
> generated project ends up in our company POM (without itself carrying this
> information, as the generated project is ultimately aimed at public
> consumption):
>
> <altDeploymentRepository>${
> project.distributionManagement.snapshotRepository.id
> }::default::${project.distributionManagement.snapshotRepository.url}</altDeploymentRepository>
>
> I probably left out some small but fancy details. I code reviewed this
> with some colleagues, who praised me for my wicked Maven skills. Now...
> that's not necessarily a good thing, because this is one of those cases
> where little is left from Maven's "convention over configuration"
> philosophy, and others may have a hard time figuring out how this all
> works. (Including future versions of myself. That wouldn't be a first
> either.)
>
> That's all.
>
>
>
> Sander Verhagen
> [  [hidden email]  ]
>
> -----Original Message-----
> From: Sander Verhagen [mailto:[hidden email]]
> Sent: Saturday, July 22, 2017 01:10
> To: Maven Users List <[hidden email]>
> Subject: Dealing with a generated project
>
> Hi list,
>
>
> The REST API of our application is using Swagger for documentation. During
> build we spin up our application, extract the Swagger JSON document, and
> feed it into the Swagger Codegen Maven Plugin to generate an API client.
> This plugin spits out a complete Maven project (and Gradle for that
> matter), including Java files that represent this API client, even Java
> files with unit tests. Great!
>
> So, now I have a generated project, that's not part of my current Maven
> build. (Could it be?) I've used generated code plenty, but I struggle to
> fully comprehend what the best pattern is for this generated project. I
> would like this project to be published to our Artifactory (its artifact)
> and to Git (its source code). All preferably from the same build. For the
> publish to Git I'm afraid to get into the vendor branch pattern, which I've
> never done well at. I'm anyway not even sure if I'd want to publish to Git
> on every build, and every commit of my application, or maybe publish to Git
> based on a source JAR (is that even a thing?), so yeah, I could use some
> pointers, if anyone has any some good ideas or examples to look at.
>
> Thanks, Sander.
>
>
>
> Sander Verhagen
> [  [hidden email]<mailto:[hidden email]>  ]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>