I am using https://eclipse.adobe.com/aem/dev-tools/ to create a project. Once created, I have the following structure in eclipse:
I want to be able to use the GoogleMaps API in my component. So I add the dependency for it in hometest.core/pom.xml
<dependency>
<groupId>com.google.maps</groupId>
<artifactId>google-maps-services</artifactId>
<version>0.1.7</version>
<scope>compile</scope>
</dependency>
I've also added everything to the _exportcontents
in hometest.core/pom.xml
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Directory>OSGI-INF/lib</Embed-Directory>
<_exportcontents>
*
</_exportcontents>
</instructions>
</configuration>
</plugin>
I then import com.google.maps.model.GeocodingResult
into HelloServiceProxy.java
as shown below:
I install the package to local instance of aem using mvn clean install -PautoInstallPackage
However, when I try to add the component to the page I get the following error:
java.lang.Error: Unresolved compilation problem: Only a type can be imported. com.google.maps.model.GeocodingResult resolves to a package
Below is screenshot of the error:
Update 1
I started with another brand new AEM project and did the following things:
in core/pom.xml added configuration settings for
maven-bundle-plugin
like this<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency> <Embed-Directory>OSGI-INF/lib</Embed-Directory> <_exportcontents> * </_exportcontents> </instructions> </configuration> </plugin>
Added google maps dependency like this:
<dependency> <groupId>com.google.maps</groupId> <artifactId>google-maps-services</artifactId> <version>0.1.7</version> <scope>compile</scope> </dependency>
deployed with this
mvn clean install -PautoInstallPackage
When I try to add component to the page I get errors:
java.lang.Error: Unresolved compilation problems:
Only a type can be imported. com.google.maps.model.GeocodingResult resolves to a package
Only a type can be imported. org.demo.anothertest.core.HelloService resolves to a package
HelloService cannot be resolved to a type
HelloService cannot be resolved to a type
The error indicates that the classes from
google-maps-services
bundle are not available to thehometest.core
bundle. It might very well be that embedding bundles does not work at this point.Can you try deploying a separate bundle which embeds
google-maps-services
and see if that works?