| How to create attributes using EMF API ? [message #757936] |
Wed, 16 November 2011 13:26  |
|
I have an ecore model of a maven Pom (attached).
I build instances of the model using the API, usually without issue.
I need to create:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugins>
<build>
The EMF model has a number of Configuration types, each with a getAny()
method returning a FeatureMap.
How can I add the <source>1.6</source> and <target>1.6</target> Features ?
ala:
Model model = PomFactory.eINSTANCE.createModel();
model.setArtifactId(module.getName());
model.setGroupId("com.ebay." + module.getPath());
model.setName(module.getName());
model.setPackaging("jar");
model.setVersion("1.0.0");
......
Build build = PomFactory.eINSTANCE.createBuild();
model.setBuild(build);
PluginsType2 plugins = PomFactory.eINSTANCE.createPluginsType2();
build.setPlugins(plugins);
Plugin plugin = PomFactory.eINSTANCE.createPlugin();
plugins.getPlugin().add(plugin);
plugin.setGroupId("org.apache.maven.plugins");
plugin.setArtifactId("maven-compiler-plugin");
ConfigurationType2 configurationType2 = plugin.getConfiguration();
if (null == configurationType2) {
configurationType2 =
PomFactory.eINSTANCE.createConfigurationType2();
plugin.setConfiguration(configurationType2);
}
FeatureMap featureMap = configurationType2.getAny();
EAttribute sourceAttribute =
PomPackage.eINSTANCE.getConfigurationType2_Any();
sourceAttribute.setName("source");
featureMap.add(sourceAttribute, <?????>); // <-- is this even
close to being right ?
I'm not sure what types I need to create and add to the featureMap, or
even if I'm on the right track.
Thanks!!!!!
Roy
Attachment: pom.ecore
(Size: 211.77KB, Downloaded 72 times)
|
|
|