java - 使用 maven-tycho : 导出 Eclipse 插件时为 "API restriction error"

标签 java eclipse maven plugins tycho

我目前正在尝试使用 Maven(Tycho 扩展)构建和导出 Eclipe 插件,但它会抛出大量 API 限制错误

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:09 min
[INFO] Finished at: 2015-03-02T13:57:35+03:00
[INFO] Final Memory: 78M/187M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.22.0:compile (default-compile) on project GDBFifoBlocks: Compilation failure: Compilation failure:
[ERROR] /home/siarshai/Programming/Workspaces/eclipse-rcp-workspace/GDBFifoBlocksBackbone/src/neuromatrixplugin/fifoblocks/backbone/viewmodel/fifo/FIFOBlockBitFieldVMNode.java:[240]
[ERROR] update.setLabel(getMessageFormat().format(
[ERROR] messageAttrs, new StringBuffer(), null).toString(), columnIndex);
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The method 'MessageFormat.format(Object[], StringBuffer, FieldPosition)' is not API (restriction on classpath entry '/home/siarshai/.m2/repository/p2/osgi/bundle/com.ibm.icu/52.1.1.v201501240615/com.ibm.icu-52.1.1.v201501240615.jar')
[ERROR] /home/siarshai/Programming/Workspaces/eclipse-rcp-workspace/GDBFifoBlocksBackbone/src/neuromatrixplugin/fifoblocks/backbone/viewmodel/fifo/FIFOBlockBitFieldVMNode.java:[345]
[ERROR] update.setLabel(getMessageFormat().format(combinedAttrs, new StringBuffer(), null).toString(), columnIndex);
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The method 'MessageFormat.format(Object[], StringBuffer, FieldPosition)' is not API (restriction on classpath entry '/home/siarshai/.m2/repository/p2/osgi/bundle/com.ibm.icu/52.1.1.v201501240615/com.ibm.icu-52.1.1.v201501240615.jar')
[ERROR] /home/siarshai/Programming/Workspaces/eclipse-rcp-workspace/GDBFifoBlocksBackbone/src/neuromatrixplugin/fifoblocks/backbone/viewmodel/fifo/FIFOBlockBitFieldVMNode.java:[395]
[ERROR] update.setLabel(getMessageFormat().format(combinedAttrs, new StringBuffer(), null).toString(), columnIndex);
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The method 'MessageFormat.format(Object[], StringBuffer, FieldPosition)' is not API (restriction on classpath entry '/home/siarshai/.m2/repository/p2/osgi/bundle/com.ibm.icu/52.1.1.v201501240615/com.ibm.icu-52.1.1.v201501240615.jar')
[ERROR] /home/siarshai/Programming/Workspaces/eclipse-rcp-workspace/GDBFifoBlocksBackbone/src/neuromatrixplugin/fifoblocks/backbone/viewmodel/fifo/FIFOBlockElementVMNode.java:[290]
[ERROR] update.setLabel(getMessageFormat().format(messageAttrs, new StringBuffer(), null).toString(), columnIndex);
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The method 'MessageFormat.format(Object[], StringBuffer, FieldPosition)' is not API (restriction on classpath entry '/home/siarshai/.m2/repository/p2/osgi/bundle/com.ibm.icu/52.1.1.v201501240615/com.ibm.icu-52.1.1.v201501240615.jar')
[ERROR] /home/siarshai/Programming/Workspaces/eclipse-rcp-workspace/GDBFifoBlocksBackbone/src/neuromatrixplugin/fifoblocks/backbone/viewmodel/fifo/FIFOBlockElementVMNode.java:[366]
[ERROR] update.setLabel(getMessageFormat().format(combinedAttrs, new StringBuffer(), null).toString(), columnIndex);
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The method 'MessageFormat.format(Object[], StringBuffer, FieldPosition)' is not API (restriction on classpath entry '/home/siarshai/.m2/repository/p2/osgi/bundle/com.ibm.icu/52.1.1.v201501240615/com.ibm.icu-52.1.1.v201501240615.jar')

我的 pom.xml 文件:(有关更多详细信息,请参阅 this 问题)

父项目

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <groupId>NMGDBPluginFeature</groupId>
  <artifactId>NMGDBPluginFeature.parent</artifactId>
  <version>1.0.0.gdbfifoblocks</version>
  <packaging>pom</packaging>

   <properties>
      <tycho-version>0.22.0</tycho-version>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
   </properties>

   <repositories>
        <repository>
            <id>eclipse-luna</id>
            <layout>p2</layout>
            <url>http://download.eclipse.org/releases/luna</url>
        </repository>
    </repositories>

   <build>
      <plugins>
         <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-maven-plugin</artifactId>
            <version>0.22.0</version>
            <extensions>true</extensions>   

            <configuration>
                <compilerArgument>-warn:none</compilerArgument>     
                <compilerArgument>-err:none</compilerArgument>      
            </configuration>

         </plugin>
      </plugins>
   </build>



  <modules>
    <module>../GDBFifoBlocksBackbone</module>
    <module>../NMGDBPluginFeature</module>
  </modules>

</project>

特色项目:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>NMGDBPluginFeature</groupId>
    <artifactId>NMGDBPluginFeature.parent</artifactId>
    <version>1.0.0.gdbfifoblocks</version>
    <relativePath>./../GeneralExportingProject</relativePath>
  </parent>

  <artifactId>NMGDBPluginFeature</artifactId>
  <packaging>eclipse-feature</packaging>


   <build>
      <plugins>
         <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-maven-plugin</artifactId>
            <version>0.22.0</version>
            <extensions>true</extensions>   

            <configuration>
                <compilerArgument>-warn:none</compilerArgument>     
                <compilerArgument>-err:none</compilerArgument>      
            </configuration>

         </plugin>
      </plugins>
   </build>

</project>

插件项目:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>NMGDBPluginFeature</groupId>
    <artifactId>NMGDBPluginFeature.parent</artifactId>
    <version>1.0.0.gdbfifoblocks</version>
    <relativePath>./../GeneralExportingProject</relativePath>
  </parent>

  <artifactId>GDBFifoBlocks</artifactId>
  <packaging>eclipse-plugin</packaging>

   <build>
      <plugins>
         <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-maven-plugin</artifactId>
            <version>0.22.0</version>
            <extensions>true</extensions>

            <configuration>
                <compilerArgument>-warn:none</compilerArgument>     
                <compilerArgument>-err:none</compilerArgument>      
            </configuration>

         </plugin>
      </plugins>
   </build>

</project>

我确定插件和导出功能配置(即 MANIFEST 和 feature.xml)写得很好。我已经尝试过:

  1. 在 Eclipse > Window > Preferences > Java > Compiler > Error/Warning 中将所有 API 违规设置为“忽略”
  2. 从项目的构建路径中删除 JRE 并重新添加它(如几个错误主题中所建议的那样)
  3. 在 pom.xml 中添加了 -warn:none(可以在上面的配置中看到)

我在 Google 中没有找到其他推荐。我应该将此报告为错误还是我的错误?

最佳答案

感谢@oberlies 的评论,找到了答案。 compilerArgument 应该传递给 tycho-compiler-plugin 而不是传递给 tycho-maven-plugin 所以正确的配置是

   <build>
      <plugins>

        <plugin>
              <groupId>org.eclipse.tycho</groupId>
              <artifactId>tycho-compiler-plugin</artifactId>
              <version>0.22.0</version>
            <configuration>
                <compilerArgument>-warn:none</compilerArgument>     
                <compilerArgument>-err:none</compilerArgument>      
            </configuration>
        </plugin>

         <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-maven-plugin</artifactId>
            <version>0.22.0</version>
            <extensions>true</extensions>   
         </plugin>

      </plugins>
   </build>

出于某种原因,Tycho 不会在编辑器中或运行期间就标签不匹配发出警告。

关于java - 使用 maven-tycho : 导出 Eclipse 插件时为 "API restriction error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28808688/

相关文章:

java - Maven com.google 无法解析输入

java - 按对象属性对元素进行分组

java - 尝试使用 java 从 Gmail 读取电子邮件时出现 MessagingException

python - Pydev Python调试中如何跳转到下一个断点

java - 安卓工作室。类别搜索停止工作。 (导航 -> 类...)

java - Eclipse 不启动 (Ubuntu) : JVM terminated. 退出代码=2

java - Solrj NoClassDefFoundError

java - ORA-01866 与 JDeveloper 10.1.3.4

java - 在没有构造函数的情况下初始化类时会调用什么?

java - 应用程序部署在 jboss 上,但当我尝试访问时出现 404 错误