Java/ANT/Epsilon Problem: failed to create task or type epsilon.loadModel [message #713351] |
Mon, 08 August 2011 11:33 |
adrian Messages: 1 Registered: August 2011 |
Junior Member |
|
|
Hi,
I have a problem. I'm trying to do a transformation with ANT epsilon by running a Java class. The problem is that I get the error:
Problem: failed to create task or type epsilon.loadModel
ANT code:
<project default="main">
<target name="loadModels">
<epsilon.loadModel name="EER" type="EMF">
<parameter name="modelFile" file="./default.xmi"/>
<parameter name="metamodelFile" value="../../es.unican.moses.sle.db.eer2sql/model/EERmodel.ecore"/>
<parameter name="isMetamodelFileBased" value="true"/>
<parameter name="readOnLoad" value="true"/>
<parameter name="storeOnDisposal" value="false"/>
</epsilon.loadModel>
<epsilon.loadModel name="Relational" type="EMF">
<parameter name="modelFile" file="pruebaSalida.model"/>
<parameter name="metamodelFile" value="../../es.unican.moses.sle.db.relacional/model/Relational.ecore"/>
<parameter name="isMetamodelFileBased" value="true"/>
<parameter name="readOnLoad" value="false"/>
<parameter name="storeOnDisposal" value="true"/>
</epsilon.loadModel>
</target>
<target name="main" depends="loadModels">
<epsilon.etl src="${basedir}/eer2relational.etl">
<model ref="EER"/>
<model ref="Relational"/>
</epsilon.etl>
</target>
</project>
-------------------------------------------------- -------
The Java class is as follows:
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.osgi.framework.Bundle;
public class doCodeGeneration implements IObjectActionDelegate {
private Shell shell;
/**
* Constructor for Action1.
*/
public doCodeGeneration() {
super();
}
/**
* @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
*/
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
shell = targetPart.getSite().getShell();
}
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
MessageDialog.openInformation(
shell,
"Moses Research Group",
"EER Code Generation was executed.");
action();
}
/**
* @see IActionDelegate#selectionChanged(IAction, ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
}
/**
* Implements the actions to be carried out when the Generate Code action is invoked
*/
public void action(){
// We look for the ANT file to be executed.
File buildFile = findEer2RelationalLauncher();
Project p = new Project();
p.setUserProperty("ant.file",buildFile.getAbsolutePath());
DefaultLogger consoleLogger = new DefaultLogger();
consoleLogger.setErrorPrintStream(System.err);
consoleLogger.setOutputPrintStream(System.out);
consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
p.addBuildListener(consoleLogger);
try {
p.fireBuildStarted();
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget(p.getDefaultTarget());
p.fireBuildFinished(null);
} catch (BuildException e) {
p.fireBuildFinished(e);
}
}
/**
* Looks for the ANT file to be invoked for transforming a EER model into a relational
* one
* @return The file containing such an ANT file
*/
private File findEer2RelationalLauncher() {
// We search for the XML file containing the ANT task to be launched
Bundle bundle = Platform.getBundle("es.unican.moses.transformations.db.eer2relational");
Path path = new Path("Transformations/launchEer2Relational.xml");
URL launcherURL = FileLocator.find(bundle, path, null);
// We convert the URL to a URL using the file protocol
URL launcherFileURL = null;
try {
launcherFileURL = FileLocator.toFileURL(launcherURL);
} catch (IOException e2) {
// TODO Auto-generated catch block
// Completa esta excepcion
e2.printStackTrace();
} //
System.out.println("Path = " + launcherFileURL.toString());
File buildFile = null;
try {
buildFile = new File(launcherFileURL.toURI());
} catch (URISyntaxException e1) {
// Cambia esto por una ventana que informe del error
System.out.println("The file for launching the transformation can not be found." +
"This is probably due to an installation error");
e1.printStackTrace();
}
return buildFile;
}
}
Any ideas? I think I should change the configuration of Eclipse from Java code but I do not know how to put the option "Run in the Same JRE as the workspace".
Thank you
|
|
|
|
|
|
Re: Java/ANT/Epsilon Problem: failed to create task or type epsilon.loadModel [message #726893 is a reply to message #726381] |
Mon, 19 September 2011 20:06 |
Pablo Messages: 2 Registered: September 2011 |
Junior Member |
|
|
Hi Dimitrios,
Here my mininmal example.
Epsilon version: Epsilon Core (Incubation) 0.9.0.201011251259
To reproduce the problem: run the plugins I am sending attached to this post as an Eclipse application. Then, create an empty project and an create an EER diagram. This can be done by doing double click on the name of the project New->Other->
Examples->EERmodel diagram.
Then, add a couple of entities to the diagram (just in case you want to do it). Then, select the .eer file, press the right button of the mouse and select "EER Code generation". You will get a dialog box saying all have been done correctly, but if you look at the console of the first Eclipse, you will find the error.
If the code is too complex, let me know and I try to simplify it.
Thanks in advance, Pablo.
[Updated on: Mon, 19 September 2011 20:07] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03243 seconds