This is the continuation of
- Sling OSGi Track pt 1: hand-rolled service bundle and
- Sling OSGi Track pt 2: using Felix' bundle plugin for manifest entries and
- Sling OSGi Track pt 3: replacing the Activator with DS
In this part, I will show how to install a maven-built bundle to sling directly from maven
- Show how to install a maven-built bundle to sling
- Add the sling plugin to the pom
- Add the ASF incubating repository
- Build and Install
Add the sling plugin to the pom
Add the following snippet to the build plugins.
(8-10) bind the execution of the plugin's install-bundle goal to install phase goal
(11-15) configure the sling URL to use, the username and the password.
1: <plugin>2: <groupId>org.apache.sling</groupId>3: <artifactId>maven-sling-plugin</artifactId>4: <version>2.0.2-incubator</version>5: <executions>6: <execution>7: <id>install-bundle</id>8: <goals>9: <goal>install</goal>10: </goals>11: <configuration>12: <slingUrl>http://localhost:7402/system/console/install</slingUrl>13: <user>admin</user>14: <password>admin</password>15: </configuration>16: </execution>17: </executions>18: </plugin>
Add the ASF incubating repository
The sling plugin (to date) lives in the Apache Software Foundation's incubating repository (as sling is still in the incubator).
So for maven to be able to resolve the plugin, we must add the repository to the pom.
While we're at it, we will also add it both as a plugin and as a regular artifact repository, as we'll be using other parts of sling later on.
Add the following right before the <dependencies> section:
1: <repositories>2: <repository>3: <id>apache.incubating</id>4: <name>Apache Incubating Repository</name>5: <url>http://people.apache.org/repo/m2-incubating-repository</url>6: </repository>7: </repositories>8: <pluginRepositories>9: <pluginRepository>10: <id>apache.incubating.plugins</id>11: <name>Apache Incubating Plugin Repository</name>12: <url>http://people.apache.org/repo/m2-incubating-repository13: </url>14: </pluginRepository>15: </pluginRepositories>
Build and Install
Now, execute maven so:
mvn clean install
To verify that the new package is deployed, go to the sling console at http://localhost:7402/system/console/list and click on the "OSGI Test Bundle" to see the details
(this only works in Firefox, not on IE, about others I do not know).
I bumped the version by 0.0.1 for each part of this series, so we're now at 0.0.4.
The version is taken from the pom's <version> element.
As usual, go to http://localhost:7402/test to see the service say "hello"