Tycho 编译器未从插件依赖项中找到 类

Tycho compiler does not find classes from plugin dependecies

我正在尝试使用 Tycho 构建一个插件。 Eclipse 工作区中没有错误,但是当我尝试使用 Maven 编译它时出现以下错误(超过 57 个错误):

    [INFO] Resolving dependencies of MavenProject: uk.xman.tool:xman.xtend.conditiondsl:2.0.0 @ C:\Users\Simone\OneDrive\Eclipse\xman.xtend.conditiondsl\pom.xml
    [INFO] Resolving class path of MavenProject: uk.xman.tool:xman.xtend.conditiondsl:2.0.0 @ C:\Users\Simone\OneDrive\Eclipse\xman.xtend.conditiondsl\pom.xml
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Build Order:
    [INFO] 
    [INFO] xman.maven.parent
    [INFO] xman.eclipse.target_definition
    [INFO] xman.xtend.conditiondsl
    [INFO] 
    [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building xman.maven.parent 2.0.0
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ xman.maven.parent ---
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building xman.eclipse.target_definition 2.0.0
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ xman.eclipse.target_definition ---
    [INFO] Deleting C:\Users\Simone\OneDrive\Eclipse\xman.eclipse.target_definition\target
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building xman.xtend.conditiondsl 2.0.0
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ xman.xtend.conditiondsl ---
    [INFO] Deleting C:\Users\Simone\OneDrive\Eclipse\xman.xtend.conditiondsl\target
    [INFO] 
    [INFO] --- tycho-packaging-plugin:0.22.0:build-qualifier (default-build-qualifier) @ xman.xtend.conditiondsl ---
    [INFO] The project's OSGi version is 2.0.0
    [INFO] 
    [INFO] --- tycho-packaging-plugin:0.22.0:validate-id (default-validate-id) @ xman.xtend.conditiondsl ---
    [INFO] 
    [INFO] --- tycho-packaging-plugin:0.22.0:validate-version (default-validate-version) @ xman.xtend.conditiondsl ---
    [INFO] 
    [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ xman.xtend.conditiondsl ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory C:\Users\Simone\OneDrive\Eclipse\xman.xtend.conditiondsl\src\main\resources
    [INFO] 
    [INFO] --- tycho-compiler-plugin:0.22.0:compile (default-compile) @ xman.xtend.conditiondsl ---
    [INFO] Compiling 36 source files to C:\Users\Simone\OneDrive\Eclipse\xman.xtend.conditiondsl\target\classes
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO] 
    [INFO] xman.maven.parent ................................. SUCCESS [  0.087 s]
    [INFO] xman.eclipse.target_definition .................... SUCCESS [  0.005 s]
    [INFO] xman.xtend.conditiondsl ........................... FAILURE [  2.628 s]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 32.542 s
    [INFO] Finished at: 2015-06-08T19:36:02+00:00
    [INFO] Final Memory: 64M/154M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.22.0:compile (default-compile) on project xman.xtend.conditiondsl: Compilation failure: Compilation failure:
    [ERROR] C:\Users\Simone\OneDrive\Eclipse\xman.xtend.conditiondsl\src-gen\uk\ac\man\xman\dsl\services\ConditionDSLGrammarAccess.java:[937]
    [ERROR] public XbaseGrammarAccess.XExpressionInsideBlockElements getXExpressionInsideBlockAccess() {
    [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [ERROR] XbaseGrammarAccess.XExpressionInsideBlockElements cannot be resolved to a type
    [ERROR] C:\Users\Simone\OneDrive\Eclipse\xman.xtend.conditiondsl\src-gen\uk\ac\man\xman\dsl\services\ConditionDSLGrammarAccess.java:[938]
    [ERROR] return gaXbase.getXExpressionInsideBlockAccess();
    [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [ERROR] The method getXExpressionInsideBlockAccess() is undefined for the type XbaseGrammarAccess
    [ERROR] C:\Users\Simone\OneDrive\Eclipse\xman.xtend.conditiondsl\src-gen\uk\ac\man\xman\dsl\services\ConditionDSLGrammarAccess.java:[942]
    [ERROR] return getXExpressionInsideBlockAccess().getRule();
    [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [ERROR] The method getXExpressionInsideBlockAccess() is undefined for the type ConditionDSLGrammarAccess
    [ERROR] C:\Users\Simone\OneDrive\Eclipse\xman.xtend.conditiondsl\src-gen\uk\ac\man\xman\dsl\parser\antlr\internal\InternalConditionDSLParser.java:[3918]
    [ERROR] newLeafNode(kw, grammarAccess.getOpCompareAccess().getLessThanSignEqualsSignKeyword_1());
    [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [ERROR] The method getLessThanSignEqualsSignKeyword_1() is undefined for the type XbaseGrammarAccess.OpCompareElements
    [ERROR] C:\Users\Simone\OneDrive\Eclipse\xman.xtend.conditiondsl\src-gen\uk\ac\man\xman\dsl\parser\antlr\internal\InternalConditionDSLParser.java:[4541]
    [ERROR] newLeafNode(kw, grammarAccess.getOpOtherAccess().getLessThanSignEqualsSignGreaterThanSignKeyword_9());
    [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [ERROR] The method getLessThanSignEqualsSignGreaterThanSignKeyword_9() is undefined for the type XbaseGrammarAccess.OpOtherElements
    [ERROR] C:\Users\Simone\OneDrive\Eclipse\xman.xtend.conditiondsl\src-gen\uk\ac\man\xman\dsl\parser\antlr\internal\InternalConditionDSLParser.java:[5748]
    [ERROR] newCompositeNode(grammarAccess.getXCastedExpressionAccess().getXMemberFeatureCallParserRuleCall_0());
    [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [ERROR] The method getXMemberFeatureCallParserRuleCall_0() is undefined for the type XbaseGrammarAccess.XCastedExpressionElements
    [ERROR] C:\Users\Simone\OneDrive\Eclipse\xman.xtend.conditiondsl\src-gen\uk\ac\man\xman\dsl\parser\antlr\internal\InternalConditionDSLParser.java:[6946]
    [ERROR] newCompositeNode(grammarAccess.getXPrimaryExpressionAccess().getXFeatureCallParserRuleCall_3());
    [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [ERROR] The method getXFeatureCallParserRuleCall_3() is undefined for the type XbaseGrammarAccess.XPrimaryExpressionElements
    [ERROR] C:\Users\Simone\OneDrive\Eclipse\xman.xtend.conditiondsl\src-gen\uk\ac\man\xman\dsl\parser\antlr\internal\InternalConditionDSLParser.java:[6968]
    [ERROR] newCompositeNode(grammarAccess.getXPrimaryExpressionAccess().getXLiteralParserRuleCall_4());
    [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [ERROR] The method getXLiteralParserRuleCall_4() is undefined for the type XbaseGrammarAccess.XPrimaryExpressionElements
    [ERROR] C:\Users\Simone\OneDrive\Eclipse\xman.xtend.conditiondsl\src-gen\uk\ac\man\xman\dsl\parser\antlr\internal\InternalConditionDSLParser.java:[6990]
    [ERROR] newCompositeNode(grammarAccess.getXPrimaryExpressionAccess().getXIfExpressionParserRuleCall_5());
    [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [ERROR] The method getXIfExpressionParserRuleCall_5() is undefined for the type XbaseGrammarAccess.XPrimaryExpressionElements
    [ERROR] C:\Users\Simone\OneDrive\Eclipse\xman.xtend.conditiondsl\src-gen\uk\ac\man\xman\dsl\parser\antlr\internal\InternalConditionDSLParser.java:[7012]
    [ERROR] newCompositeNode(grammarAccess.getXPrimaryExpressionAccess().getXForLoopExpressionParserRuleCall_6());
    [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

这是清单:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: xman.xtext.conditiondsl
Bundle-Vendor: University of Manchester
Bundle-Version: 2.0.0
Bundle-SymbolicName: xman.xtend.conditiondsl;singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.xtext.xbase;bundle-version="2.4.3",
 org.eclipse.xtext.generator;bundle-version="2.4.3",
 org.eclipse.emf.mwe2.launch;resolution:=optional,
 org.eclipse.xtext;bundle-version="2.4.3",
 org.eclipse.xtext.util;bundle-version="2.4.3",
 org.eclipse.emf.ecore, 
 org.eclipse.emf.common,
 org.antlr.runtime,
 org.eclipse.xtext.common.types;bundle-version="2.4.3",
 org.eclipse.xtext.xbase.lib;bundle-version="2.4.3"
Import-Package: org.apache.commons.logging;version="1.1.1",
 org.apache.log4j;version="1.2.15",
 org.eclipse.xtext.xbase.lib
Export-Package: uk.ac.man.xman.dsl,
 uk.ac.man.xman.dsl.conditionDSL,
 uk.ac.man.xman.dsl.conditionDSL.impl,
 uk.ac.man.xman.dsl.conditionDSL.util,
 uk.ac.man.xman.dsl.formatting;uses:="org.eclipse.xtext.formatting.impl",
 uk.ac.man.xman.dsl.generator;uses:="org.eclipse.emf.ecore.resource,org.eclipse.xtext.generator",
 uk.ac.man.xman.dsl.jvmmodel;uses:="org.eclipse.emf.ecore,org.eclipse.xtext.xbase.jvmmodel",
 uk.ac.man.xman.dsl.parser.antlr,
 uk.ac.man.xman.dsl.parser.antlr.internal,
 uk.ac.man.xman.dsl.scoping;uses:="org.eclipse.xtext.scoping.impl",
 uk.ac.man.xman.dsl.serializer,
 uk.ac.man.xman.dsl.services,
 uk.ac.man.xman.dsl.validation
Bundle-ClassPath: .
Bundle-RequiredExecutionEnvironment: J2SE-1.5

似乎 Tycho 编译器在尝试编译时没有考虑插件依赖性:缺少的类型在 MANIFEST 中所需的 jar org.eclipse.xtext.xbase 中定义。

有解决此问题的想法吗?

问题出在 org.eclipse.xtext.xbase 的版本上。

当您启用调试输出 (-X) 时,tycho-compiler-plugin 的日志输出包括 Tycho 编译所针对的 JAR 的确切列表。 (寻找 [DEBUG] Classpath:

所以如果你看到 Tycho 的依赖解析选择了错误的 org.eclipse.xtext.xbase 版本,你可以

  • 更改 target platform 以便仅包含您需要的版本,或者
  • 使 MANIFEST.MF 中声明的依赖项更具限制性。

在您的示例中,您使用 Require-Bundle: org.eclipse.xtext.xbase;bundle-version="2.4.3" 指定您需要 2.4.3 或更高版本。但也许这是错误的,你实际上需要更高的最低版本。