我正在尝试为android创建一个独立的ant构建文件。我们正在使用acceleo生成代码。
下面是我在build.xml中采取的步骤。
- 编译自动生成器
- 生成EMTL文件 从EMTL文件生成代码
现在,我可以运行步骤1,它工作得很好。然后我运行步骤2,它失败了,出现以下错误(步骤2错误)。然后我可以运行步骤3,它工作得很好。然后我检查我所有的文件和生成的代码,一切看起来都很好。但是,第二步的错误确实困扰着我,我需要解决它们。
如果您需要更多的信息,请告诉我,我将不胜感激。
下面是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:Frameworkbuild.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)
Acceleo表示无法解析元模型。你的发电机使用的包是什么?如果您只是使用http://www.eclipse.org/EMF/2002/Ecore,则可以在不注册元模型的情况下进行编译,因为"Ecore"是一个特定的用例。否则,您应该编写元模型包的类,而不是"org.eclipse.emf.ecore.EcorePackage"。
从[module generateDataAccessObject(...)]
中删除额外的东西实际上解决了这个问题。如果我只包含http://www.eclipse.org/emf/2002/Ecore and http://www.eclipse.org/acceleo/mtl/3.0
,那么它工作