Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Buckminster » Call jdt.ant from buckminster.prebind?
Call jdt.ant from buckminster.prebind? [message #518585] Thu, 04 March 2010 14:53 Go to next message
Patrick Ruckstuhl is currently offline Patrick RuckstuhlFriend
Messages: 64
Registered: July 2009
Member
Is there a way to call an jdt.ant action from buckminster.prebind?

I'm working on an xtext based plugin which needs to generate classes for the compilation. But for the generation itself the classpath of the project is needed.


The project contains a src and a src-gen directory. Contents of the src-gen directory are generated by an xtext workflow which I can call from an ant task but need the classpath of the project for the call.

If I try to launch the task from the prebind the action fails and it looks like the classpath is not yet specified. If I call the manually after everything is done, the action works fine.
Re: Call jdt.ant from buckminster.prebind? [message #518643 is a reply to message #518585] Thu, 04 March 2010 16:40 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3231
Registered: July 2009
Senior Member
Hi Patrick,
The way we usually solve this is by using the Buckminster classpath emitter. It's an eclipse builder that can be added
to your .project file like so:

<buildCommand>
<name>org.eclipse.buckminster.jdt.classpathEmitter</name>
<arguments>
<dictionary>
<key>full.printstream</key>
<value>false</value>
</dictionary>
<dictionary>
<key>file</key>
<value>make/bm.properties</value>
</dictionary>
</arguments>
</buildCommand>

In this example, I assume that there is a 'make' folder at the project root. The emitter will put a properties file in
this folder that includes the full classpath. An ant target in a build.xml file can then access this by doing:

<property file="bm.properties"/>

and then, in some target something similar to:

<javac ...>
<classpath>
<pathelement path="${bm.classpath}"/>
</classpath>
</javac>

HTH,
- thomas


On 03/04/2010 03:53 PM, Patrick Ruckstuhl wrote:
> Is there a way to call an jdt.ant action from buckminster.prebind?
>
> I'm working on an xtext based plugin which needs to generate classes for
> the compilation. But for the generation itself the classpath of the
> project is needed.
>
>
> The project contains a src and a src-gen directory. Contents of the
> src-gen directory are generated by an xtext workflow which I can call
> from an ant task but need the classpath of the project for the call.
>
> If I try to launch the task from the prebind the action fails and it
> looks like the classpath is not yet specified. If I call the manually
> after everything is done, the action works fine.
Re: Call jdt.ant from buckminster.prebind? [message #518646 is a reply to message #518585] Thu, 04 March 2010 16:57 Go to previous messageGo to next message
Patrick Ruckstuhl is currently offline Patrick RuckstuhlFriend
Messages: 64
Registered: July 2009
Member
But if the classpath is produced from the eclipse build, I can't call this in the preBind, can I?

When the project is loaded in the eclipse workspace, the action I currently have that uses the jdt.ant agent works fine.

What I want to somehow do is:

-get plugin and get jdt classpath for the plugin
-run my action
-load and compile the plugin in eclipse


What currently works is

-get plugin
-load and try to compile the plugin in eclipse (still has errors)
-run my action
-build plugin in eclipse again
Re: Call jdt.ant from buckminster.prebind? [message #518658 is a reply to message #518646] Thu, 04 March 2010 17:11 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3231
Registered: July 2009
Senior Member
On 03/04/2010 05:57 PM, Patrick Ruckstuhl wrote:
> But if the classpath is produced from the eclipse build, I can't call
> this in the preBind, can I?
>
Ah, missed that part. You want the classpath even before you bind the project to the workspace?

> When the project is loaded in the eclipse workspace, the action I
> currently have that uses the jdt.ant agent works fine.
>
All ant targets that have been registered with your eclipse runtime should be callable from a buckminster ant actor. We
use the Eclipse ant launcher internally.

> What I want to somehow do is:
>
> -get plugin and get jdt classpath for the plugin
> -run my action
> -load and compile the plugin in eclipse
>
Try having your prebind action call on an ant actor. Try calling the jdt.ant from the build script that this actor uses.

- thomas
Re: Call jdt.ant from buckminster.prebind? [message #518659 is a reply to message #518585] Thu, 04 March 2010 17:20 Go to previous messageGo to next message
Patrick Ruckstuhl is currently offline Patrick RuckstuhlFriend
Messages: 64
Registered: July 2009
Member
Yes I want the classpath before the project is bound to the workspace.

> Try having your prebind action call on an ant actor. Try calling the jdt.ant from the build script that this actor uses.

I don't understand this.
The reason for using a jdt.ant actor is that I get the classpath, if I use an ant actor I don't get the classpath.


Thank you very much for your help.
Re: Call jdt.ant from buckminster.prebind? [message #518694 is a reply to message #518659] Thu, 04 March 2010 14:04 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3231
Registered: July 2009
Senior Member
Hi Patrick,
I misunderstood what you meant by "jdt.ant". Thought it was something that the JDT provided.

The jdt.ant actor will not be able to produce the class path until you have bound the component to the workspace since
it relies on that the component indeed is a project. So I'm afraid you have a catch 22 situation.

An alternative to using the prebind action could be to try using the classpath emitter I proposed earlier with an
associated ant task. Both triggered from the .project file. I imagine that you can make things happen in the right order
if the source generation precedes the declaration of the org.eclipsejdt.core.javabuilder in the .project file. The
drawback is that the source generation will be part of the incremental build process which can sometimes be a burden
(it's triggered whenever resources are saved). But perhaps that's actually what you want?

Below is a snippet from the .project file of our jdt bundle. It ensures that the classpath is emitted and that our jdt
ant tasks are built as part of the standard eclipse incremental build process. Using the buckminster.ant.AntBuilder will
ensure that everything is lightweight and runs in a headless environment.

Regards,
Thomas Hallgren

<buildCommand>
<name>org.eclipse.buckminster.jdt.classpathEmitter</name>
<arguments>
<dictionary>
<key>full.printstream</key>
<value>false</value>
</dictionary>
<dictionary>
<key>file</key>
<value>make/bm.properties</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buckminster.ant.AntBuilder</name>
<arguments>
<dictionary>
<key>refresh.resource</key>
<value>.</value>
</dictionary>
<dictionary>
<key>delta.resource</key>
<value>src/ant_tasks</value>
</dictionary>
<dictionary>
<key>given.name</key>
<value>Internal Ant Builder support compile</value>
</dictionary>
<dictionary>
<key>script.file</key>
<value>make/build.xml</value>
</dictionary>
<dictionary>
<key>derived.resource</key>
<value>ant_tasks/</value>
</dictionary>
</arguments>
</buildCommand>
Re: Call jdt.ant from buckminster.prebind? [message #518702 is a reply to message #518694] Thu, 04 March 2010 19:16 Go to previous messageGo to next message
Achim Demelt is currently offline Achim DemeltFriend
Messages: 160
Registered: July 2009
Senior Member
Hi Patrick,

We're using the following CSPEX to advise the Xtext code generation before
the actual build. The build.xml file can pick up the classpath from the
classpathEmitter as shown in Thomas' earlier post.

With this solution, you can generate the DSL on-demand using the regular MWE
workflow in the IDE, but when built headlessly, the CSPEX makes sure that
the generator is invoked.

Cheers,
Achim

<?xml version="1.0" encoding="UTF-8"?>
<cs:cspecExtension
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bc="http://www.eclipse.org/buckminster/Common-1.0"
xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0">
<cs:actions>
<cs:public name="generate.dsl" actor="ant">
<cs:actorProperties>
<cs:property key="buildFile"
value="build.xml"/>
<cs:property key="targets"
value="generate"/>
</cs:actorProperties>
</cs:public>
</cs:actions>
<cs:alterActions>
<cs:public name="eclipse.build">
<cs:prerequisites>
<cs:attribute name="generate.dsl"/>
</cs:prerequisites>
</cs:public>
</cs:alterActions>
</cs:cspecExtension>


Thomas Hallgren wrote:

> Hi Patrick,
> I misunderstood what you meant by "jdt.ant". Thought it was something that
> the JDT provided.
>
> The jdt.ant actor will not be able to produce the class path until you
> have bound the component to the workspace since it relies on that the
> component indeed is a project. So I'm afraid you have a catch 22
> situation.
>
> An alternative to using the prebind action could be to try using the
> classpath emitter I proposed earlier with an associated ant task. Both
> triggered from the .project file. I imagine that you can make things
> happen in the right order if the source generation precedes the
> declaration of the org.eclipsejdt.core.javabuilder in the .project file.
> The drawback is that the source generation will be part of the incremental
> build process which can sometimes be a burden (it's triggered whenever
> resources are saved). But perhaps that's actually what you want?
>
> Below is a snippet from the .project file of our jdt bundle. It ensures
> that the classpath is emitted and that our jdt ant tasks are built as part
> of the standard eclipse incremental build process. Using the
> buckminster.ant.AntBuilder will ensure that everything is lightweight and
> runs in a headless environment.
>
> Regards,
> Thomas Hallgren
>
> <buildCommand>
> <name>org.eclipse.buckminster.jdt.classpathEmitter</name>
> <arguments>
> <dictionary>
> <key>full.printstream</key>
> <value>false</value>
> </dictionary>
> <dictionary>
> <key>file</key>
> <value>make/bm.properties</value>
> </dictionary>
> </arguments>
> </buildCommand>
> <buildCommand>
> <name>org.eclipse.buckminster.ant.AntBuilder</name>
> <arguments>
> <dictionary>
> <key>refresh.resource</key>
> <value>.</value>
> </dictionary>
> <dictionary>
> <key>delta.resource</key>
> <value>src/ant_tasks</value>
> </dictionary>
> <dictionary>
> <key>given.name</key>
> <value>Internal Ant Builder support compile</value>
> </dictionary>
> <dictionary>
> <key>script.file</key>
> <value>make/build.xml</value>
> </dictionary>
> <dictionary>
> <key>derived.resource</key>
> <value>ant_tasks/</value>
> </dictionary>
> </arguments>
> </buildCommand>
Re: Call jdt.ant from buckminster.prebind? [message #518713 is a reply to message #518702] Thu, 04 March 2010 19:29 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3231
Registered: July 2009
Senior Member
Much cleaner then my proposal. Thanks Achim.

- thomas

On 03/04/2010 08:16 PM, Achim Demelt wrote:
> Hi Patrick,
>
> We're using the following CSPEX to advise the Xtext code generation before
> the actual build. The build.xml file can pick up the classpath from the
> classpathEmitter as shown in Thomas' earlier post.
>
> With this solution, you can generate the DSL on-demand using the regular MWE
> workflow in the IDE, but when built headlessly, the CSPEX makes sure that
> the generator is invoked.
>
> Cheers,
> Achim
>
> <?xml version="1.0" encoding="UTF-8"?>
> <cs:cspecExtension
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:bc="http://www.eclipse.org/buckminster/Common-1.0"
> xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0">
> <cs:actions>
> <cs:public name="generate.dsl" actor="ant">
> <cs:actorProperties>
> <cs:property key="buildFile"
> value="build.xml"/>
> <cs:property key="targets"
> value="generate"/>
> </cs:actorProperties>
> </cs:public>
> </cs:actions>
> <cs:alterActions>
> <cs:public name="eclipse.build">
> <cs:prerequisites>
> <cs:attribute name="generate.dsl"/>
> </cs:prerequisites>
> </cs:public>
> </cs:alterActions>
> </cs:cspecExtension>
>
>
> Thomas Hallgren wrote:
>
>> Hi Patrick,
>> I misunderstood what you meant by "jdt.ant". Thought it was something that
>> the JDT provided.
>>
>> The jdt.ant actor will not be able to produce the class path until you
>> have bound the component to the workspace since it relies on that the
>> component indeed is a project. So I'm afraid you have a catch 22
>> situation.
>>
>> An alternative to using the prebind action could be to try using the
>> classpath emitter I proposed earlier with an associated ant task. Both
>> triggered from the .project file. I imagine that you can make things
>> happen in the right order if the source generation precedes the
>> declaration of the org.eclipsejdt.core.javabuilder in the .project file.
>> The drawback is that the source generation will be part of the incremental
>> build process which can sometimes be a burden (it's triggered whenever
>> resources are saved). But perhaps that's actually what you want?
>>
>> Below is a snippet from the .project file of our jdt bundle. It ensures
>> that the classpath is emitted and that our jdt ant tasks are built as part
>> of the standard eclipse incremental build process. Using the
>> buckminster.ant.AntBuilder will ensure that everything is lightweight and
>> runs in a headless environment.
>>
>> Regards,
>> Thomas Hallgren
>>
>> <buildCommand>
>> <name>org.eclipse.buckminster.jdt.classpathEmitter</name>
>> <arguments>
>> <dictionary>
>> <key>full.printstream</key>
>> <value>false</value>
>> </dictionary>
>> <dictionary>
>> <key>file</key>
>> <value>make/bm.properties</value>
>> </dictionary>
>> </arguments>
>> </buildCommand>
>> <buildCommand>
>> <name>org.eclipse.buckminster.ant.AntBuilder</name>
>> <arguments>
>> <dictionary>
>> <key>refresh.resource</key>
>> <value>.</value>
>> </dictionary>
>> <dictionary>
>> <key>delta.resource</key>
>> <value>src/ant_tasks</value>
>> </dictionary>
>> <dictionary>
>> <key>given.name</key>
>> <value>Internal Ant Builder support compile</value>
>> </dictionary>
>> <dictionary>
>> <key>script.file</key>
>> <value>make/build.xml</value>
>> </dictionary>
>> <dictionary>
>> <key>derived.resource</key>
>> <value>ant_tasks/</value>
>> </dictionary>
>> </arguments>
>> </buildCommand>
>
Re: Call jdt.ant from buckminster.prebind? [message #518761 is a reply to message #518713] Thu, 04 March 2010 22:37 Go to previous messageGo to next message
Patrick Ruckstuhl is currently offline Patrick RuckstuhlFriend
Messages: 64
Registered: July 2009
Member
I think I can even keep my jdt.ant task which is simpler and does not require any changes to the project.

I'll just use your idea with only running the workflow automatically in the automatic build or if the target is called manually.

Currently my prerequisite is on eclipse.build.source
which is better? Is there any "big picture" overview of the various actions and when which one is called automatically?

Is only the buckminster.preBind automatically called and everything else only if it is run manually?

My original idea was that the developers would not need to do anything and directly get a full project without manual intervention.

Thinking about it, a postBind that would be automatically called could do exactly what I need, does something like this exist?
Re: Call jdt.ant from buckminster.prebind? [message #527180 is a reply to message #518702] Wed, 14 April 2010 11:27 Go to previous messageGo to next message
Stefan Weise is currently offline Stefan WeiseFriend
Messages: 8
Registered: July 2009
Junior Member
Hi Achim,

can you please give me a hint what classpath entries I need to be able to execute the
workflowrunner? At the moment I get the following error:

taskdef class org.eclipse.emf.mwe.core.ant.WorkflowAntTask cannot be found

Cheers,

Stefan

Am 04.03.10 20:16, schrieb Achim Demelt:
> Hi Patrick,
>
> We're using the following CSPEX to advise the Xtext code generation before
> the actual build. The build.xml file can pick up the classpath from the
> classpathEmitter as shown in Thomas' earlier post.
>
> With this solution, you can generate the DSL on-demand using the regular MWE
> workflow in the IDE, but when built headlessly, the CSPEX makes sure that
> the generator is invoked.
>
> Cheers,
> Achim
>
> <?xml version="1.0" encoding="UTF-8"?>
> <cs:cspecExtension
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:bc="http://www.eclipse.org/buckminster/Common-1.0"
> xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0">
> <cs:actions>
> <cs:public name="generate.dsl" actor="ant">
> <cs:actorProperties>
> <cs:property key="buildFile"
> value="build.xml"/>
> <cs:property key="targets"
> value="generate"/>
> </cs:actorProperties>
> </cs:public>
> </cs:actions>
> <cs:alterActions>
> <cs:public name="eclipse.build">
> <cs:prerequisites>
> <cs:attribute name="generate.dsl"/>
> </cs:prerequisites>
> </cs:public>
> </cs:alterActions>
> </cs:cspecExtension>
>
>
Re: Call jdt.ant from buckminster.prebind? [message #527297 is a reply to message #527180] Wed, 14 April 2010 17:27 Go to previous messageGo to next message
Patrick Ruckstuhl is currently offline Patrick RuckstuhlFriend
Messages: 64
Registered: July 2009
Member
See

http://svn.origo.ethz.ch/wsvn/aranea/trunk/dev/ch.ethz.origo .aranea.messagedsl/buckminster.cspex

and

http://svn.origo.ethz.ch/wsvn/aranea/trunk/dev/ch.ethz.origo .aranea.messagedsl/build.xml


This way the ant task is run with the same classpath as the project itself.
Re: Call jdt.ant from buckminster.prebind? [message #527409 is a reply to message #527297] Thu, 15 April 2010 08:03 Go to previous message
Stefan Weise is currently offline Stefan WeiseFriend
Messages: 8
Registered: July 2009
Junior Member
Now it works.

Thanks,

Stefan

Am 14.04.10 19:27, schrieb Patrick Ruckstuhl:
> See
> http://svn.origo.ethz.ch/wsvn/aranea/trunk/dev/ch.ethz.origo .aranea.messagedsl/buckminster.cspex
>
>
> and
> http://svn.origo.ethz.ch/wsvn/aranea/trunk/dev/ch.ethz.origo .aranea.messagedsl/build.xml
>
>
>
> This way the ant task is run with the same classpath as the project itself.
Previous Topic:BuckyBook revision 0.7 available for download
Next Topic:Default Platform created by buckminster
Goto Forum:
  


Current Time: Thu Dec 18 04:07:43 GMT 2014

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

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