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

Generator extension API + jte-models extension #224

Merged
merged 26 commits into from
May 27, 2023

Conversation

edward3h
Copy link
Contributor

This is what I've done for generating a 'model' facade. I need to finish some more documentation, but thought it would be good to share.

  • added an 'extension API' that can be called from TemplateCompiler
  • jte-models module is an extension that generates a facade interface + static and dynamic implementations.
  • maven and gradle plugin support
  • test cases

@codecov
Copy link

codecov bot commented May 17, 2023

Codecov Report

Patch coverage: 25.00% and project coverage change: -1.34 ⚠️

Comparison is base (d74f2f0) 92.92% compared to head (da68af4) 91.58%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #224      +/-   ##
============================================
- Coverage     92.92%   91.58%   -1.34%     
+ Complexity     1128     1122       -6     
============================================
  Files            65       67       +2     
  Lines          2882     2901      +19     
  Branches        464      460       -4     
============================================
- Hits           2678     2657      -21     
- Misses          111      151      +40     
  Partials         93       93              
Impacted Files Coverage Δ
...e-runtime/src/main/java/gg/jte/TemplateEngine.java 93.16% <0.00%> (-4.28%) ⬇️
...e/src/main/java/gg/jte/compiler/CodeGenerator.java 85.18% <ø> (ø)
jte/src/main/java/gg/jte/compiler/ParamInfo.java 70.00% <0.00%> (-30.00%) ⬇️
...jte/compiler/extensionsupport/ExtensionConfig.java 0.00% <0.00%> (ø)
...extensionsupport/ExtensionTemplateDescription.java 0.00% <0.00%> (ø)
...rc/main/java/gg/jte/compiler/TemplateCompiler.java 83.01% <22.22%> (-6.25%) ⬇️
...src/main/java/gg/jte/compiler/ClassDefinition.java 81.25% <33.33%> (-11.06%) ⬇️
...va/gg/jte/compiler/kotlin/KotlinCodeGenerator.java 97.18% <100.00%> (+0.02%) ⬆️
...e-runtime/src/main/java/gg/jte/TemplateConfig.java 100.00% <100.00%> (ø)
...n/java/gg/jte/compiler/java/JavaCodeGenerator.java 98.41% <100.00%> (+0.02%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@casid
Copy link
Owner

casid commented May 17, 2023

@edward3h that‘s awesome progress! I‘ll have a detailled look this weekend and proper feedback 😊

Copy link
Owner

@casid casid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @edward3h I finally had the time to do a proper review. And wow, that looks great! I really like that it's a general purpose extension API, as the native image resources are now possible with an extension instead of hacking into the project. Also, I find it really funny that you're using jte to generate the models :-D.

I left a few notes in the code, mostly minor stuff. I have left a note on the JteModel interface, I have a gut feeling that the render() methods there need to be simplified a bit. I left a suggestion, let me know what you think about it!

Overall I feel very confident that we can merge this soon.

jte-extension-api-mocks/pom.xml Outdated Show resolved Hide resolved
jte-extension-api/pom.xml Outdated Show resolved Hide resolved
jte-models/pom.xml Outdated Show resolved Hide resolved
jte-native-resources/pom.xml Outdated Show resolved Hide resolved
jte/src/main/java/gg/jte/compiler/TemplateCompiler.java Outdated Show resolved Hide resolved
jte/pom.xml Outdated
<artifactId>jte-extension-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the native resources extension here? This way users who need it can add the dependency and others don't have it by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention was to keep backward compatibility for users who have configured native resources with the existing boolean property. Maybe there is another way to do that. Do you have any ideas?

I can figure out how to do it in Gradle :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could throw an Exception when the native resources boolean property is set to true? And put instructions into the exception message how to migrate to the new extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess if we put this in 3.0 we can just drop the existing setting and be less concerned about compatibility.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that makes sense 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made this change - dropped all the uses of the native resources boolean property and updated tests to use the extension instead.

@edward3h
Copy link
Contributor Author

Yes I was playing with String.format to generate model classes, then thought it would be easier with some sort of template library, then "Oh, I have one right here". It is nice that it worked out.

@casid casid mentioned this pull request May 22, 2023
@edward3h
Copy link
Contributor Author

I pulled updates from main and got tests passing again.

@casid
Copy link
Owner

casid commented May 26, 2023

That looks really good! I don't see anything that should prevent us from merging :-)

@edward3h what do you think?

@edward3h
Copy link
Contributor Author

Looks good to me :)

@casid casid merged commit 268e848 into casid:main May 27, 2023
@casid
Copy link
Owner

casid commented May 27, 2023

🎉 Thank you for this amazing extension API contribution @edward3h!

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

Successfully merging this pull request may close these issues.

2 participants