8000 Gradle incremental annotation processing support · Issue #200 · jstachio/jstachio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Gradle incremental annotation processing support #200

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

Closed
hrstoyanov opened this issue Jul 22, 2023 · 8 comments
Closed

Gradle incremental annotation processing support #200

hrstoyanov opened this issue Jul 22, 2023 · 8 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers integration
Milestone

Comments

@hrstoyanov
Copy link
hrstoyanov commented Jul 22, 2023

This is not a jStachio issue, but something users of the Gradle build tool need to be aware of:

I accidentally had this property in my gradle.properties file:

org.gradle.caching=true

... and as a result, my template were cached and not reflecting changes I did to the files (resulting in stale rendered outputs), even after I run a clean task! The above gradle properties is not set on by default (maybe for a reason, I think), so be careful and know what you are doing, if you set it to true!

Another problem with Gradle is that (assuming the above property is not set) you still need to do a "clean" if you edit the templates, because changes in them will not be detected - gradle only looks at the java files and does not know that it should run the annotation processor after template files change. Here is how I mitigated this issue - I added additional dependency for the annotation processor:

dependencies {
    implementation "io.jstach:jstachio:${jstachioVersion}"
    annotationProcessor "io.jstach:jstachio-apt:${jstachioVersion}"
    annotationProcessor fileTree(layout.projectDirectory.dir('src/main/resources/templates')) { include '**/*' }
}

Now every change in the templates will trigger the annotation processor and cause recompile of the generated template renderers. You can even set the org.gradle.caching property from above, and your dev cycles will still work correctly!

Maybe this is worth adding to the docs for "gradlers" like me? I am not even sure how is this addressed with Maven builds?

@hrstoyanov hrstoyanov changed the title Gradle build issue (documentation issue) Gradle build issues (documentation issue) Jul 23, 2023
@agentgt
Copy link
Contributor
agentgt commented Jul 23, 2023

This is kind of a bug. I am fairly sure there is some way to support incremental in gradle better I just have delved into it enough since I don't use Gradle as often. I know jooby does special things and I believe micronaut.

@hrstoyanov
Copy link
Author
hrstoyanov commented Jul 23, 2023

... hm ...not sure this is a Gradle bug ... if you just tell it what the annotation processor is, it would not know what it works, or which files to monitor for changes. I still think adding this in the docs for Gradle would be enough:

dependencies {
    implementation "io.jstach:jstachio:${jstachioVersion}"
    annotationProcessor "io.jstach:jstachio-apt:${jstachioVersion}"
    annotationProcessor fileTree(layout.projectDirectory.dir('src/main/resources/templates')) { include '**/*' }
}

@agentgt
Copy link
Contributor
agentgt commented Jul 24, 2023

What I was talking about is using META-INF/gradle/incremental.annotation.processors.

That gives gradle some hints that I'm still exploring.

@agentgt agentgt changed the title Gradle build issues (documentation issue) Gradle incremental annotation processing support Jul 24, 2023
@agentgt agentgt added this to the v1.3.0 milestone Jul 24, 2023
@agentgt agentgt added documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers labels Jul 24, 2023
@agentgt
Copy link
Contributor
agentgt commented Jul 24, 2023

@agentgt
Copy link
Contributor
agentgt commented Jul 24, 2023

@hrstoyanov Can you make a bare minimum Gradle project using JStachio?

I have not used Gradle from the ground up in some time (> 5 years) and when I have to use it I'm building on top of someone else's gradle setup.

If you can't it is ok it just would shave off some time for me to fix incremental.

@hrstoyanov
Copy link
Author

Sure, will have something for you later today...

@hrstoyanov
Copy link
Author

@agentgt i scraped together a bare-bone Gradle jstachio project here:

https://github.com/hrstoyanov/issue201/

See the README.md for instructions.

@agentgt
Copy link
Contributor
agentgt commented Jul 29, 2023

Ok I looked into it and you are right with the resources config you provided so I will be adding that to the doc.

As for the other gradle incremental support I was mistaken. It is about Java and therefore when what happens when changing the annotated model.

That I'm playing with right now with your sample project.

agentgt added a commit to agentgt/jstachio that referenced this issue Jul 29, 2023
agentgt added a commit to agentgt/jstachio that referenced this issue Jul 29, 2023
agentgt added a commit that referenced this issue Jul 29, 2023
@agentgt agentgt closed this as completed Jul 29, 2023
agentgt added a commit to agentgt/jstachio that referenced this issue Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers integration
Projects
None yet
Development

No branches or pull requests

2 participants
0