Executing EMF Ant tasks programmatically [message #526674] |
Mon, 12 April 2010 14:55 |
Eclipse User |
|
|
|
Originally posted by: cold.phusion.gmail.com
Hi all,
I'm probably not the first to ask about Ant and Eclipse and I definitely
won't be the last (since there is virtually no useful documentation on
the subject). I already spent a couple of hours reading similar threads
and trying out sample code, but I got nowhere.
What I want to do is quite simple: I want to call an (EMF) Ant target
(emf.Ecore2Java) programmatically, but I keep getting the following error:
Problem: failed to create task or type emf.Ecore2Java
Cause: Could not load a dependent class
org/eclipse/emf/ant/taskdefs/codegen/ecore/GeneratorTask
This class may be in a separate JAR that is not installed.
The reason for this is actually clear - Ant is starting in its own
environment and its ClassLoader cannot find the TaskDefs defined by EMF.
Executing the same target [1] from the Ant view in Eclipse works just
fine, because there's the option to run it in the same JRE as the
workspace.
The AntRunner, however, seems to always create a new ClassLoader
(AntRunner#getClassLoader())...
Is there any way of supplying the EMF dependencies as part of the
AntRunner classpath (AntRunner#setCustomClasspath())?
Thanks :)
Cheers,
Alex
P.S. Note that I did ask about Ant and its integration in Eclipse in the
PDE newsgroup, but I haven't got an answer so far, so I thought you guys
could have a clue.
P.P.S. I know I could try and build the GenModel myself but I think it
would be better if I could just reuse my existing Ant target instead of
reinventing the wheel :]
[1] <emf.Ecore2Java
model="${xsd.file}"
genmodel="${genmodel.file}"
generatemodelproject="true"
generatejavacode="true">
</emf.Ecore2Java>
|
|
|
Re: Executing EMF Ant tasks programmatically [message #526722 is a reply to message #526674] |
Mon, 12 April 2010 17:42 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Alex,
Comments below.
Alex Shterev wrote:
> Hi all,
>
> I'm probably not the first to ask about Ant and Eclipse and I
> definitely won't be the last (since there is virtually no useful
> documentation on the subject). I already spent a couple of hours
> reading similar threads and trying out sample code, but I got nowhere.
I'm expert with how Ant works either...
>
> What I want to do is quite simple: I want to call an (EMF) Ant target
> (emf.Ecore2Java) programmatically, but I keep getting the following
> error:
>
> Problem: failed to create task or type emf.Ecore2Java
> Cause: Could not load a dependent class
> org/eclipse/emf/ant/taskdefs/codegen/ecore/GeneratorTask
> This class may be in a separate JAR that is not installed.
>
> The reason for this is actually clear - Ant is starting in its own
> environment and its ClassLoader cannot find the TaskDefs defined by
> EMF. Executing the same target [1] from the Ant view in Eclipse works
> just fine, because there's the option to run it in the same JRE as the
> workspace.
The JRE is just the Java library, so I'm not sure I follow.
> The AntRunner, however, seems to always create a new ClassLoader
> (AntRunner#getClassLoader())...
> Is there any way of supplying the EMF dependencies as part of the
> AntRunner classpath (AntRunner#setCustomClasspath())?
> Thanks :)
I have no clue but I'd look closely at the process that's used to run
Ant from the IDE. Traces of it are left in the Debug window after it
runs and you can look at the command line arguments used to run it from
the properties.
>
> Cheers,
> Alex
>
> P.S. Note that I did ask about Ant and its integration in Eclipse in
> the PDE newsgroup, but I haven't got an answer so far, so I thought
> you guys could have a clue.
It is kind of a generic Ant question...
>
> P.P.S. I know I could try and build the GenModel myself but I think it
> would be better if I could just reuse my existing Ant target instead
> of reinventing the wheel :]
>
>
> [1] <emf.Ecore2Java
> model="${xsd.file}"
> genmodel="${genmodel.file}"
> generatemodelproject="true"
> generatejavacode="true">
> </emf.Ecore2Java>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Executing EMF Ant tasks programmatically [message #526882 is a reply to message #526722] |
Tue, 13 April 2010 11:29 |
Eclipse User |
|
|
|
Originally posted by: cold.phusion.gmail.com
Hi Ed,
thank you for the quick reply. Yes, it is kind of a generic "Eclipse vs.
Ant" question, I just hoped that someone has tried the same with the EMF
Ant tasks (since they are custom Ant tasks).
As for the JRE library - I meant the same running instance of JRE and
consequently the same ClassLoader - a brief quote from the Eclipse Help
"There are basically two requirements for running Ant in Eclipse that do
not fit the plug-in model very well:
* Change the Ant classpath at runtime
* Change the Ant version at runtime
During runtime plug-in classloaders cannot have their classpaths
expanded and plug-ins cannot change their dependencies."
Anyhow, my problem got fixed actually :) Apparently Eclipse plug-ins
which define custom Ant tasks can't be run as normal plug-ins in a PDE
launch. I still don't get what additional steps should be performed to
do so - if I find out I'll try to write a decent tutorial about it.
I just disabled all workspace plug-ins that had something to do with Ant
(org.eclipse.ant.*, org.eclipse.emf.ant.*, org.eclipse.emf.importer.*)
and enabled once again the precompiled bundles - now everything works
like a charm.
Cheers,
Alex
Am 12.04.2010 19:42, schrieb Ed Merks:
> Alex,
>
> Comments below.
>
> Alex Shterev wrote:
>> Hi all,
>>
>> I'm probably not the first to ask about Ant and Eclipse and I
>> definitely won't be the last (since there is virtually no useful
>> documentation on the subject). I already spent a couple of hours
>> reading similar threads and trying out sample code, but I got nowhere.
> I'm expert with how Ant works either...
>>
>> What I want to do is quite simple: I want to call an (EMF) Ant target
>> (emf.Ecore2Java) programmatically, but I keep getting the following
>> error:
>>
>> Problem: failed to create task or type emf.Ecore2Java
>> Cause: Could not load a dependent class
>> org/eclipse/emf/ant/taskdefs/codegen/ecore/GeneratorTask
>> This class may be in a separate JAR that is not installed.
>>
>> The reason for this is actually clear - Ant is starting in its own
>> environment and its ClassLoader cannot find the TaskDefs defined by
>> EMF. Executing the same target [1] from the Ant view in Eclipse works
>> just fine, because there's the option to run it in the same JRE as the
>> workspace.
> The JRE is just the Java library, so I'm not sure I follow.
>> The AntRunner, however, seems to always create a new ClassLoader
>> (AntRunner#getClassLoader())...
>> Is there any way of supplying the EMF dependencies as part of the
>> AntRunner classpath (AntRunner#setCustomClasspath())?
>> Thanks :)
> I have no clue but I'd look closely at the process that's used to run
> Ant from the IDE. Traces of it are left in the Debug window after it
> runs and you can look at the command line arguments used to run it from
> the properties.
>>
>> Cheers,
>> Alex
>>
>> P.S. Note that I did ask about Ant and its integration in Eclipse in
>> the PDE newsgroup, but I haven't got an answer so far, so I thought
>> you guys could have a clue.
> It is kind of a generic Ant question...
>>
>> P.P.S. I know I could try and build the GenModel myself but I think it
>> would be better if I could just reuse my existing Ant target instead
>> of reinventing the wheel :]
>>
>>
>> [1] <emf.Ecore2Java
>> model="${xsd.file}"
>> genmodel="${genmodel.file}"
>> generatemodelproject="true"
>> generatejavacode="true">
>> </emf.Ecore2Java>
|
|
|
Powered by
FUDForum. Page generated in 0.02838 seconds