Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Can builder change delta?
Can builder change delta? [message #335866] Wed, 06 May 2009 22:08 Go to next message
Johan Van Noten is currently offline Johan Van NotenFriend
Messages: 87
Registered: July 2009
Member
My intention:

I'm planning to introduce an additional Builder in front of the normal
build chain (CDT in our case, but that is not very relevant). This Builder
needs to patch the source files, next the normal build chain should build
as usual.

My problems:
* It doesn't feel 'right' to use a builder that takes a file, patches it
and saves the same file. Typically you would expect a builder to take a
source and generate a new artifact from it. Am I abusing the
IncrementalProjectBuilder here? Should I handle the requirement of
"in-place modification" in another way?

* Moreover, my builder could need to go and change files that were not in
the original delta. This means that Eclipse calls my builder with a
certain delta, next my builder modifies some additional files.
Unfortunately, the next builder seems to get the same delta as my own
first builder. The delta is not adjusted "along the way". Is this normal?

Thanks for your feedback,
Johan
Re: Can builder change delta? [message #335895 is a reply to message #335866] Fri, 08 May 2009 06:47 Go to previous messageGo to next message
Walter Harley is currently offline Walter HarleyFriend
Messages: 847
Registered: July 2009
Senior Member
"Johan Van Noten" <johan@qootec.be> wrote in message
news:7566a3ea46a0adc037386d5617ed6417$1@www.eclipse.org...
> My intention:
>
> I'm planning to introduce an additional Builder in front of the normal
> build chain (CDT in our case, but that is not very relevant). This Builder
> needs to patch the source files, next the normal build chain should build
> as usual.
>
> My problems:
> * It doesn't feel 'right' to use a builder that takes a file, patches it
> and saves the same file. Typically you would expect a builder to take a
> source and generate a new artifact from it. Am I abusing the
> IncrementalProjectBuilder here? Should I handle the requirement of
> "in-place modification" in another way?
>
> * Moreover, my builder could need to go and change files that were not in
> the original delta. This means that Eclipse calls my builder with a
> certain delta, next my builder modifies some additional files.
> Unfortunately, the next builder seems to get the same delta as my own
> first builder. The delta is not adjusted "along the way". Is this normal?


What will you do if the source files are read-only, as they might be in a
"pessimistic" version control system such as Perforce?

I don't think you can change resources during a build. I think you may get
a deadlock, as the builder has a lock on the workspace. I'm not sure about
that. Regardless, I am pretty sure you won't be able to change deltas
mid-build.

Can you build your modified source files to an intermediate location,
instead of trying to overwrite the existing ones?
Re: Can builder change delta? [message #335901 is a reply to message #335866] Fri, 08 May 2009 09:40 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
I don't think modifying source files in a build would hurt. I've done
this in Cypal Studio for GWT, in which a builder updates the *Async.java
.. So far no errors due to that (that doesn't mean there is none).
However, I've not attempted to modify the delta, and don't think that is
a good idea.

- Prakash

---
http://blog.eclipse-tips.com
Re: Can builder change delta? [message #335907 is a reply to message #335895] Fri, 08 May 2009 14:36 Go to previous messageGo to next message
Johan Van Noten is currently offline Johan Van NotenFriend
Messages: 87
Registered: July 2009
Member
Walter Harley wrote:

> What will you do if the source files are read-only, as they might be in a
> "pessimistic" version control system such as Perforce?
The concept of our plugin would only work on sources for which you have
the right to change them. In that sense this would not cause a major
difficulty IMHO.

> I don't think you can change resources during a build. I think you may get
> a deadlock, as the builder has a lock on the workspace. I'm not sure about
> that. Regardless, I am pretty sure you won't be able to change deltas
> mid-build.
I'm quite convinced that I can modify them "technically". I do all
modifications from within the workspace through the IDocument interface.
It all seems to work if I only change sources that were already included
in the delta.

Unfortunately, I can also start modifying sources at build time even when
they were not modified by the user.

For this to be understandable, I should explain briefly our purpose. Think
about a kind of source code instrumentation scenario. Our builder would
use some additional resources in the project that contain information on
which sources to instrument in what way. A change to this information
could have influence on the patching that needs to happen on some of the
project's sources, even if these sources were not modified before the
build starts. We are "rewriting" part of the code in an automatic way.

That brings me to your next remark:
> Can you build your modified source files to an intermediate location,
> instead of trying to overwrite the existing ones?
The answer is: not really. We want the rewritten code to become the real
source code. The customer wants that rewritten code to be checked in and
later to be used for e.g. debugging containing our modifications.

Do you feel this requirement should be fullfilled differently?

Johan
Re: Can builder change delta? [message #335910 is a reply to message #335901] Fri, 08 May 2009 14:45 Go to previous messageGo to next message
Johan Van Noten is currently offline Johan Van NotenFriend
Messages: 87
Registered: July 2009
Member
I understand that your builder is updating the contents of a source file
that was scheduled for building. This feels like a scenario in which you
need to "patch" the file before passing it on to a next build step. Is
that correct?

In that case our scenario is very close to yours, except that we sometimes
need to patch files that were not included in the original delta (because
they were unmodified up to that time). Once we modify them, they should of
course end up being built by the next builder in the chain. This raised
the requirement of changing the delta "on-the-fly".
Re: Can builder change delta? [message #335923 is a reply to message #335907] Sat, 09 May 2009 02:59 Go to previous messageGo to next message
Walter Harley is currently offline Walter HarleyFriend
Messages: 847
Registered: July 2009
Senior Member
"Johan Van Noten" <johan@qootec.be> wrote in message
news:e861d7745ce9466d22ff807cdbd69540$1@www.eclipse.org...
> For this to be understandable, I should explain briefly our purpose. Think
> about a kind of source code instrumentation scenario. Our builder would
> use some additional resources in the project that contain information on
> which sources to instrument in what way. A change to this information
> could have influence on the patching that needs to happen on some of the
> project's sources, even if these sources were not modified before the
> build starts. We are "rewriting" part of the code in an automatic way.

It seems very strange to me to do this in a builder, if it is a one-time
modification of the code. Why not something more like a wizard or
refactoring action?

To me as a user it would seem peculiar if doing a build also caused the
source code that I was editing to change underneath me.

Anyway, it sounds like Prakash has more encouragement for you than I do, so
I would listen to him instead :-)
Re: Can builder change delta? [message #335956 is a reply to message #335866] Mon, 11 May 2009 14:54 Go to previous message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

Johan Van Noten wrote:
> My intention:
>
> I'm planning to introduce an additional Builder in front of the normal
> build chain (CDT in our case, but that is not very relevant). This
> Builder needs to patch the source files, next the normal build chain
> should build as usual.
>
> My problems:
> * It doesn't feel 'right' to use a builder that takes a file, patches it
> and saves the same file. Typically you would expect a builder to take a
> source and generate a new artifact from it. Am I abusing the
> IncrementalProjectBuilder here? Should I handle the requirement of
> "in-place modification" in another way?

The only other option I can think of would be to do the "patching"
during save (as opposed to waiting until a build). If you have your own
editor for thses files, that is pretty easy to do in its save method(s);
if you're relying on a built-in editor it might not be so easy. I know
the Java editor has the notion of "save actions" or "save participants"
so perhaps that is a platform-general thing (as opposed to a
JDT-specific thing) that you could investigate...


>
> * Moreover, my builder could need to go and change files that were not
> in the original delta. This means that Eclipse calls my builder with a
> certain delta, next my builder modifies some additional files.
> Unfortunately, the next builder seems to get the same delta as my own
> first builder. The delta is not adjusted "along the way". Is this normal?

I don't know if altering the delta mid-stream would work or would be a
good idea. But if you touch other resources, that should just generate
another delta that will in turn trigger another build. You'd have to be
careful to avoid infinite loops of builds continually modifying
resources that trigger more builds.

Hope this helps,
Eric
Previous Topic:[DataBinding] Databinding a ListViewer to a model list
Next Topic:Tabbed Properties Image Leaks?
Goto Forum:
  


Current Time: Fri Jul 05 05:18:57 GMT 2024

Powered by FUDForum. Page generated in 0.03896 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top