Skip to content

Commit a816aeb

Browse files
author
GOURDIN Christophe
committed
[Fix]Packages registering, for an obscur reason, ecore package must be registered before others extension package
1 parent c331256 commit a816aeb

4 files changed

Lines changed: 29 additions & 35 deletions

File tree

plugins/org.eclipse.cmf.occi.docker.gen.conf/src/org/eclipse/cmf/occi/docker/gen/conf/files/genCompose.mtl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[comment encoding = UTF-8 /]
2-
[module genCompose('http://occiware.org/occi/docker/ecore', 'http://schemas.ogf.org/occi/infrastructure/ecore', 'http://schemas.ogf.org/occi/core/ecore')]
2+
[module genCompose('http://www.eclipse.org/emf/2002/Ecore', 'http://schemas.ogf.org/occi/core/ecore', 'http://schemas.ogf.org/occi/infrastructure/ecore', 'http://occiware.org/occi/docker/ecore')]
33

44
[template public generateCompose(configuration : Configuration)]
55
[file ('docker/compose.yml', false, 'UTF-8')]

plugins/org.eclipse.cmf.occi.docker.gen.conf/src/org/eclipse/cmf/occi/docker/gen/conf/files/genSH.mtl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[comment encoding = UTF-8 /]
2-
[module genSH('http://occiware.org/occi/docker/ecore', 'http://schemas.ogf.org/occi/infrastructure/ecore', 'http://schemas.ogf.org/occi/core/ecore')]
2+
[module genSH('http://occiware.org/occi/docker/ecore', 'http://www.eclipse.org/emf/2002/Ecore', 'http://schemas.ogf.org/occi/core/ecore', 'http://schemas.ogf.org/occi/infrastructure/ecore')]
33

44
[template public generateSH(configuration : Configuration)]
55
[file ('docker/' + configurationFileName(configuration) + '.sh', false, 'UTF-8')]
@@ -8,31 +8,31 @@
88
# Generated at [getNow()/] from [getFilePath(configuration)/] by org.occiware.clouddesigner.occi.docker.gen.conf
99
#
1010

11-
[for (machine : Machine | configuration.resources->filter(Machine))]
11+
[for (machine : docker::Machine | configuration.resources->filter(docker::Machine))]
1212
[machine.genMachine()/]
1313
[/for]
1414
[/file]
1515
[/template]
1616

17-
[template public genMachine (machine : Machine) ]
17+
[template public genMachine (machine : docker::Machine) ]
1818
# Create the Docker [eClass().name/] named [name/]
19-
docker-machine create [genDriverConfig()/] [name/]
19+
docker-machine create [machine.genDriverConfig()/] [name/]
2020

2121
eval "$(docker-machine env [name/])"
2222

2323
[getOrderedContainers().genContainer()/]
2424
[/template]
2525

26-
[template public genDriverConfig (machine : Machine) post (trim())]
26+
[template public genDriverConfig (machine : docker::Machine) post (trim())]
2727
[/template]
2828

29-
[template public genDriverConfig (machine : Machinevirtualbox) post (trim())]
29+
[template public genDriverConfig (machine :docker::Machinevirtualbox) post (trim())]
3030
--driver=virtualbox[if (not occiComputeMemory.oclIsUndefined() and occiComputeMemory <> 0)] --virtualbox-memory [toInteger(occiComputeMemory)/][/if][if (not diskSize.oclIsUndefined() and diskSize <> null)] --virtualbox-disk-size [diskSize/][/if]
3131
[/template]
3232

3333
[comment TODO: Add genDriverConfig for each Machine_* /]
3434

35-
[template public genContainer (container : Container) ]
35+
[template public genContainer (container : docker::Container) ]
3636
# Create the Docker Container named [name/]
3737
[comment TODO: Add other parameters of the docker create command. /]
3838
docker create --name [name/][if publishAll] -P[/if][if (not volumes.oclIsUndefined())] -v [volumes.trim()/][/if][if (not ports.oclIsUndefined())] -p [ports.trim()/][/if][genLinkConfig()/][if (not image.oclIsUndefined())] [image.trim()/][/if][if (not command.oclIsUndefined())] [command.trim()/][/if]
@@ -43,9 +43,9 @@ docker start [name/]
4343

4444
[/template]
4545

46-
[template public genLinkConfig (container : Container) post (trim())]
47-
[for (link : Link | links->filter(docker::Link))]
48-
[let name : String = link.target.oclAsType(Container).name]
46+
[template public genLinkConfig (container : docker::Container) post (trim())]
47+
[for (link : docker::Link | links->filter(docker::Link))]
48+
[let name : String = link.target.oclAsType(docker::Container).name]
4949
--link [name/]:[if link.alias <> null][link.alias/][else][name/][/if]
5050
[/let]
5151
[/for]

plugins/org.eclipse.cmf.occi.docker.gen.conf/src/org/eclipse/cmf/occi/docker/gen/conf/main/Generate.java

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,11 @@
1818
import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
1919
import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
2020
import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
21-
import org.eclipse.cmf.occi.core.OCCIPackage;
22-
import org.eclipse.cmf.occi.docker.DockerFactory;
23-
import org.eclipse.cmf.occi.docker.DockerPackage;
24-
import org.eclipse.cmf.occi.infrastructure.InfrastructurePackage;
2521
import org.eclipse.emf.common.util.BasicMonitor;
2622
import org.eclipse.emf.common.util.Monitor;
2723
import org.eclipse.emf.common.util.URI;
2824
import org.eclipse.emf.ecore.EObject;
2925
import org.eclipse.emf.ecore.resource.ResourceSet;
30-
import org.eclipse.emf.ecore.util.EcoreUtil;
31-
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
3226

3327
/**
3428
* Entry point of the 'Generate' generation module.
@@ -346,33 +340,33 @@ public String[] getTemplateNames() {
346340
@Override
347341
public void registerPackages(ResourceSet resourceSet) {
348342
super.registerPackages(resourceSet);
349-
// The following doesnt work same message as described below.
350-
resourceSet.getPackageRegistry().put(OCCIPackage.eNS_URI,
351-
OCCIPackage.eINSTANCE);
352-
resourceSet.getPackageRegistry().put(InfrastructurePackage.eNS_URI,
353-
InfrastructurePackage.eINSTANCE);
354-
resourceSet.getPackageRegistry().put(DockerPackage.eNS_URI,
355-
DockerPackage.eINSTANCE);
343+
if (!isInWorkspace(org.eclipse.emf.ecore.EcorePackage.class)) {
344+
resourceSet.getPackageRegistry().put(org.eclipse.emf.ecore.EcorePackage.eINSTANCE.getNsURI(), org.eclipse.emf.ecore.EcorePackage.eINSTANCE);
345+
}
346+
// // The following doesnt work same message as described below.
347+
// resourceSet.getPackageRegistry().put(OCCIPackage.eNS_URI,
348+
// OCCIPackage.eINSTANCE);
349+
// resourceSet.getPackageRegistry().put(InfrastructurePackage.eNS_URI,
350+
// InfrastructurePackage.eINSTANCE);
351+
// resourceSet.getPackageRegistry().put(DockerPackage.eNS_URI,
352+
// DockerPackage.eINSTANCE);
356353

357354
// Other try with acceleo forum comments in forums, the following doesnt work...
358355
// Message : !MESSAGE The generation failed to generate any file because there are no model elements that matches at least the type of the first parameter of one of your main templates.
359356
// The problem may be caused by a problem with the registration of your metamodel, please see the method named "registerPackages" in the Java launcher of your generator. It could also come from a missing [comment @main/]
360357
// in the template used as the entry point of the generation.
361-
if (!isInWorkspace(OCCIPackage.class)) {
362-
// The normal package registration if your metamodel is in a plugin.
363-
resourceSet.getPackageRegistry().put(OCCIPackage.eNS_URI, OCCIPackage.eINSTANCE);
364-
}
365-
if (!isInWorkspace(InfrastructurePackage.class)) {
358+
if (!isInWorkspace(org.eclipse.cmf.occi.core.OCCIPackage.class)) {
366359
// The normal package registration if your metamodel is in a plugin.
367-
resourceSet.getPackageRegistry().put(InfrastructurePackage.eNS_URI, InfrastructurePackage.eINSTANCE);
360+
resourceSet.getPackageRegistry().put(org.eclipse.cmf.occi.core.OCCIPackage.eNS_URI, org.eclipse.cmf.occi.core.OCCIPackage.eINSTANCE);
368361
}
369-
if (!isInWorkspace(InfrastructurePackage.class)) {
362+
if (!isInWorkspace(org.eclipse.cmf.occi.infrastructure.InfrastructurePackage.class)) {
370363
// The normal package registration if your metamodel is in a plugin.
371-
resourceSet.getPackageRegistry().put(InfrastructurePackage.eNS_URI, InfrastructurePackage.eINSTANCE);
364+
resourceSet.getPackageRegistry().put(org.eclipse.cmf.occi.infrastructure.InfrastructurePackage.eNS_URI, org.eclipse.cmf.occi.infrastructure.InfrastructurePackage.eINSTANCE);
372365
}
373-
if (!isInWorkspace(DockerPackage.class)) {
366+
367+
if (!isInWorkspace(org.eclipse.cmf.occi.docker.DockerPackage.class)) {
374368
// The normal package registration if your metamodel is in a plugin.
375-
resourceSet.getPackageRegistry().put(DockerPackage.eNS_URI, DockerPackage.eINSTANCE);
369+
resourceSet.getPackageRegistry().put(org.eclipse.cmf.occi.docker.DockerPackage.eNS_URI, org.eclipse.cmf.occi.docker.DockerPackage.eINSTANCE);
376370
}
377371
// EcoreUtil.resolveAll(resourceSet);
378372

plugins/org.eclipse.cmf.occi.docker.gen.conf/src/org/eclipse/cmf/occi/docker/gen/conf/main/generate.mtl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[comment encoding = UTF-8 /]
2-
[module generate('http://occiware.org/occi/docker/ecore', 'http://schemas.ogf.org/occi/infrastructure/ecore', 'http://schemas.ogf.org/occi/core/ecore')]
2+
[module generate('http://www.eclipse.org/emf/2002/Ecore', 'http://schemas.ogf.org/occi/core/ecore', 'http://schemas.ogf.org/occi/infrastructure/ecore', 'http://occiware.org/occi/docker/ecore')]
33
[import org::eclipse::cmf::occi::docker::gen::conf::files::genCompose /]
44
[import org::eclipse::cmf::occi::docker::gen::conf::files::genSH /]
55
[template public generateElement(configuration : Configuration)]

0 commit comments

Comments
 (0)