Skip to content

"./gradlew clean" should remove files from generated source dirs #24

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
edenman opened this issue Jul 7, 2015 · 6 comments
Closed

"./gradlew clean" should remove files from generated source dirs #24

edenman opened this issue Jul 7, 2015 · 6 comments

Comments

@edenman
Copy link
Contributor

edenman commented Jul 7, 2015

I'm setting generatedFilesBaseDir = "$projectDir/src/generated" so IntelliJ can more easily recognize my generated proto .java files as sources. When I re-generate these files, I want a clean to remove them (in case I renamed a class with java_outer_classname, for instance)

@edenman
Copy link
Contributor Author

edenman commented Jul 7, 2015

Workaround is just to augment the clean task:

protobuf {
    ...
    clean {
      delete generatedFilesBaseDir
    }
}

@zhangkun83 zhangkun83 added this to the 0.6.0 milestone Jul 9, 2015
@zhangkun83 zhangkun83 removed this from the 0.6.0 milestone Aug 12, 2015
@zhangkun83
Copy link
Collaborator

I am concerned about the safety of this feature. Because generatedFilesBaseDir can point to any directory, even outside of the project and may contain other non-generated files, deleting it indistinguishably can be dangerous. I would expect IntelliJ should allow you to specify sources under the build directory. If it's not the case, your workaround seems fine.

@edenman
Copy link
Contributor Author

edenman commented Aug 12, 2015

imho:

  • If you point generatedFilesBaseDir outside your project, you deserve to have that directory deleted. What even would be the point of that?
  • If you point generatedFilesBaseDir at a directory inside your project and it contains other non-generated files, what even would be the point of that? Also, that's what version control is for.

@zhangkun83
Copy link
Collaborator

If you point generatedFilesBaseDirat a directory inside your project and it contains other non-generated files, what even would be the point of that?

I can imagine some people pointing generatedFilesBaseDir to $projectDir/src/ for convenience. Maybe it's not necessary at all, but people may think it is and do it anyway. This may lead to deleting their own sources. Yes we have version control, but you may still lose local edits and sometimes it's siginificant loss.

Technically you are right, but people make mistakes, and I don't want their trivial mistakes to easily turn into accidents.

In general, I don't want to encourage the practice of putting generated files outside of build. Files generated in the build process should stay inside build. It's fine that you have a good reason and you want to do it anyway, but it's not the norm that we want to support.

@Shad0w1nk
Copy link

If it's not recommended, why not deprecate the possibility. That way the problem will not be present.

For a possible solution, Gradle would have to know how, in term of file path, protoc is transforming the inputs. This would enable incremental compilation as we would know which files to remove when a proto file is deleted to keep everything up to date. Saving the processed information in a temporary file would enable both incremental compilation and cleaning. The only problem is the duplicate information between protoc and Gradle. If we can get the knowledge from protoc, then it wouldn't be a problem. Let me know what you guys think.

@zhangkun83
Copy link
Collaborator

Let's move the discussion to #33

podarsmarty pushed a commit to podarsmarty/protobuf-gradle-plugin that referenced this issue Jul 22, 2016
Instead of the app blanking out to a white screen, it should be closed
instead.
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

No branches or pull requests

3 participants