How to trigger builds using Eclipse API?

98 views
Skip to first unread message

David Hofmann

unread,
Oct 25, 2014, 1:51:35 PM10/25/14
to elysiu...@googlegroups.com
Hi,

I'm trying to figure out how to trigger a LilyPond Compilation from the Eclipse API.

I have a plugin that generates a .ly file in an eclipse project and want to invoke the compilation process.
To achieve this, I have tried the following:

- Refresh all resources recursively, tried the parent folder and the whole project
- I tried to run IProject.build()

Both did not work for me. I noticed that although my project has a LilyPond nature, it has no "Lily Pond Builder", so I suppose the compilation is triggered by another mechanism.

Right now I can only let my plugin generate the .ly file, then open it in an editor, make some random change and save the file again. Then it is compiled.
How can I invoke the compilation for a file in a project using the Eclipse API?

Thanks in advance for any hints!

Best,
Dave
signature.asc

Dénes Harmath

unread,
Oct 25, 2014, 2:10:56 PM10/25/14
to elysiu...@googlegroups.com
Hi,

it's great that you are developing an Eclipse plugin that generates LilyPond files and takes advantage of Elysium! I would be eager to know what is its purpose.
Building LilyPond projects is done via Xtext (as a so-called builder participant), so the Xtext builder has to be present on the project (id: org.eclipse.xtext.ui.shared.xtextBuilder). Please report if this has solved your problem.

Best,
thSoft

David Hofmann

unread,
Oct 26, 2014, 11:39:11 AM10/26/14
to elysiu...@googlegroups.com
Hi,

the plugin is part of a research project which is concerned with algorithmic composition and uses LilyPond as an output format to render the score and produce a MIDI file.

The project has a LilyPond nature and also an Xtext Builder installed. However, if I create new .ly files programmatically they are not recognized by the builder, even if I refresh the resources and run IProject.build(). It is only recognized if I perform a manual change in the file and save it again. Do I have to register new resources in Xtext somehow in order to update the resource descriptions?

Thanks and best regards,
Dave
signature.asc

Harmath Dénes

unread,
Oct 28, 2014, 7:18:46 AM10/28/14
to elysiu...@googlegroups.com
2014-10-26 16:37 GMT+01:00 David Hofmann <david....@gmail.com>:
Hi,

the plugin is part of a research project which is concerned with algorithmic composition and uses LilyPond as an output format to render the score and produce a MIDI file.

Cool!
 
The project has a LilyPond nature and also an Xtext Builder installed. However, if I create new .ly files programmatically they are not recognized by the builder, even if I refresh the resources and run IProject.build(). It is only recognized if I perform a manual change in the file and save it again. Do I have to register new resources in Xtext somehow in order to update the resource descriptions?

Have you tried performing a full build with project.build(IncrementalProjectBuilder.FULL_BUILD, ...)?

David Hofmann

unread,
Oct 28, 2014, 9:51:57 AM10/28/14
to elysiu...@googlegroups.com
Hi :)

Yes I have tried a full build. I just debugged it and I think I found the relevant lines in LilyPondBuilder.build():

boolean changed = (delta.getNew() != null) && (delta.getOld() != null);
if (changed && delta.haveEObjectDescriptionsChanged()) {
filesToCompile.add(file);
} else {
filesMarkedAsOutdated.add(file);
}

For the newly created file changed evaluates to true, but delta.haveEObjectDescriptionsChanged() evaluates to false. That's why the file is not added to the filesToCompile list. Any idea how I could enforce such a EObjectDescriptionChange programatically? Or is this a bug as it does not consider new files?

Best,
Dave
signature.asc

Dénes Harmath

unread,
Nov 2, 2014, 2:40:04 AM11/2/14
to elysiu...@googlegroups.com
Oh, I think this is a "feature", not a bug. I fixed this in r9931ac5, I'm going to release it soon.

David Hofmann

unread,
Nov 9, 2014, 7:05:11 AM11/9/14
to elysiu...@googlegroups.com
Hi Dénes,

thank you very much for fixing the issue. I just checked but found no updates at http://eclipse.thsoft.hu. Is the URL wrong or was it not released yet?

Best,
Dave
signature.asc

Dénes Harmath

unread,
Nov 9, 2014, 7:51:35 AM11/9/14
to elysiu...@googlegroups.com
Sorry for being late, please try to Check for updates.

David Hofmann

unread,
Nov 14, 2014, 4:42:46 AM11/14/14
to elysiu...@googlegroups.com
Thank you very much for publishing the update, I have installed it but unfortunately the problem is still not solved.
When debugging the same method in LilyPondBuilder, this time descriptionsChanged evaluates to true but resourcesChanged evaluates to false. This is because delta.getNew() returns an instance of DefaultResourceDescriptionDelta, but delta.getOld() returns null for my newly created file. According to the current code both delta.getNew() and delta.getOld() must be != null. Can you adjust this for newly created files, i.e. if getOld() is null?

Thank you and best regards,
Dave
signature.asc

Dénes Harmath

unread,
Nov 14, 2014, 5:10:33 AM11/14/14
to elysiu...@googlegroups.com
Oh yeah, that was the actual cause. :) Sorry for the confusion. I released a tested fix now.
Just an advice: if possible, please use the issue tracker for bug reports and enhancement requests in the future. :) Thank you in advance!
Also I would be eager to see your research project, please share it when it is ready. :)

David Hofmann

unread,
Nov 14, 2014, 5:24:04 AM11/14/14
to elysiu...@googlegroups.com
Yeehaw, it works like a charm now, thanks :)
And of course next time I'll use the tracker.

cheerz,
Dave

P.S.: I'll let you know if there are nice results from my research project ;)
signature.asc
Reply all
Reply to author
Forward
0 new messages