Given the following project structure:
parent/
settings.gradle
app/
src/main/java/...
build.gradle
model/
src-gen/main/java/...
Example.java
impl/
ExampleImpl.java
build.gradle
In model/build.gradle I declare the required EMF packages as api dependencies, assuming they will be made available to a user of that project:
dependencies {
api 'org.eclipse.emf:common:2.3.0-v200706262000'
api 'org.eclipse.emf:ecore:2.3.0-v200706262000'
api 'org.eclipse.emf:ecore-xmi:2.2.3'
}
sourceSets { main { java {
srcDirs 'src-gen'
} } }
In app/build.gradle I declare :model as a dependency:
plugins {
id 'java'
id 'application'
}
dependencies {
implementation project(':model')
...
However, when I run gradle run, I get the following exception (along with ~100 related ones):
> Task :model:compileJava FAILED
/.../parent/model/src-gen/main/java/org/example/parent/model/impl/ExampleImpl.java:10: error: cannot find symbol
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
^
symbol: class MinimalEObjectImpl
location: package org.eclipse.emf.ecore.impl
Why is that and what can I do about it? I want to generate an EMF based data model (:model) and use it in the other subproject (:app). I want to avoid dependencies on Eclipse.
The version of EMF you use (2.3.0) is too old : 2007. The MinimalEObjectImpl was only introduced in 2009 in version 2.5.0.
I advice you to use a newer version like 2.22.0. Here a link to the maven repository:
https://mvnrepository.com/artifact/org.eclipse.emf/org.eclipse.emf.ecore.