call java class which has a method from ANT build file [message #1730148] |
Thu, 21 April 2016 18:26 |
taghreed altamimi Messages: 184 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 #1730427 is a reply to message #1730241] |
Mon, 25 April 2016 18:25 |
taghreed altamimi Messages: 184 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 |
|
This is more of an Ant question than an Epsilon question, I'm afraid . 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 |
taghreed altamimi Messages: 184 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03246 seconds