ericfaerber.com

Just another WordPress.com site

Archive for the tag “OSGI”

Install OSGI Bundles Using Maven

For my job I do a lot of CQ5 work. Often this involves creating OSGI bundles. To install an OSGI bundle you either have to put the bundle in /apps/myproject/install or manually install it in the Felix Web Console. Both of these methods get old after doing it multiple times.

Sling has a Maven plugin that simplifies this process by installing the bundle for you when you build the project. Simply add the following code to your pom.xml file for your Maven project and then select the install-osgi profile when building.

<profile>
	<id>install-osgi</id>
	<activation>
		<property>
			<name>install-osgi</name>
		</property>
	</activation>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.sling</groupId>
				<artifactId>maven-sling-plugin</artifactId>
				<version>2.0.4-incubator</version>
				<executions>
					<execution>
						<id>install-osgi</id>
						<goals>
							<goal>install</goal>
						</goals>
						<configuration>
							<slingUrl>http://localhost:4502/system/console/install</slingUrl>
							<user>admin</user>
							<password>admin</password>
							<skip>false</skip>
							<bundleStartLevel>20</bundleStartLevel>
							<bundleStart>true</bundleStart>
							<refreshPackages>true</refreshPackages>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</profile>

Or if you are using command line to build the project, add -Dinstall-osgi to the arguments. You can create as many profiles as you’d like for the different environments you may be working with (author, publish).

Advertisements

Post Navigation