Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 458751

Summary: Make dependency to JDT optional
Product: [Modeling] Sirius Reporter: Michael Keppler <michael.keppler>
Component: CoreAssignee: Laurent Redor <laurent.redor>
Status: CLOSED FIXED QA Contact: Laurent Redor <laurent.redor>
Severity: normal    
Priority: P3 CC: cedric.brun, laurent.redor, maxime.porhel, pierre-charles.david
Version: 2.0.3Keywords: triaged
Target Milestone: 4.0.0M6   
Hardware: PC   
OS: All   
See Also: https://git.eclipse.org/r/67965
https://git.eclipse.org/r/68926
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=4813c7a686db5061be9e7dce2e3aaf438a11521d
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=23dd4943ab8acb3ca78f66a9921dc8484bf4a7cf
Whiteboard:
Bug Depends on: 348922    
Bug Blocks:    

Description Michael Keppler CLA 2015-01-29 10:50:57 EST
sirius.ui has a required dependency to jdt.core. This is only to add the Sirius nature to a Java project. It would be nice to declare this dependency optional (and handle the missing class at runtime), as there are products, which want to use Sirius, but without any JDT dependency.
Comment 1 Maxime Porhel CLA 2015-02-02 08:45:46 EST
I found two other dependencies to jdt.core: 

 . org.eclipse.sirius.common.acceleo.mtl.ide: WorkspaceJavaImportHandler is used by the Acceleo MTL interpreter to manage Java services. This class is used to retrieve the Java services from the workspace, it allows the specififer to create is VSM (.odesign file) to test it without launching a runtime ("live editing mode") this plugins should not be required in a product using Sirius if this product does not allow its users to deal with VSMs. 

 . org.eclipse.sirius.common.xtext: XTextResourceSetFactory configures the resource set  and use several classes of jdt.core to compute the platform uri map. This plugin is the XText bridge. It currently provides:
   . a resource set factory to correctly setup the resourceSet when XText is used, 
   . a saving policy dedicated to Xtext aware sessions. It actually work around the bug #432795 by always adding options to ignore the concrete syntax validation of Xtext while saving.

We might also analyze the possibility to make the dependency between the Xtext bridge and jdt.core optional.
Comment 2 Cedric Brun CLA 2015-02-02 09:14:37 EST
If one use org.eclipse.sirius.common.acceleo.mtl then by transitivity org.eclipse.acceleo.engine and org.eclipse.acceleo.common will be part of the classpath. Both these plugins have an optional dependency to JDT and PDE. the dependency is optional but the code might fail when used within an Eclipse runtime and not in standalone. 
See Bug 348922.
Comment 3 Pierre-Charles David CLA 2015-02-03 07:42:59 EST
(In reply to Maxime Porhel from comment #1)
>  . org.eclipse.sirius.common.acceleo.mtl.ide: WorkspaceJavaImportHandler is
> used by the Acceleo MTL interpreter to manage Java services. This class is
> used to retrieve the Java services from the workspace, it allows the
> specififer to create is VSM (.odesign file) to test it without launching a
> runtime ("live editing mode") this plugins should not be required in a
> product using Sirius if this product does not allow its users to deal with
> VSMs. 

Note that this "magic" behavior does not work anyway with recent versions of Eclipse (starting from Luna), see https://bugs.eclipse.org/bugs/show_bug.cgi?id=419205.
Comment 4 Eclipse Genie CLA 2016-03-21 11:30:07 EDT
New Gerrit change created: https://git.eclipse.org/r/68926
Comment 7 Pierre-Charles David CLA 2016-03-22 09:23:36 EDT
So this it done in practice now, and Sirius 4.0M6 (the runtime part) should be able to work without the JDT:

% git grep -E "org\.eclipse\.(jdt|pde)" -- '**/MANIFEST.MF'
plugins/org.eclipse.sirius.common.acceleo.mtl.ide/META-INF/MANIFEST.MF: org.eclipse.jdt.core;bundle-version="3.5.0",
plugins/org.eclipse.sirius.common.xtext/META-INF/MANIFEST.MF: org.eclipse.jdt.core;bundle-version="3.8.1";resolution:=optional,
plugins/org.eclipse.sirius.editor/META-INF/MANIFEST.MF: org.eclipse.pde.core;bundle-version="3.8.1"
plugins/org.eclipse.sirius.editor/META-INF/MANIFEST.MF: org.eclipse.jdt.core,
plugins/org.eclipse.sirius.editor/META-INF/MANIFEST.MF: org.eclipse.pde.core,
plugins/org.eclipse.sirius.editor/META-INF/MANIFEST.MF: org.eclipse.pde.core.plugin
plugins/org.eclipse.sirius.tests.junit/META-INF/MANIFEST.MF: org.eclipse.jdt.ui,
plugins/org.eclipse.sirius.tests.junit/META-INF/MANIFEST.MF: org.eclipse.jdt;bundle-version="3.3.1",
plugins/org.eclipse.sirius.tests.swtbot/META-INF/MANIFEST.MF: org.eclipse.pde.ui,

The only remaining references/dependencies to JDT (or PDE for that matter) are:
* in the tests (that's OK);
* in the Xtext integration plug-in, which still depends on the JDT, but the plug-in is optional and the dependency itself is now optional too;
* in the specification environment org.eclipse.sirius.editor (the VSM editor infrastructure) and org.eclipse.sirius.common.acceleo.mtl.ide (which provides completion/validation support for Acceleo expressions in the VSM editor, and is not needed when *running* a Sirius modeler.

As mentioned in a previous comment by Cédric, Acceleo/MTL itself still depends on the JDT. But AQL does not, so now it *should* be possible to create full-featured Sirius-based modelers which can be run in Eclipse installations without the JDT.

I'm not closing the ticket yet, as it is not completely clear how to validate it, so until we have proper validation scenario it stays open (we may have a bad surprise if some other dependency of ours we missed requires the JDT itself).
Comment 8 Laurent Redor CLA 2016-04-27 10:44:25 EDT
I validated this issue with this scenario:
* Get the sources of all Sirius plugins in your workspace
* Launch a runtime with all plugins
* Validate that all is OK (open a diagram, a tree and a table for example)
* Modify the launch configuration to remove all jdt plugins.
* Validate the launch configuration and remove plugins which depends from jdt (until launch configuration OK).
* You should have all Sirius plugins necessary to the runtime.
* Launch a runtime
* Validate that all is OK (open a diagram, a tree and a table for example)

A real validation would be to make a product with Sirius runtime and without jdt but this was not made for this issue.
Comment 9 Pierre-Charles David CLA 2016-06-24 08:03:14 EDT
Available in Sirius 4.0.0.