|
Re: Call jdt.ant from buckminster.prebind? [message #518643 is a reply to message #518585] |
Thu, 04 March 2010 16:40 |
|
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 #518658 is a reply to message #518646] |
Thu, 04 March 2010 17:11 |
|
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 #518694 is a reply to message #518659] |
Thu, 04 March 2010 14:04 |
|
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 |
|
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>
>
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04408 seconds