Skip to content

Instantly share code, notes, and snippets.

@alem0lars
Last active December 11, 2015 08:29
Show Gist options
  • Save alem0lars/4573911 to your computer and use it in GitHub Desktop.
Save alem0lars/4573911 to your computer and use it in GitHub Desktop.
Create a OSGi Maven Project
PRJ_BASE_DIR="/usr/local/archive/projects" # Change this with your project parent directory.
PRJ_GROUP_ID="my.group.id"
PRJ_ARTIFACT_ID="myArtifact"
cd ${PRJ_BASE_DIR}
mvn org.ops4j:maven-pax-plugin:create-project -DgroupId=${PRJ_GROUP_ID} -DartifactId=${PRJ_ARTIFACT_ID}
# It allows to manage the OSGi runtime using the web-ui
mvn pax:import-bundle -DgroupId=org.apache.felix -DartifactId=org.apache.felix.webconsole -DimportTransitive=true -DimportOptional=true
mvn pax:import-bundle -DgroupId=org.apache.felix -DartifactId=org.apache.felix.http.jetty -DimportTransitive=true -DimportOptional=true -DwidenScope=true
mvn pax:import-bundle -DgroupId=org.apache.geronimo.bundles -DartifactId=json -DimportTransitive=true -DimportOptional=true -DwidenScope=true
# Check for the version of the slf4j-api dependency listed in the provision pom and substitute the
# following variable (SL4J_VERS) with that version
SLF4J_VERS="1.3.1"
mvn pax:import-bundle -DgroupId=org.slf4j -DartifactId=slf4j-simple -Dversion=${SLF4J_VERS} -DimportTransitive=true -DimportOptional=true -DwidenScope=true
# Enable the configuration admin service
mvn pax:import-bundle -DgroupId=org.apache.felix -DartifactId=org.apache.felix.configadmin -DwidenScope=true
# Enable the logging
mvn pax:import-bundle -DgroupId=org.apache.felix -DartifactId=org.apache.felix.log -DwidenScope=true
mvn clean install
# When you run mvn pax:provision you start the OSGi runtime environment.
# Everytime that you want to provision, you firstly need to install => mvn install pax:provision
# You can manage that using the web admin (http://localhost:8080). Let's try that..
mvn pax:provision
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment