Reputation: 827
I have included Google Gson dependency in the pom.xml
of my project as shown below:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2</version>
</dependency>
I'm able to build the project without any issues but when I'm hitting the URL, the page doesn't load.
This is a CQ5 project and when I visit system/console to debug the issue, I find that the project package is not started.
Further, it gives the error: com.google.gson,version=[2.2,3) -- Cannot be resolved
Any help would be appreciated.
Thanks
Upvotes: 0
Views: 2543
Reputation: 2539
I recommend to configure the package plugin (where you configure the filters) in your package project. As stated in the documentation:
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<configuration>
<embeddeds combine.children="append">
<embedded1>
<groupId>com.something.grouip</groupId>
<artifactId>your-artifact</artifactId>
</embedded1>
</embeddeds>
</configuration>
...
...
</plugin
Upvotes: 0
Reputation: 9304
Besides adding the dependency in pom.xml you have to install it in the OSGi container. You have 2 options:
1. Include the JAR into your CQ package.
All JARs put into CQ package folder /jcr_root/apps/APP_NAME/install
are installed automatically during CQ package installation. Therefore you can put the GSON library into this folder and it'll be added to the OSGi container.
If you are using assembly plugin to create CQ package, add following lines to the assembly descriptor:
<dependencySets>
<dependencySet>
<outputDirectory>/jcr_root/apps/YOUR_APP/install</outputDirectory>
</dependencySet>
</dependencySets>
It'll copy all dependencies with scope runtime
to the ouputDirectory
.
2. Add the JAR as an embedded dependency in your bundle
If you want to make the GSON available only for your bundle, but not for other bundles in the OSGi (eg. because there is already another version of GSON installed), you can embed the library. Use Embed-Dependency
directive of the Maven bundle plugin, eg:
<Embed-Dependency>gson;scope=runtime</Embed-Dependency>
Upvotes: 1