Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » call java class which has a method from ANT build file(call java class which has a method from ANT build file)
call java class which has a method from ANT build file [message #1730148] Thu, 21 April 2016 18:26 Go to next message
taghreed altamimi is currently offline taghreed altamimiFriend
Messages: 180
Registered: October 2014
Senior Member
Hello,
I am trying to call java class which has a method from ANT build file
I have tried many ways but all of them failed .

The following is my ANT file : the bold (Java part )is what I need to do

<?xml version="1.0"?>
<project default="main" >

<target name="loadModels">


<epsilon.emf.loadModel
name="UML"
modelFile="Models/CompletedModelNov24Ph1Ph2ActivityGraph.uml"
metamodelUri="http://www.eclipse.org/uml2/5.0.0/UML"
read="true" store="true"/>

<epsilon.emf.register file="../AntBuildfile/Metamodels/lqnmodel.ecore"/>

<epsilon.emf.loadModel name="lqnmodel"
modelFile="Models/target2lqn.model"
metamodelUri="lqnmodel"
read="false" store="true"/>


</target>

<target name="main" depends="loadModels">

<epsilon.eol src="../AntBuildfile/ScriptingUMLXML.eol">
<model ref="UML" />
</epsilon.eol>

<epsilon.etl src="../AntBuildfile/AntwithoutTraceabilityApril11.etl" >
<model ref="UML"/>
<model ref="lqnmodel" />
</epsilon.etl>


<java>
<!--call java class which has a method to change the tag names and send the file location as a parameter to that method -->
</java>


</target>

</project>

I found this reference http://ant.apache.org/manual/develop.html#set-magic
but it confused me ,for example my class doesn't extend org.apache.tools.ant.Task do I need to include that ??if so where can I find class task in order to be able to extend it. Also do I need to identify the class path and class name?? and if yes how can I identify them because each time I got an error that my class is not found.

Can you please help me.

Thanks Taghreed.

[Updated on: Thu, 21 April 2016 18:29]

Report message to a moderator

Re: call java class which has a method from ANT build file [message #1730241 is a reply to message #1730148] Fri, 22 April 2016 13:51 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 475
Registered: January 2010
Senior Member
Indeed, that documentation is for developing your own Ant tasks, in Java. The Task class is defined by Ant, so you'd need to refer to the Ant libraries for that.

However, it might be easier to simply use the Ant Java task to run your class as it is:

https://ant.apache.org/manual/Tasks/java.html
Re: call java class which has a method from ANT build file [message #1730427 is a reply to message #1730241] Mon, 25 April 2016 18:25 Go to previous messageGo to next message
taghreed altamimi is currently offline taghreed altamimiFriend
Messages: 180
Registered: October 2014
Senior Member
Hello Antonio,
Can you please provide me with any example because I am still facing a problem in identifying class name and class path .I am able to execute .EOL and .ETL files through AntBuild file but still facing problems with calling java class. By the way can I execute .EOL ,.ETL files and call java class that has a method in the same Ant file.

This is the targets in my antbuild file:
<target name="main" depends="loadModels">

<epsilon.eol src="../AntBuildfile/ScriptingUMLXML.eol">
<model ref="UML" />
</epsilon.eol>

<epsilon.etl src="../AntBuildfile/AntwithoutTraceabilityApril11.etl" >
<model ref="UML"/>
<model ref="lqnmodel" />
</epsilon.etl>
</target>

<target name="run" depends="compile">
<!--<java>
<My Problem here :how to call java class which has a method to change the tag names and send the file name as a parameter
</java> -->
</target>
<target name="compile" >
<javac includeantruntime="false" srcdir="staging"/>
</target>

I really appreciate your help.

Taghreed.

[Updated on: Mon, 25 April 2016 18:26]

Report message to a moderator

Re: call java class which has a method from ANT build file [message #1730485 is a reply to message #1730427] Tue, 26 April 2016 09:24 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 475
Registered: January 2010
Senior Member
This is more of an Ant question than an Epsilon question, I'm afraid Wink. In any case, it really depends on what you want to do.

I feel that your use case would be better supported by extending Epsilon with your custom tool, backed by Java code. See this article:

http://www.eclipse.org/epsilon/doc/articles/call-java-from-epsilon/

If it really needs to be done through Java, I guess you could use the <java> task and provide the adequate classpath through the "classpath" attribute. I don't think it'll work well if you intend to redistribute the Ant process as part of some tool, since the <java> Ant task is not OSGi aware and won't be able to pick up plugins correctly. Here's an example project, in any case.
Re: call java class which has a method from ANT build file [message #1730728 is a reply to message #1730485] Thu, 28 April 2016 05:52 Go to previous messageGo to next message
taghreed altamimi is currently offline taghreed altamimiFriend
Messages: 180
Registered: October 2014
Senior Member
Hello Antonio ,
Thanks for your example it helped me very much but I am still have a problem .I need to pass an argument which is file's location as string to my java method as the following:

<java classname="tagPackage.TagModifier" classpath="bin"/>
<arg path="C:\Users\tegotamimi\Desktop\eclipse-epsilon-1.2-win32-x86_64\workspace\TagModifier\Models\target2lqn28April.model"/>

can you please advise me if this is the correct way to do it.
I am really appreciate your help.
Taghreed.

[Updated on: Thu, 28 April 2016 05:53]

Report message to a moderator

Re: call java class which has a method from ANT build file [message #1730814 is a reply to message #1730728] Thu, 28 April 2016 16:26 Go to previous messageGo to next message
taghreed altamimi is currently offline taghreed altamimiFriend
Messages: 180
Registered: October 2014
Senior Member
Ok I did it ,your example did help me very much.

Thanks,
Taghreed.
Re: call java class which has a method from ANT build file [message #1730823 is a reply to message #1730814] Thu, 28 April 2016 18:27 Go to previous message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 475
Registered: January 2010
Senior Member
Great! Smile
Previous Topic:rename tag name by EOL
Next Topic:EVL: How to define and use a profile and stereotypes in a model validation
Goto Forum:
  


Current Time: Wed Oct 17 05:14:56 GMT 2018

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

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

Back to the top