Start a new topic

New location for generated files

Currently, the generated files are buried deeply in the gentargets directory:

gentargets > <project name> > <GenTarget name> > generated > <generated filename>

It would be good to have the generated file closer to the root for a variety of reasons. For example, some of the GenTargets use spaces in their names ('Swagger Normalizer [YAML+JSON]" and "ASP.NET 5 Server" are examples). Some file systems do not like spaces in names. 

The other reason is it's just a pain. The only file I *need* to check into my VCS is the generated file. Having to copy the generated file to another location after every generation is a step I don't need.

1 Comment

Brad, thanks for the feedback!

This deserves a complete response, and probably a new article here on the community & support portal.  I'll write up something within the next few days.  But in the meantime, here's a quick summary of solutions available with the current feature set:

  1. Specify a different output folder using relativeOutputDir

    Each GenTarget folder has a YAML-formatted .gen configuration file.  This has all of the parameters that can be customized for the GenTemplate, and some generic parameters that can be used in any GenTarget.  One of those parameters is relativeOutputDir, which defaults to 'generated', but can be set to any relative or absolute path to specify where the generated files should go.

    Here's an example that puts generated files in a "SwaggerUI-v3" folder directly under the project root.

  2. Move the GenTarget folder

    A GenTarget folder can be anywhere in the project structure; it doesn't have to be in the standard 'gentargets' subfolder structure. You can choose to place your gentarget in a different location at the time you create it, or you can move it after the fact simply by dragging and dropping in the Project Explorer.

    Note that the primarySource/path property in the .gen file needs to point to the absolute or relative path of the Swagger–OpenAPI 2.0, 3.0, or RAPID-ML file that is the input to your GenTarget. If you move the GenTarget outside of the default folder hierarchy, you will need to update primarySource so it correctly points to the main input model.

    Here's an example that has been moved from the default 'gentargets'/<model-name>/<gentarget-name>' location to the project root.  The primarySource/path property has been changed to a correct relative path, pointing to the input model.

  3. Create a project to contain the generated files

    This is especially useful when you're generating a project that uses Java, or another language supported in the Eclipse environment. You can create a new Eclipse project that contains the generated files, and this will show as a top-level project in your workspace.

    I'll describe this more thoroughly in the upcoming article. 

Login or Signup to post a comment