acceleo compiler,5:无法解析元模型

时间:2011-12-12 14:48:29

标签: ant eclipse-emf acceleo

我正在尝试为android创建一个独立的ant构建文件。我们正在使用acceleo来生成代码。

以下是我在build.xml中采取的步骤。

  1. 编译自动生成器
  2. 生成EMTL文件
  3. 从EMTL文件生成代码
  4. 现在,我可以运行第1步,它运行正常。然后我运行第2步,它失败并出现以下错误(步骤2错误)。然后我可以运行第3步,它运行正常。然后我检查所有文件和生成的代码,一切看起来都很好。但是,第2步中的那些错误真的让我烦恼,我需要让它们得到解决。

    如果您需要更多信息,我们将非常感谢您的帮助。请告知我们。

    以下是build.xml中的步骤和步骤2的错误。


    the build.xml information
    <target name="compileAutogen" description="Compiles Autogen">
        <javac
            srcdir="${AUTOGEN_SRC}"
            destdir="${AUTOGEN_BIN}"
            classpath="${ECLIPSE_HOME}/plugins/org.eclipse.acceleo.engine_3.2.0.v20111027-0537.jar;${ECLIPSE_HOME}/plugins/org.eclipse.emf.common_2.7.0.v20110912-0920.jar;${ECLIPSE_HOME}/plugins/org.eclipse.emf.ecore_2.7.0.v20110912-0920.jar;${ECLIPSE_HOME}/plugins/org.eclipse.acceleo.model_3.2.0.v20111027-0537.jar"
            executable="${JAVA_JDK}/javac"
            fork="true"
            includeantruntime="false"
            failonerror="false"
        />
    </target>
    
    <target name="generateEMTL" description="Generates the EMTL files for Autogen">
        <acceleoCompiler sourceFolder="${AUTOGEN_SRC}"
             outputFolder="${AUTOGEN_BIN}"
             dependencies=""
             binaryResource="false"
             packagesToRegister="org.eclipse.emf.ecore.EcorePackage">
        </acceleoCompiler>
    </target>
    
    <target name="generateFrameworkCode" description="Generates the generated code for Framework">
        <java 
            classname="framework.generator.main.Main" 
            classpath="${AUTOGEN_BIN};${ECLIPSE_HOME}/plugins/org.eclipse.acceleo.engine_3.2.0.v20111027-0537.jar;${ECLIPSE_HOME}/plugins/org.eclipse.emf.ecore_2.7.0.v20110912-0920.jar;${ECLIPSE_HOME}/plugins/org.eclipse.emf.common_2.7.0.v20110912-0920.jar;${ECLIPSE_HOME}/plugins/org.eclipse.acceleo.common_3.2.0.v20111027-0537.jar;${ECLIPSE_HOME}/plugins/org.eclipse.acceleo.model_3.2.0.v20111027-0537.jar;${ECLIPSE_HOME}/plugins/org.eclipse.emf.ecore.xmi_2.7.0.v20110520-1406.jar;${ECLIPSE_HOME}/plugins/org.eclipse.ocl.ecore_3.1.1.v20110823-1646.jar;${ECLIPSE_HOME}/plugins/org.eclipse.ocl_3.1.0.v20110913-1213.jar;${ECLIPSE_HOME}/plugins/lpg.runtime.java_2.0.17.v201004271640.jar;${ECLIPSE_HOME}/plugins/org.eclipse.core.runtime.compatibility.registry_3.5.0.v20110505/runtime_registry_compatibility.jar;${ECLIPSE_HOME}/plugins/org.eclipse.core.runtime_3.7.0.v20110110.jar;${ECLIPSE_HOME}/plugins/org.eclipse.osgi_3.7.1.R37x_v20110808-1106.jar;${ECLIPSE_HOME}/plugins/org.eclipse.equinox.common_3.6.0.v20110523.jar;${ECLIPSE_HOME}/plugins/org.eclipse.core.jobs_3.5.100.v20110404.jar;${ECLIPSE_HOME}/plugins/org.eclipse.equinox.registry_3.5.101.R37x_v20110810-1611.jar;${ECLIPSE_HOME}/plugins/org.eclipse.equinox.preferences_3.4.1.R37x_v20110725.jar;${ECLIPSE_HOME}/plugins/org.eclipse.core.contenttype_3.4.100.v20110423-0524.jar;${ECLIPSE_HOME}/plugins/org.eclipse.equinox.app_1.3.100.v20110321.jar;${ECLIPSE_HOME}/plugins/com.google.collect_1.0.0.v201105210816.jar" 
            fork="true">
            <arg value="${MODEL}"/>
            <arg value="${TARGET}"/>
        </java>
    </target>
    
    <target 
        name="generateFramework" 
        description="Compiles Autogen, prepares the emtl files and runs the generator for Framework"
        depends="compileAutogen, generateEMTL, generateFrameworkCode"
    />
    

    (Step 2 Errors)
    generateEMTL:
    [acceleoCompiler] generateDataAccessObject.mtl
    [acceleoCompiler] 5:The metamodel couldn't be resolved
    [acceleoCompiler] 5:The metamodel couldn't be resolved
    [acceleoCompiler] 5:The metamodel couldn't be resolved
    [acceleoCompiler] 
    [acceleoCompiler] generatePerstNode.mtl
    [acceleoCompiler] 5:The metamodel couldn't be resolved
    [acceleoCompiler] 5:The metamodel couldn't be resolved
    [acceleoCompiler] 
    [acceleoCompiler] TreeWalk.mtl
    [acceleoCompiler] 5:The metamodel couldn't be resolved
    [acceleoCompiler] 5:The metamodel couldn't be resolved
    [acceleoCompiler] 
    
    BUILD FAILED
    C:\Framework\build.xml:170: generateDataAccessObject.mtl
    5:The metamodel couldn't be resolved
    5:The metamodel couldn't be resolved
    5:The metamodel couldn't be resolved
    
    generatePerstNode.mtl
    5:The metamodel couldn't be resolved
    5:The metamodel couldn't be resolved
    
    TreeWalk.mtl
    5:The metamodel couldn't be resolved
    5:The metamodel couldn't be resolved
    
    
        at org.eclipse.acceleo.parser.compiler.AcceleoCompiler.execute(AcceleoCompiler.java:121)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
        at org.apache.tools.ant.Main.runBuild(Main.java:809)
        at org.apache.tools.ant.Main.startAnt(Main.java:217)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
    

2 个答案:

答案 0 :(得分:1)

Acceleo表示无法解析元模型。您的发电机使用的包装是什么?如果您只是使用http://www.eclipse.org/EMF/2002/Ecore,则可以在不注册元模型的情况下进行编译,因为“Ecore”是一个特定的用例。否则,您应该编写元模型的包的类而不是“org.eclipse.emf.ecore.EcorePackage”。

答案 1 :(得分:0)

[module generateDataAccessObject(...)]中移除额外的东西实际上解决了问题。如果我只包含http://www.eclipse.org/emf/2002/Ecore and http://www.eclipse.org/acceleo/mtl/3.0,那么它就可以了。