Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6.2.0 Release #51

Merged
merged 7 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cnf/central.mvn
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ org.osgi:osgi.annotation:8.1.0
org.slf4j:slf4j-simple:1.7.36
org.slf4j:slf4j-api:1.7.36

org.geckoprojects.bnd:org.gecko.bnd.dimc.library:1.4.4
org.geckoprojects.bnd:org.gecko.bnd.jacoco.library:1.4.4
org.geckoprojects.bnd:org.gecko.bnd.osgitest.library:1.4.4
org.eclipse.platform:org.eclipse.core.contenttype:3.9.100
org.eclipse.platform:org.eclipse.core.expressions:3.9.100
org.eclipse.platform:org.eclipse.core.filesystem:1.10.100
Expand All @@ -97,3 +94,6 @@ org.eclipse.platform:org.eclipse.equinox.supplement:1.10.700
org.eclipse.jdt:org.eclipse.jdt.core:3.26.0
org.eclipse.platform:org.eclipse.osgi:3.18.500
org.eclipse.platform:org.eclipse.text:3.13.100
org.geckoprojects.bnd:org.gecko.bnd.dimc.library:1.5.0
org.geckoprojects.bnd:org.gecko.bnd.jacoco.library:1.5.0
org.geckoprojects.bnd:org.gecko.bnd.osgitest.library:1.5.0
2 changes: 1 addition & 1 deletion cnf/ext/version.bnd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
base-version: 6.1.3
base-version: 6.2.0
3 changes: 1 addition & 2 deletions org.gecko.emf.osgi.bnd.library.workspace/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
-include: ${.}/buildpath.bnd
mavendeps: ${sjoin;\n; ${template;-maven-dependencies;${@}}}

-includeresource: resources,\
{template/geckoEMF.maven=resources/template/geckoEMF.maven}
-includeresource: {resources}

Provide-Capability: \
${gecko-base}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
aQute.bnd.repository.maven.provider.MavenBndRepository;\
releaseUrl = "https://repo.maven.apache.org/maven2/,https://devel.data-in-motion.biz/nexus/repository/dim-release/"; \
snapshotUrl = "https://devel.data-in-motion.biz/nexus/repository/dim-snapshot/";\
index = "${.}/geckoEMF.maven" ;\
index = "\${.}/geckoEMF.maven" ;\
readOnly = true;\
name="GeckoEMF Dependencies"
name="GeckoEMF Dependencies - ${project-version}"

-require-bnd: "(version>=7.0.0)"
3 changes: 1 addition & 2 deletions org.gecko.emf.osgi.codegen/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ src=${^src}

-includeresource.resource: \
/=resources,\
templates,\
{resources/version.properties}
templates

-privatepackage.add: \
org.eclipse.core.runtime;-split-package:=merge-first,\
Expand Down
1 change: 0 additions & 1 deletion org.gecko.emf.osgi.codegen/resources/version.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicBoolean;

import org.eclipse.core.runtime.IProgressMonitor;
Expand Down Expand Up @@ -78,8 +77,6 @@ public class GeckoEmfGenerator implements Generator<GeneratorOptions> {
/** PROP_LOGFILE */
private static final String PROP_LOGFILE = "logfile"; //$NON-NLS-1$



private static PrintStream logWriter;

public static void info(String message) {
Expand Down Expand Up @@ -131,12 +128,7 @@ public Optional<String> generate(
initializeLog(context.getBase(), context.get(PROP_LOGFILE));
}

Properties props = new Properties();
props.load(getClass().getResourceAsStream("/version.properties"));

String version = props.getProperty("version");

info("Running Gecko EMF Codegen Version " + version);
info("Running Gecko EMF Codegen Version " + VersionConstant.GECKOPROJECTS_EMF_VERSION);

String genFolder = context.get(PROP_OUTPUT);
File output = null;
Expand Down Expand Up @@ -288,50 +280,54 @@ private void configureEMF(ResourceSet resourceSet, Map<Container, Map<String, St
protected Optional<String> doGenerate(String output, String genmodelPath, Map<Container, Map<String, String>> refModels, File base, String bsn, String genmodelLocation) {
info("Running for genmodel " + genmodelPath + " in " + base.getAbsolutePath());
ResourceSet resourceSet = new ResourceSetImpl();

configureEMF(resourceSet, refModels, bsn, base);
URI genModelUri = URI.createURI("resource://" + bsn + "/" + genmodelPath);

info("Loading " + genModelUri.toString());

Resource resource = resourceSet.getResource(genModelUri, true);

if(!resource.getErrors().isEmpty()) {
return Optional.of(resource.getErrors().get(0).toString());
}

GenModel genModel = (GenModel) resource.getContents().get(0);
org.eclipse.emf.codegen.ecore.generator.Generator gen = new org.eclipse.emf.codegen.ecore.generator.Generator();
configureEMFGenerator(gen);

String modelDirectory = "/" + bsn + (output.startsWith("/") ? "" : "/") + output;

info("Setting modelDirectory" + modelDirectory);

genModel.setModelDirectory(modelDirectory);
gen.setInput(genModel);


Map<String, Object> props = new HashMap<>();
props.put(GeckoEmfGenerator.ORIGINAL_GEN_MODEL_PATH, genmodelPath);
props.put(GeckoEmfGenerator.ORIGINAL_GEN_MODEL_PATHS_EXTRA, Arrays.asList(base.getName() + "/" + genmodelPath));
props.put(GeckoEmfGenerator.INCLUDE_GEN_MODEL_FOLDER, genmodelLocation);
gen.getOptions().data = new Object[] {props};

genModel.setCanGenerate(true);
genModel.setUpdateClasspath(false);

info("Starting generator run");
try {
Diagnostic diagnostic = gen.generate(genModel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, CodeGenUtil.EclipseUtil.createMonitor(new LoggingProgressMonitor(), 1));
printResult(diagnostic);
if(diagnostic.getSeverity() != Diagnostic.OK) {
return Optional.of(diagnostic.toString());
}
} catch (Exception e) {
String message = "An error appeared while generating: " + e.getMessage();
error(message, e);
return Optional.of(message);
configureEMF(resourceSet, refModels, bsn, base);
URI genModelUri = URI.createURI("resource://" + bsn + "/" + genmodelPath);

info("Loading " + genModelUri.toString());

Resource resource = resourceSet.getResource(genModelUri, true);

if(!resource.getErrors().isEmpty()) {
return Optional.of(resource.getErrors().get(0).toString());
}

GenModel genModel = (GenModel) resource.getContents().get(0);
org.eclipse.emf.codegen.ecore.generator.Generator gen = new org.eclipse.emf.codegen.ecore.generator.Generator();
configureEMFGenerator(gen);

String modelDirectory = "/" + bsn + (output.startsWith("/") ? "" : "/") + output;

info("Setting modelDirectory" + modelDirectory);

genModel.setModelDirectory(modelDirectory);
gen.setInput(genModel);


Map<String, Object> props = new HashMap<>();
props.put(GeckoEmfGenerator.ORIGINAL_GEN_MODEL_PATH, genmodelPath);
props.put(GeckoEmfGenerator.ORIGINAL_GEN_MODEL_PATHS_EXTRA, Arrays.asList(base.getName() + "/" + genmodelPath));
props.put(GeckoEmfGenerator.INCLUDE_GEN_MODEL_FOLDER, genmodelLocation);
gen.getOptions().data = new Object[] {props};

genModel.setCanGenerate(true);
genModel.setUpdateClasspath(false);

info("Starting generator run");
try {
Diagnostic diagnostic = gen.generate(genModel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, CodeGenUtil.EclipseUtil.createMonitor(new LoggingProgressMonitor(), 1));
printResult(diagnostic);
if(diagnostic.getSeverity() != Diagnostic.OK) {
return Optional.of(diagnostic.toString());
}
} catch (Exception e) {
String message = "An error appeared while generating: " + e.getMessage();
error(message, e);
return Optional.of(message);
}
} finally {
resourceSet.getResources().forEach(Resource::unload);
resourceSet.getResources().clear();
}
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public class BNDGeneratorAdapterFactory extends GenModelGeneratorAdapterFactory
return new BNDGeneratorAdapterFactory();
};




@Override
public Adapter createGenPackageAdapter() {
if (genPackageGeneratorAdapter == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
import org.eclipse.emf.codegen.ecore.genmodel.generator.GenClassGeneratorAdapter;
import org.eclipse.emf.common.util.Monitor;
import org.eclipse.emf.common.util.URI;

/**
* Used to avoid the PDE specific Files
Expand All @@ -44,6 +45,19 @@ protected JETEmitterDescriptor[] getJETEmitterDescriptors() {
return JET_EMITTER_DESCRIPTORS;
}

/*
* (non-Javadoc)
* @see org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter#getEncoding(org.eclipse.emf.common.util.URI)
*/
@Override
protected String getEncoding(URI workspacePath) {
String encoding = super.getEncoding(workspacePath);
if(encoding == null) {
return "UTF8";
}
return encoding;
}

/**
* Creates a new instance.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.eclipse.emf.codegen.ecore.genmodel.GenEnum;
import org.eclipse.emf.codegen.ecore.genmodel.generator.GenEnumGeneratorAdapter;
import org.eclipse.emf.common.util.Monitor;
import org.eclipse.emf.common.util.URI;

/**
* A {@link GeneratorAdapter} for instances of {@link GenEnum}. This contributes
Expand Down Expand Up @@ -53,6 +54,19 @@ public GeckoGenEnumGeneratorAdapter(GeneratorAdapterFactory generatorAdapterFact
super(generatorAdapterFactory);
}

/*
* (non-Javadoc)
* @see org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter#getEncoding(org.eclipse.emf.common.util.URI)
*/
@Override
protected String getEncoding(URI workspacePath) {
String encoding = super.getEncoding(workspacePath);
if(encoding == null) {
return "UTF8";
}
return encoding;
}

/**
* Returns the set of <code>JETEmitterDescriptor</code>s used by the adapter.
* The contents of the returned array should never be changed. Rather,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.emf.codegen.ecore.genmodel.generator.GenModelGeneratorAdapter;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.Monitor;
import org.eclipse.emf.common.util.URI;

/**
* Used to avoid the PDE specific Files
Expand All @@ -34,6 +35,19 @@ public GeckoGenModelGeneratorAdapter(GeneratorAdapterFactory generatorAdapterFac
super(generatorAdapterFactory);
}

/*
* (non-Javadoc)
* @see org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter#getEncoding(org.eclipse.emf.common.util.URI)
*/
@Override
protected String getEncoding(URI workspacePath) {
String encoding = super.getEncoding(workspacePath);
if(encoding == null) {
return "UTF8";
}
return encoding;
}

/*
* (non-Javadoc)
* @see org.eclipse.emf.codegen.ecore.genmodel.generator.GenModelGeneratorAdapter#generateModel(java.lang.Object, org.eclipse.emf.common.util.Monitor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,16 @@
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.BinaryIO.Version;
import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.EObjectOutputStream;
import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.EObjectOutputStream;
import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.BinaryIO.Version;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.XMLResource.URIHandler;
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
import org.eclipse.emf.ecore.xmi.impl.URIHandlerImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
import org.gecko.emf.osgi.codegen.GeckoEmfGenerator;
import org.gecko.emf.osgi.codegen.ResourceUriHandler;

/**
* EMF codegen generator adapter that is responsible to generate the OSGi
Expand Down Expand Up @@ -94,6 +92,19 @@ public GeckoGenPackageGeneratorAdapter(GeneratorAdapterFactory generatorAdapterF
super(generatorAdapterFactory);
}

/*
* (non-Javadoc)
* @see org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter#getEncoding(org.eclipse.emf.common.util.URI)
*/
@Override
protected String getEncoding(URI workspacePath) {
String encoding = super.getEncoding(workspacePath);
if(encoding == null) {
return "UTF8";
}
return encoding;
}

/**
* Returns the set of <code>JETEmitterDescriptor</code>s used by the adapter.
* The contents of the returned array should never be changed. Rather,
Expand Down
4 changes: 3 additions & 1 deletion org.gecko.emf.osgi.example.model.basic/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ src=${^src},src-gen
output=src-gen;\
version=${base-version};\
clean=false;\
logfile=out.log
logfile=out.log

-baseline: !org.gecko.emf.osgi.example.model.basic.impl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="basic" nsURI="http://gecko.org/example/model/basic" nsPrefix="basic">
<eAnnotations source="Version">
<details key="value" value="1.2.0"/>
<details key="value" value="1.5"/>
</eAnnotations>
<eAnnotations source="SuppressWarnings" references="#//SuppressWarnings">
<details key="value" value="&quot;Blub&quot;"/>
</eAnnotations>
<eClassifiers xsi:type="ecore:EClass" name="Person">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="firstName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
Expand Down Expand Up @@ -47,6 +50,7 @@
<eLiterals name="EMAIL" value="3" literal="Email"/>
<eLiterals name="SKYPE" value="4" literal="Skype"/>
<eLiterals name="WEBADDRESS" value="5" literal="WWW"/>
<eLiterals name="nööö" value="6"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="ContactContextType">
<eLiterals name="HOME"/>
Expand Down Expand Up @@ -136,4 +140,9 @@
</eClassifiers>
<eClassifiers xsi:type="ecore:EDataType" name="Coordinates" instanceClassName="java.lang.Double[]"/>
<eClassifiers xsi:type="ecore:EDataType" name="MultiDimensionCoordinates" instanceClassName="java.lang.Double[][]"/>
<eClassifiers xsi:type="ecore:EClass" name="SuppressWarnings" instanceClassName="java.lang.SuppressWarnings"
abstract="true" interface="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="value" upperBound="-1"
eType="ecore:EDataType ../../../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
operationReflection="true" importOrganizing="true" oSGiCompatible="true">
<foreignModel>basic.ecore</foreignModel>
<genPackages prefix="Basic" basePackage="org.gecko.emf.osgi.example.model" resource="XMI"
disposableProviderFactory="true" loadInitialization="true" contentTypeIdentifier="basic#1.0"
fileExtensions="basic" ecorePackage="basic.ecore#/">
disposableProviderFactory="true" contentTypeIdentifier="basic#1.0" fileExtensions="basic"
ecorePackage="basic.ecore#/">
<genEnums typeSafeEnumCompatible="false" ecoreEnum="basic.ecore#//ContactType">
<genEnumLiterals ecoreEnumLiteral="basic.ecore#//ContactType/PHONE"/>
<genEnumLiterals ecoreEnumLiteral="basic.ecore#//ContactType/MOBILE"/>
<genEnumLiterals ecoreEnumLiteral="basic.ecore#//ContactType/WHATSAPP"/>
<genEnumLiterals ecoreEnumLiteral="basic.ecore#//ContactType/EMAIL"/>
<genEnumLiterals ecoreEnumLiteral="basic.ecore#//ContactType/SKYPE"/>
<genEnumLiterals ecoreEnumLiteral="basic.ecore#//ContactType/WEBADDRESS"/>
<genEnumLiterals ecoreEnumLiteral="basic.ecore#//ContactType/nööö"/>
</genEnums>
<genEnums typeSafeEnumCompatible="false" ecoreEnum="basic.ecore#//ContactContextType">
<genEnumLiterals ecoreEnumLiteral="basic.ecore#//ContactContextType/HOME"/>
Expand Down Expand Up @@ -111,5 +112,8 @@
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute basic.ecore#//Geometry/id"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute basic.ecore#//Geometry/multiDimensionalCoordinates"/>
</genClasses>
<genClasses image="false" ecoreClass="basic.ecore#//SuppressWarnings">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute basic.ecore#//SuppressWarnings/value"/>
</genClasses>
</genPackages>
</genmodel:GenModel>
Loading
Loading