"API restriction error" when exporting Eclipse plugin with maven-tycho:
Asked Answered
S

2

6

I'm currently trying to build and export an Eclipe plugin with Maven (Tycho extension) but it throws a buch of API restriction errors

[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')

My pom.xml files: (see this question for more details)

Parent 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>
  <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>

Feature 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>

Plugin 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>

I'm sure that plugin and exporting feature configurations (i.e. MANIFEST and feature.xml) are written well. I've already tried:

  1. Set all API violations to "Ignore" in Eclipse > Window > Preferences > Java > Compiler > Error/Warning
  2. Deleted JRE from project's Build Path and added it again (as suggested in several bug topics)
  3. Added -warn:none to the pom.xml (can be seen in configurations presented above)

I found no additional recommendations in Google. Should I report this as a bug or is it my mistake?

Semipro answered 2/3, 2015 at 11:28 Comment(4)
Do you actually want to use the MessageFormat from 'com.ibm.icu'? Or were you trying to use the normal java.text.MessageFormat?Mindimindless
compilerArgument is not a parameter on the tycho-maven-plugin, so this configuration has no effect.Dandify
@greg-449, unfoturnately, there're many other restricted classes. They are unavoidable due to nature of project.Semipro
@Dandify thank you, that was the case. My mistake: didn't take attention, which plugin I actually used. To be fair, my plugin build configuration ordered to use already compiled files, so I thought tycho was failing at validating.Semipro
S
6

Thanks to the @oberlies comment, answer is found. compilerArgument should be passed to tycho-compiler-plugin not to tycho-maven-plugin so proper configuration is

   <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>

For some reason Tycho doesn't warn about mismatched tags neither in editor nor during run.

Semipro answered 2/3, 2015 at 15:4 Comment(1)
Tycho doesn't warn about mismatched tags - The same applies to all Maven configuration: The plugin configuration applies to all goals of the Maven plugin, so it is normal that there are tags that don't apply. Maven (or Tycho) could try to find tags that will never apply by scanning all potential goals and their parameters - but this just hasn't been implemented yet...Dandify
L
1

just to add if the eclipse plugin project does have project specific settings, these might override the compiler behavior, so the error could still appear even if the flag was set to warning:

        <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>

you may also remove the project specific settings folder from the plugin or adjust the settings for this compiler flag.

Lumpy answered 5/9, 2017 at 11:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.