首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用maven-tycho导出Eclipse插件时,"API限制错误“:

使用maven-tycho导出Eclipse插件时,"API限制错误“:
EN

Stack Overflow用户
提问于 2015-03-02 11:28:37
回答 2查看 3.2K关注 0票数 4

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

代码语言:javascript
复制
[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问题)

父项目

代码语言:javascript
复制
<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>

专题项目:

代码语言:javascript
复制
<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>

插件项目:

代码语言:javascript
复制
<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>

我确信插件和导出特性配置(即清单和feature.xml)写得很好。我已经试过了

  1. 将Eclipse > Window > Preferences > Java > Compiler > Error/Warning中的所有API冲突设置为“忽略”
  2. 从项目的构建路径中删除JRE并再次添加它(如几个bug主题中所建议的)
  3. 将-warn:none添加到pom.xml中(在上面介绍的配置中可以看到)

我在Google中没有发现任何其他建议。我应该把这个报告为错误还是我的错?

EN

回答 2

Stack Overflow用户

发布于 2015-03-02 15:04:30

多亏了@oberlies的评论,我们找到了答案。compilerArgument应该传递给tycho-编译器插件,而不是tycho-maven-plugin,所以正确的配置是

代码语言:javascript
复制
   <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在编辑器中和运行期间都不会警告不匹配的标记。

票数 5
EN

Stack Overflow用户

发布于 2017-09-05 11:12:51

仅仅为了添加如果eclipse插件项目确实具有特定于项目的设置,这些设置可能会覆盖编译器行为,因此即使将标志设置为警告,错误仍然可能出现:

代码语言:javascript
复制
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-compiler-plugin</artifactId>
            <version>${tycho.version}</version>
            <configuration>
                <compilerArgument>-warn:+discouraged,forbidden</compilerArgument>
                <useProjectSettings>false</useProjectSettings>
            </configuration>
        </plugin>

您还可以从插件中删除特定于项目的设置文件夹,或者调整此编译器标志的设置。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28808688

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档