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

MINOR: Move generated sources to build directory #16993

Merged
merged 2 commits into from
Aug 25, 2024

Conversation

mumrah
Copy link
Member

@mumrah mumrah commented Aug 24, 2024

Gradle does not recommend putting generated and non-generated sources in the same directory. This can disturb the caching mechanism. This patch puts the generated sources into the "build" dir.

After merging, the old generated sources will still be around but should not affect the build or local development. A ./gradlew clean should remove any old or new generated sources.

https://discuss.gradle.org/t/right-way-to-generate-sources-in-gradle-7/41141/2

.gitignore Outdated
Comment on lines 57 to 58
**/src/generated
**/src/generated-test
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing these ignores makes it more likely for people to accidentally commit the generated code, right?

WDYT about moving the directories but leaving the ignores in place for some time? If we merged my clean PR, that could give a window in which developers can clean up the old directories without ever thinking about them, and later we can finally remove the ignores and the extra clean.

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason I wanted to remove it was so we could do a simple git clean to remove the files from the old location. However, not ignoring them does make it more likely for someone to commit them.

I think your plan makes sense. Basically if we move the files to "build", but keep the additional clean logic you've added, ./gradlew clean should clear out both locations.

Copy link
Member

Choose a reason for hiding this comment

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

1 to @gharris1727 to leave the ignores in place. Otherwise, people could commit the generated code unexpectedly when testing 3.x branches and trunk branch.

Copy link
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@mumrah thanks for this patch. Could you please remove unused path (src/generated/java)` from core module (https://github.com/apache/kafka/blob/trunk/build.gradle#L1261). That should be included by #16019 but I overlook it ...

.gitignore Outdated
Comment on lines 57 to 58
**/src/generated
**/src/generated-test
Copy link
Member

Choose a reason for hiding this comment

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

1 to @gharris1727 to leave the ignores in place. Otherwise, people could commit the generated code unexpectedly when testing 3.x branches and trunk branch.

settings.gradle Outdated Show resolved Hide resolved
@mumrah mumrah requested review from gharris1727 and chia7712 August 24, 2024 21:14
Copy link
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

LGTM. the following addendum can be addressed in next PR (I will file a jira for them).

  1. remove src/generated/java from core module
  2. add <suppress files="[\\/]generated[\\/]" checks="[a-zA-Z0-9]*"/> to the suppressions.xml to suppress all generated code

@chia7712
Copy link
Member

in next PR (I will file a jira for them).

https://issues.apache.org/jira/browse/KAFKA-17416

@chia7712 chia7712 merged commit a95dfe2 into apache:trunk Aug 25, 2024
4 of 7 checks passed
LoganZhuZzz pushed a commit to LoganZhuZzz/kafka that referenced this pull request Aug 28, 2024
bboyleonp666 pushed a commit to bboyleonp666/kafka that referenced this pull request Sep 4, 2024
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.

3 participants