Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Invoke .emf from Ant programatically ?
Invoke .emf from Ant programatically ? [message #1257401] Wed, 26 February 2014 11:34 Go to next message
Shrikanth NC is currently offline Shrikanth NCFriend
Messages: 28
Registered: February 2014
Junior Member
I tried AntRunner of eclipse ant core,

***************************************************************************

AntRunner runner = new org.eclipse.ant.core.AntRunner();
runner.setBuildFileLocation("C:\\epsilon\\workspace\\ISUpdate\\model\\build.xml");
runner.setArguments("-Dmessage=Building -verbose");
try {
System.out.println(runner.getAvailableTargets());
} catch (CoreException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
runner.start(null);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

*******************************************************************************

Also tried regular ant api

**********************************************************************
File buildFile = new File(
"C:\\epsilon\\workspace\\ISUpdate\\model\\build.xml");
Project antProject = new Project();
antProject.setUserProperty("ant.file", buildFile.getAbsolutePath());
antProject.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
antProject.addReference("ant.ProjectHelper", helper);
helper.parse(antProject, buildFile);
String target = "main";
System.out.println(antProject.getJavaVersion());
antProject.executeTarget(target);


********************************************************************************

But I am unable generate

In the AntRunner api i am getting core exception and BUILD FAILED
In the later it says unable to find epsilon.eugenia tag

***********************************************************************
My Ant script :

- <project default="main">
- <target name="main">
<epsilon.eugenia src="new_file.emf" />
</target>
</project>

************************************************************************

Kindly help : How to generate code from emfatic file programatically either through ant or eugenia source code!
Re: Invoke .emf from Ant programatically ? [message #1257722 is a reply to message #1257401] Wed, 26 February 2014 18:26 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 918
Registered: July 2009
Senior Member
Hi,

Does this help? http://www.eclipse.org/forums/index.php/mv/msg/512479/1111540/#msg_1111540

Cheers,
Dimitris
Re: Invoke .emf from Ant programatically ? [message #1258213 is a reply to message #1257722] Thu, 27 February 2014 06:55 Go to previous messageGo to next message
Shrikanth NC is currently offline Shrikanth NCFriend
Messages: 28
Registered: February 2014
Junior Member
Thank You but no it doesn't fit into my situation.

My exact requirement :

1. When someone clicks menu item ( say update ) from my rcp application.
2. I wish to trigger updated emfatic file using ant / any other
3. That overwrites new diagram code
4. Hence my palette gets updated with new elements automatically, the next time i restart my rcp application

Problem :

I hard code 'wc.setAttribute(IExternalToolConstants.ATTR_LOCATION, "C:\\epsilon\\workspace\\is\\model\\build.xml");'

in RunAntAction class.

Also tried using AntRunner of eclipse core

Both throwing this exception,

org.eclipse.core.runtime.CoreException: C:\epsilon\workspace\is\model\build.xml:3: java.lang.NullPointerException
at org.eclipse.ant.core.AntRunner.handleInvocationTargetException(AntRunner.java:452)
at org.eclipse.ant.core.AntRunner.run(AntRunner.java:384)
at org.eclipse.epsilon.examples.runant.RunAntAction.run(RunAntAction.java:37)

***********************************************************************************

In short i want to generate diagram code using emfatic file in an standalone java program.

Using above examples it introduces eclipse workspace/IFile dependencies.


Kindly help, Thanks for your support!
Re: Invoke .emf from Ant programatically ? [message #1258788 is a reply to message #1258213] Thu, 27 February 2014 19:12 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 918
Registered: July 2009
Senior Member
Hi,

I don't think it's possible to do what you're describing from an RCP/standalone application as Eugenia inherently requires these Eclipse dependencies.

Cheers,
Dimitris

[Updated on: Thu, 27 February 2014 19:13]

Report message to a moderator

Re: Invoke .emf from Ant programatically ? [message #1263283 is a reply to message #1258788] Tue, 04 March 2014 10:42 Go to previous messageGo to next message
Shrikanth NC is currently offline Shrikanth NCFriend
Messages: 28
Registered: February 2014
Junior Member
<project default="main">
<target name="main">
<epsilon.eugenia src="new_file.emf"/>
</target>
</project>

is it possible to invoke it from command prompt ? ( Assuming Separate Ant is installed )

Thanks,
Shrikanth NC

[Updated on: Tue, 04 March 2014 10:43]

Report message to a moderator

Re: Invoke .emf from Ant programatically ? [message #1266297 is a reply to message #1263283] Fri, 07 March 2014 08:38 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 918
Registered: July 2009
Senior Member
Hi,

To be able to invoke this from the command line you'll need to assemble a fat jar containing Epsilon, Eugenia, EMF and GMF (see [1] for a starting point) and add it to ANT's classpath. Please feel free to open an enhancement request for this using the link below.

https://bugs.eclipse.org/bugs/enter_bug.cgi?product=epsilon

Cheers,
Dimitris

[1] https://dev.eclipse.org/svnroot/modeling/org.eclipse.epsilon/trunk/standalone/org.eclipse.epsilon.standalone/build-jars.xml
Re: Invoke .emf from Ant programatically ? [message #1266332 is a reply to message #1266297] Fri, 07 March 2014 09:42 Go to previous messageGo to next message
Shrikanth NC is currently offline Shrikanth NCFriend
Messages: 28
Registered: February 2014
Junior Member
I am half way there. Now ant is able to recognize epsilon.eugenia ( 'abc' in my case ) task as well as classnotdef exception doesnt occur after adding almost all jars Very Happy

But now I am stuck with new problem,

Using the following ant build.xml (below)

<project default="main">

<path id="libraries">
<fileset dir="C:\Users\shrikanth_n_c\Desktop\Libraries\EMF\">
<include name="*.jar"/>
</fileset>
<fileset dir="C:\epsilon\plugins\">
<include name="*.jar"/>
</fileset>
<fileset dir="C:\epsilon\plugins\org.apache.ant_1.8.4.v201303080030\lib\">
<include name="*.jar"/>
</fileset>
</path>

<target name="main">
<taskdef name="abc" classname="org.eclipse.epsilon.workflow.tasks.eugenia.EugeniaTask" classpathref="libraries" />
<abc src="new_file.emf" />
</target>
</project>

I am invoking build.xml from command prompt using

java -jar C:\eclipse\plugins\org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar -application org.eclipse.ant.core.antRunner -buildfile C:\epsilon\workspace\is\model\build.xml

I am getting following message,

Buildfile: C:\epsilon\workspace\is\model\build.xml

main:

BUILD FAILED
C:\epsilon\workspace\is\model\build.xml:17: java.lang.IllegalStateException: Wor
kbench has not been created yet.
at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:93)
at org.eclipse.epsilon.workflow.tasks.eugenia.EugeniaTask.executeImpl(Eu
geniaTask.java:139)
at org.eclipse.epsilon.workflow.tasks.EpsilonTask.execute(EpsilonTask.ja
va:40)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:41)
at org.eclipse.ant.internal.core.ant.EclipseDefaultExecutor.executeTarge
ts(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRu
nner.java:672)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRu
nner.java:537)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.ant.core.AntRunner.run(AntRunner.java:513)
at org.eclipse.ant.core.AntRunner.start(AntRunner.java:600)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandl
e.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runAppli
cation(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(Ec
lipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.ja
va:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.ja
va:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)

Total time: 1 second
An error has occurred. See the log file
C:\Users\shrikanth_n_c\workspace\.metadata\.log.

Kindly help me to proceed!

Thanks,
Shrikanth NC
  • Attachment: .log
    (Size: 71.14KB, Downloaded 4 times)

[Updated on: Fri, 07 March 2014 09:53]

Report message to a moderator

Re: Invoke .emf from Ant programatically ? [message #1267722 is a reply to message #1266332] Sun, 09 March 2014 12:50 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 918
Registered: July 2009
Senior Member
The discussion has moved to https://bugs.eclipse.org/bugs/show_bug.cgi?id=429848
Previous Topic:Eugenia: Starters/ideas to automate GMF generation?
Next Topic:ETL trafo plug-in - no target model visible
Goto Forum:
  


Current Time: Thu Dec 18 04:14:39 GMT 2014

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

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