Skip to content

Commit

Permalink
[Fix]Packages registering, for an obscur reason, ecore package must b…
Browse files Browse the repository at this point in the history
…e registered before others extension package
  • Loading branch information
GOURDIN Christophe committed Jun 4, 2018
1 parent c331256 commit a816aeb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[comment encoding = UTF-8 /]
[module genCompose('http://occiware.org/occi/docker/ecore', 'http://schemas.ogf.org/occi/infrastructure/ecore', 'http://schemas.ogf.org/occi/core/ecore')]
[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')]

[template public generateCompose(configuration : Configuration)]
[file ('docker/compose.yml', false, 'UTF-8')]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[comment encoding = UTF-8 /]
[module genSH('http://occiware.org/occi/docker/ecore', 'http://schemas.ogf.org/occi/infrastructure/ecore', 'http://schemas.ogf.org/occi/core/ecore')]
[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')]

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

[for (machine : Machine | configuration.resources->filter(Machine))]
[for (machine : docker::Machine | configuration.resources->filter(docker::Machine))]
[machine.genMachine()/]
[/for]
[/file]
[/template]

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

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

[getOrderedContainers().genContainer()/]
[/template]

[template public genDriverConfig (machine : Machine) post (trim())]
[template public genDriverConfig (machine : docker::Machine) post (trim())]
[/template]

[template public genDriverConfig (machine : Machinevirtualbox) post (trim())]
[template public genDriverConfig (machine :docker::Machinevirtualbox) post (trim())]
--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]
[/template]

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

[template public genContainer (container : Container) ]
[template public genContainer (container : docker::Container) ]
# Create the Docker Container named [name/]
[comment TODO: Add other parameters of the docker create command. /]
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]
Expand All @@ -43,9 +43,9 @@ docker start [name/]

[/template]

[template public genLinkConfig (container : Container) post (trim())]
[for (link : Link | links->filter(docker::Link))]
[let name : String = link.target.oclAsType(Container).name]
[template public genLinkConfig (container : docker::Container) post (trim())]
[for (link : docker::Link | links->filter(docker::Link))]
[let name : String = link.target.oclAsType(docker::Container).name]
--link [name/]:[if link.alias <> null][link.alias/][else][name/][/if]
[/let]
[/for]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@
import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
import org.eclipse.cmf.occi.core.OCCIPackage;
import org.eclipse.cmf.occi.docker.DockerFactory;
import org.eclipse.cmf.occi.docker.DockerPackage;
import org.eclipse.cmf.occi.infrastructure.InfrastructurePackage;
import org.eclipse.emf.common.util.BasicMonitor;
import org.eclipse.emf.common.util.Monitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;

/**
* Entry point of the 'Generate' generation module.
Expand Down Expand Up @@ -346,33 +340,33 @@ public String[] getTemplateNames() {
@Override
public void registerPackages(ResourceSet resourceSet) {
super.registerPackages(resourceSet);
// The following doesnt work same message as described below.
resourceSet.getPackageRegistry().put(OCCIPackage.eNS_URI,
OCCIPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(InfrastructurePackage.eNS_URI,
InfrastructurePackage.eINSTANCE);
resourceSet.getPackageRegistry().put(DockerPackage.eNS_URI,
DockerPackage.eINSTANCE);
if (!isInWorkspace(org.eclipse.emf.ecore.EcorePackage.class)) {
resourceSet.getPackageRegistry().put(org.eclipse.emf.ecore.EcorePackage.eINSTANCE.getNsURI(), org.eclipse.emf.ecore.EcorePackage.eINSTANCE);
}
// // The following doesnt work same message as described below.
// resourceSet.getPackageRegistry().put(OCCIPackage.eNS_URI,
// OCCIPackage.eINSTANCE);
// resourceSet.getPackageRegistry().put(InfrastructurePackage.eNS_URI,
// InfrastructurePackage.eINSTANCE);
// resourceSet.getPackageRegistry().put(DockerPackage.eNS_URI,
// DockerPackage.eINSTANCE);

// Other try with acceleo forum comments in forums, the following doesnt work...
// 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.
// 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/]
// in the template used as the entry point of the generation.
if (!isInWorkspace(OCCIPackage.class)) {
// The normal package registration if your metamodel is in a plugin.
resourceSet.getPackageRegistry().put(OCCIPackage.eNS_URI, OCCIPackage.eINSTANCE);
}
if (!isInWorkspace(InfrastructurePackage.class)) {
if (!isInWorkspace(org.eclipse.cmf.occi.core.OCCIPackage.class)) {
// The normal package registration if your metamodel is in a plugin.
resourceSet.getPackageRegistry().put(InfrastructurePackage.eNS_URI, InfrastructurePackage.eINSTANCE);
resourceSet.getPackageRegistry().put(org.eclipse.cmf.occi.core.OCCIPackage.eNS_URI, org.eclipse.cmf.occi.core.OCCIPackage.eINSTANCE);
}
if (!isInWorkspace(InfrastructurePackage.class)) {
if (!isInWorkspace(org.eclipse.cmf.occi.infrastructure.InfrastructurePackage.class)) {
// The normal package registration if your metamodel is in a plugin.
resourceSet.getPackageRegistry().put(InfrastructurePackage.eNS_URI, InfrastructurePackage.eINSTANCE);
resourceSet.getPackageRegistry().put(org.eclipse.cmf.occi.infrastructure.InfrastructurePackage.eNS_URI, org.eclipse.cmf.occi.infrastructure.InfrastructurePackage.eINSTANCE);
}
if (!isInWorkspace(DockerPackage.class)) {

if (!isInWorkspace(org.eclipse.cmf.occi.docker.DockerPackage.class)) {
// The normal package registration if your metamodel is in a plugin.
resourceSet.getPackageRegistry().put(DockerPackage.eNS_URI, DockerPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(org.eclipse.cmf.occi.docker.DockerPackage.eNS_URI, org.eclipse.cmf.occi.docker.DockerPackage.eINSTANCE);
}
// EcoreUtil.resolveAll(resourceSet);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[comment encoding = UTF-8 /]
[module generate('http://occiware.org/occi/docker/ecore', 'http://schemas.ogf.org/occi/infrastructure/ecore', 'http://schemas.ogf.org/occi/core/ecore')]
[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')]
[import org::eclipse::cmf::occi::docker::gen::conf::files::genCompose /]
[import org::eclipse::cmf::occi::docker::gen::conf::files::genSH /]
[template public generateElement(configuration : Configuration)]
Expand Down

0 comments on commit a816aeb

Please sign in to comment.