Skip to content

http-client-java, clean generated java files in emitter - #8301

Merged
Weidong Xu (weidongxu-microsoft) merged 17 commits into
microsoft:mainfrom
weidongxu-microsoft:http-client-java_clean-generate-java-files
Aug 29, 2025
Merged

http-client-java, clean generated java files in emitter#8301
Weidong Xu (weidongxu-microsoft) merged 17 commits into
microsoft:mainfrom
weidongxu-microsoft:http-client-java_clean-generate-java-files

Conversation

@weidongxu-microsoft

@weidongxu-microsoftWeidong Xu (weidongxu-microsoft) commented Aug 27, 2025

Copy link
Copy Markdown
Contributor

Fix#8278

Limited to src folder (as in practice I found without this limit, lot of IO on files in node_modules)

Will do regen sync, and maybe more tests after release.

@microsoft-github-policy-servicemicrosoft-github-policy-serviceBot added the emitter:client:java Issue for the Java client emitter: @typespec/http-client-java label Aug 27, 2025
@weidongxu-microsoft
Weidong Xu (weidongxu-microsoft)force-pushed the http-client-java_clean-generate-java-files branch from 366e7d9 to bb21c2bCompareAugust 27, 2025 08:34
@github-actions

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

@weidongxu-microsoftWeidong Xu (weidongxu-microsoft) changed the title WIP, http-client-java, clean generate java files in emitterWIP, http-client-java, clean generated java files in emitterAug 27, 2025
@azure-sdk

Azure SDK Bot (azure-sdk) commented Aug 27, 2025

Copy link
Copy Markdown
Collaborator

You can try these changes here

🛝 Playground🌐 Website🛝 VSCode Extension

Weidong Xu (weidongxu-microsoft) added a commit to Azure/autorest.java that referenced this pull request Aug 28, 2025

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements functionality to clean generated Java files in the http-client-java emitter to address issue #8278. The implementation adds file deletion capabilities that identify and remove previously generated Java files before writing new ones, with support for partial updates.

  • Added deleteGeneratedJavaFiles methods to FileUtil class that can identify and delete generated Java files based on code generation markers
  • Updated file writing methods to return Path instead of File for consistency
  • Integrated the deletion functionality into both fluent and DPG code generation workflows

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
FileUtil.javaAdded methods to delete generated Java files with marker detection and updated writeToFile to return Path
FileUtilTests.javaAdded comprehensive tests for the new file deletion functionality
TypeSpecFluentPlugin.javaUpdated to use new Path-returning writeToFile method
TypeSpecPlugin.javaUpdated to use new Path-returning writeToFile method
Main.javaIntegrated file deletion logic into both fluent and DPG generation workflows
PartialUpdateOpsImpl.javaDeleted generated file (demonstrates the cleanup functionality)

@weidongxu-microsoft
Weidong Xu (weidongxu-microsoft)force-pushed the http-client-java_clean-generate-java-files branch from 213fef8 to d655baaCompareAugust 28, 2025 02:18
@weidongxu-microsoft
Weidong Xu (weidongxu-microsoft)force-pushed the http-client-java_clean-generate-java-files branch from 045fe1b to 5bbaed7CompareAugust 28, 2025 05:02
@weidongxu-microsoftWeidong Xu (weidongxu-microsoft) changed the title WIP, http-client-java, clean generated java files in emitterhttp-client-java, clean generated java files in emitterAug 28, 2025
@weidongxu-microsoft
Weidong Xu (weidongxu-microsoft) marked this pull request as ready for review August 28, 2025 09:23
@haolingdong-msft

Copy link
Copy Markdown
Member

Do we want to run autorest validation CI?

@weidongxu-microsoft

Weidong Xu (weidongxu-microsoft) commented Aug 29, 2025

Copy link
Copy Markdown
ContributorAuthor

Do we want to run autorest validation CI?

I think there is no need. The code change (Main, TypeSpecPlugin##) is for TypeSpec along.
(and, anyway, the autorest.java PR should cover some autorest invocations -- test here Azure/autorest.java#3189)

Merged via the queue into microsoft:main with commit ab5e9e0Aug 29, 2025
26 checks passed
@weidongxu-microsoft
Weidong Xu (weidongxu-microsoft) deleted the http-client-java_clean-generate-java-files branch August 29, 2025 07:05
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:javaIssue for the Java client emitter: @typespec/http-client-java

Projects

None yet

Development

Successfully merging this pull request may close these issues.

http-client-java, clean up generated Java files in emitter-output-dir

5 participants

@weidongxu-microsoft@azure-sdk@haolingdong-msft@XiaofeiCao