I found the answer to my question. In order to configure OSGI in confluence one should configure the maven plugin:
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-***-plugin</artifactId> <!-- *** is the name of the application (product) you're using -->
<version>3.2.3</version>
<extensions>true</extensions>
<configuration>
<productVersion>${product.version}</productVersion>
<instructions>
<!-- OSGi instructions go here -->
</instructions>
</configuration>
</plugin>
and put the Import-Package declarations there.