java – 使用maven-tycho导出Eclipse插件时出现“API限制错误”:
作者:互联网
我目前正在尝试使用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)写得很好.我已经尝试过了:
>在Eclipse>中将所有API违规设置为“忽略”窗口>偏好> Java>编译器>错误/警告
>从项目的构建路径中删除JRE并再次添加它(如几个bug主题中所建议的那样)
>在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,plugins,eclipse,maven,tycho 来源: https://codeday.me/bug/20190609/1205719.html