Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361940 - ATL transformation started from ant behaving differently then started by hand
Summary: ATL transformation started from ant behaving differently then started by hand
Status: NEW
Alias: None
Product: MMT.ATL
Classification: Modeling
Component: emfvm (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: mmt-atl.toolkit-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-25 11:14 EDT by Ralph Gerbig CLA
Modified: 2014-05-07 04:25 EDT (History)
2 users (show)

See Also:


Attachments
Example project (5.00 KB, application/x-zip-compressed)
2011-10-25 11:14 EDT, Ralph Gerbig CLA
no flags Details
Another example where inter model references fails with ant (5.65 KB, application/x-zip-compressed)
2014-04-08 04:13 EDT, Jean-Pierre PECUCHET CLA
no flags Details
Patch for allowing use of platform: path in ant tasks (30.58 KB, application/x-zip-compressed)
2014-04-14 09:43 EDT, Jean-Pierre PECUCHET CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralph Gerbig CLA 2011-10-25 11:14:30 EDT
Created attachment 205925 [details]
Example project

I attached a project containing a genmodel and a ATL transformation. When starting the ATL transformation manually the line 

propertyDescription <- s.ecoreFeature.name.debug('name')

returns

name: 'BugAttribute'

When starting via the ant skript it returns

name: OclUndefined

This has somehow to do that s.ecoreFeature is a cross reference from the genmodel to the ecore model.
Comment 1 William Piers CLA 2012-06-05 05:31:52 EDT
Changed to major as it only concerns ant launch.
Comment 2 Jean-Pierre PECUCHET CLA 2014-04-08 04:13:05 EDT
Created attachment 241708 [details]
Another example where inter model references fails with ant

Here comes another example using UML metamodel.
The problems occures with models using external ones.
The option "allowInterModelReferences" of the "EMF-specific VM" is set.
All is OK when using a manual launch (Runs As configuration), but the external sub-model is not seen when using an ant task.
Comment 3 Jean-Pierre PECUCHET CLA 2014-04-14 09:43:50 EDT
Created attachment 241956 [details]
Patch for allowing use of platform: path in ant tasks

The problem mainly comes from EMF rather than from ATL.
To properly load a main model (intermodel in our example) with an external model component (external in our example),
the class org.eclipse.emf.ecore.resource.impl.ResourceImpl needs at least one of the two xml files containing the models to be designated by a workspace relative path
(in our example, platform:/resource/InterModelExample/interModelReference.uml or platform:/resource/InterModelExample/externalModel.uml).
Note that the second path is given as an href attribute within the first main xml model file.
In our example, the URL of the external component is given as "externalModel.uml", not as "platform:/resource/InterModelExample/externalModel.uml".
So, to have the ATL transformation to work we must 
- either edit the interModelReference.uml file to replace the two occurrences of "externalModel.uml" by "platform:/resource/InterModelExample/externalModel.uml";
- or make ATL access to the main model file using the pass "platform:/resource/InterModelExample/interModelReference.uml" (what is naturally made by the ATL UI when using a "Run Configuration),
but is currently impossible using ATL ant tasks).

A solution would be to allow ATL ant tasks to use platform: URLs.
This imply to modify two lines of code.

1- In org.eclipse.m2m.atl.core.ant.tasks.LoadModelTask.java
within the private String convertSource() method, replace
{
	return "file:/" + path.toString();
}

by

{

	String pathString = path.toString();
	if (pathString.contains("platform:"))
		return pathString.substring(pathString.indexOf("platform:")).replaceAll("\\\\", "/");
	else
		return "file:/" + pathString;
}

2- In org.eclipse.m2m.atl.core.ant.tasks.SaveModelTask.java
within the private String convertTarget() method,
make the same replacement.

We now can use a platform: path in the atl.loadModel and atl.saveModel taskslike :

<project name="InterModelReferenceTask" default="run">
	<property name="inputModelPath" value="platform:/resource/InterModelExample/interModelReference.uml" />
	<property name="outputModelPath" value="platform:/resource/InterModelExample/interModelReferenceOutput.uml" />
	<target name="run">
		<atl.loadModel name="UML" metamodel="MOF" nsUri="http://www.eclipse.org/uml2/4.0.0/UML" />
		<atl.loadModel name="inputModel" metamodel="UML" path="${inputModelPath}" />
		<atl.launch path="InterModelReferences.asm" refining="true">
			<option name="allowInterModelReferences" value="true" />
			<inoutmodel model="inputModel" name="IN" />
		</atl.launch>
		<atl.saveModel model="inputModel" path="${outputModelPath}" />
	</target>
</project>

Here included in Patch.zip the new example, the two patched files and the patched atlAntTasks.jar to replace the one in the org.eclipse.m2m.atl.core.ant_3.4.0.v201305211502.jar plugin.
Comment 4 Jean-Pierre PECUCHET CLA 2014-05-07 04:25:53 EDT
Finally not a real bug.
Solved replacing path attribute by nsUri attribute in the atl.loadModel tag as suggested in https://bugs.eclipse.org/bugs/show_bug.cgi?id=297718