eclipse-typescript icon indicating copy to clipboard operation
eclipse-typescript copied to clipboard

Possible problems on deleting output files on clean

Open barakka opened this issue 12 years ago • 11 comments

First my configuration as reference:

  • Windows OS;
  • Using git, with generated output files tracked;
  • Eclipse "Build automatically" active;
  • Source build path set, output folder empty (but that is equal to setting it to "").

I've detected two possible problems with deleting the generated output files during clean (in TypeScriptBuilder):

  1. If the file being deleted is in use, the build fails (with a nasty error message). It happened to me when testing my app, possibly because the browser was locking the js or map files. If I edit and save one file, the automatic build triggers clean and rebuild, the clean fails and the output is not regenerated. I've fixed it try/catching the delete operation, and ignoring the failure, as the compile operation works fine even if the file is locked;

  2. Every time the project is rebuilt (for instance, just opening eclipse), all the generated output files are marked by git as deleted and re-added, which marks the project has modified with pending changes, even if no change occurred. Possibly this can be solved setting some git option, but given that the default behaviour is to track those changes, it is a little annoying.

barakka avatar Aug 28 '13 09:08 barakka

We could probably remove the clean code but won't writing new files run into the same issue? I haven't heard of any scenarios in which it would be desirable to track the output files before, what is the use case?

derekcicerone-zz avatar Aug 28 '13 14:08 derekcicerone-zz

At least in my case, writing to the file did not create any problem, while failing on the delete would stop the incremental build for any file.

With respect to why tracking generated files it is needed for two reasons:

  1. our build tool-chain is maven based, and the typescript support for maven is quite reduced (there is an half decent plugin, with a some issues however). Therefore I have to ensure that my build server receives the generated output from source control, as it will not be able to regenerate it outside eclipse (in Jenkins in this case). There several ways in which I could fix, the plugin above, some ant script using tsc from the command line, etc. buy the all bring hassles.
  2. I'm the only person working with typescript on my team, but the other teammates still need the generated output to the test the app in their environment. If I don't track the generated output, the only other way is to force all of my teammates to install the eclipse plugin (and node!!! By the way, it would be great if node could be in some way directly packaged with the plugin, without requiring a separate download).

barakka avatar Aug 28 '13 15:08 barakka

Ok, I think the best thing to do is probably just remove the clean logic for now then to unblock you.

I'm not sure how we could package up node with the plug-in since it requires different binaries for each platform. I suspect it would greatly increase the size of the download. If you find any info out though, please let me know.

derekcicerone-zz avatar Aug 28 '13 16:08 derekcicerone-zz

If I'm the only one having this type of problems, don't worry about changing the current behavior. I've already put deleting behind a preference in my repo, so I'm not blocked.

You might wan't to try/catch the deleting of resources in any case, just to play it safe.

barakka avatar Aug 28 '13 16:08 barakka

I've always considered the deletion logic a bit suspect so I think it should probably go. The only cleanup we should really be doing is deleting corresponding JavaScript and source map files when a .ts file is deleted (or renamed).

derekcicerone-zz avatar Aug 28 '13 16:08 derekcicerone-zz

It looks like this issue has re-emerged in last versions of the plugin, when using the "Compile all TypeScript files on build" option. This also happens with svn, and it seems limited to full builds.

barakka avatar Jan 20 '15 10:01 barakka

What behavior are you seeing specifically?

derekcicerone-zz avatar Jan 20 '15 13:01 derekcicerone-zz

We have a project with typescript activated, with only the source folder configured (all other paths are empty). We commit every file, both the .ts and the generated .js and .map.js and the workspace is clean.

We then close eclipse and restart it. As soon as eclipse completes rebuilding the project, the generated files are either marked as changed (in case of .git repo), or marked as deleted (in svn repo).

Git seems smarter, 'cos attempting a synchronize afterwards shows no changes. But the svn team provider includes the resources for deletion. Please note that the generated files are there, they are just marked as deleted (and will be deleted if one commits). Changing a source to force the update of the generated ones has the same effect, with the generated file being physically there but marked for delete.

The problem, I believe, depends on the fact that cleaning the project removes the generated files (which would be normal in the general case, but a problem in out setup), and a full build seems to issue a clean and then a compile.

Originally I had patched the plugin to delete the generated files only if the source file was deleted, but we have since then switched to the original plugin to receive the new updates.

Honestly I don't know which could be a good solution satisfying all use cases. Maybe a configuration switch that would avoid cleaning generated resources during a clean (as silly as it might be)?

barakka avatar Jan 20 '15 15:01 barakka

For a full build, I believe that delete and rebuild is the expected behavior, right? Restarting eclipse shouldn't automatically trigger a full rebuild though - is that a workspace option perhaps?

derekcicerone-zz avatar Jan 20 '15 15:01 derekcicerone-zz

Don't think so. We just have the workspace set up with "Build automatically" and I believe that triggers the build (for instance after a svn checkout).

But the problem is unrelated with re-opening eclipse. We can just commit everything, call for a full build without touching any source and we would get the generated files not only marked as modified (which we could live with) but also marked as deleted (with svn), which then generates all types of commit problems.

The problem might be with the svn team provider, that once it detects the file has been deleted it keeps it marked deleted even if regenerated. But I've not found any svn option to change this behavior.

barakka avatar Jan 20 '15 15:01 barakka

Hmm, I'm looking at the code now and I don't see where the compiled JavaScript file would be deleted during normal compilation. They would definitely be deleted during a clean build but that should be it.

derekcicerone-zz avatar Jan 20 '15 19:01 derekcicerone-zz