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

Custom templates don´t work properly with Gradle Plugin #1158

Closed
esfomeado opened this issue Apr 19, 2023 · 2 comments
Closed

Custom templates don´t work properly with Gradle Plugin #1158

esfomeado opened this issue Apr 19, 2023 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@esfomeado
Copy link
Contributor

Issue Description

The custom template don't work properly with the Gradle Plugin since the daemon folder is used as root instead of the project folder.

Steps to Reproduce

Try to configure a custom template using the gradle plugin.
The root folder is going to be the gradle daemon root.

Expected Result

It should use the project folder as the root.

Actual Result

It uses the daemon root.

Your Environment and Setup

  • graphql-java-codegen version: 5.7.1
  • Build tool: Gradle
@esfomeado esfomeado added the bug Something isn't working label Apr 19, 2023
@isaac-mercieca
Copy link
Contributor

@esfomeado

I was investigating this problem which was encountered by setting the plugin on a Gradle project. I noticed that the problem occurs as FileTemplateLoader in FreeMarkerTemplatesRegistry is being initialised to the current working directory which in the case of Gradle will be the daemon folder.

FileTemplateLoader fileTemplateLoader = new FileTemplateLoader(new File("."));

The solution I was considering to address this problem was to include support for a new configuration customTemplatesDirectory or customTemplatesRoot. This will provide the developer with the ability to configure the template directory for a project. Since the configuration will be available from each of the build plugins the default value for the template's root will be defined by each plugin whereas for Gradle this can be the project's root directory. Such a configuration would then need to be provided to the FileTemplateLoader.

@esfomeado
Copy link
Contributor Author

@isaac-mercieca I think that is the best solution.

@kobylynskyi kobylynskyi added this to the 5.8.0 milestone May 2, 2023
kobylynskyi pushed a commit that referenced this issue May 2, 2023
…latesRoot" #1158 (#1198)

* added support for specifying the template source for custom templates

* formatted test sources

* resolved issues with sbt plugin

* formatted source class according to checkstyle rules

* updated scala plugin to resolve to the working directory

---------

Co-authored-by: Isaac Mercieca <isaac.mercieca@rs2.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants