SlideShare a Scribd company logo
OSGi with Maven
Improved developer productivity thanks to standard tools
Thank you!
To correct me:
luke | code-house.org
twitter: @ldywicki
code: https://github.com/Code-House/eclipsecon (under ASL 2.0)
Is it a perfect marriage?
Is it a perfect marriage?
Let's face the truth
Source: https://twitter.com/vorburger/status/1044203455055892481
Google trends
About me
Self employed consultant since 2008, a middleware specialist.
● Open Source enthusiast since forever
● Apache Karaf
○ committer since 2010
○ project management committee since 2012
● I worked for
Red Hat, FUSE Source, been involved in projects for Alcatel-Lucent, Nokia Siemens Networks,
Polish Post Bank, Royal Bank of Scotland etc.
● Eclipse user since 2003
● Maven user since 2006
Few words about world
How does it look a like outhere
Tool usage
Source: https://snyk.io/blog/jvm-ecosystem-report-2018-tools
Build tools
Source: https://snyk.io/blog/jvm-ecosystem-report-2018-tools
Artifact repositories
Source: https://snyk.io/blog/jvm-ecosystem-report-2018-tools
Testing tools
Source: https://snyk.io/blog/jvm-ecosystem-report-2018-tools
Runtimes
Source: https://snyk.io/blog/jvm-ecosystem-report-2018-platform-application
OSGi is not classified in runtimes
● Some of server runtimes can run OSGi
● OSGi can be run inside a WAR
● There are a lot of people who knows Maven, Tomcat, IntellIJ and Eclipse and development model
promoted by these tools
Communication troubles
Pay attention to what you say
There is a problem finding people
knowing OSGi.
Closer look on Maven
Maven is ...
● build tool
○ compiler
○ test runner
○ packager
○ site generator
But it is also
● Tool promoting convention over configuration
● Repository client
● A dependency manager
● A pluggable machina
a word about configuration
● Global
$M2_HOME/conf/settings.xml
● Local, user settings
~/.m2/settings.xml
● Project
pom.xml
a bit about inheritance
● Projects can be organised into a tree:
○ super pom (implicit)
■ organisation POM
● project A
○ child project 1
○ child project 2
● project B
○ first child
○ second child
what is inherited
● dependency management
● dependencies
● plugins
○ executions
○ configurations
● resources configuration
Convention over configuration
● You palce sources in src/
○ code in main/java, resources in main/resources
○ tests in test/java
● Results end up in target/
● There are standard build phases (pre-test, test, package etc.)
● Plugins are hooked into phases
● Depending on plugin developer, there are various defaults
Repository client
● Maven brought remote repository idea to mainstream
● Elements are identified by:
○ group id
○ artifact id
○ version
○ classifier
○ type (packaging)
Location: ${group id}/${artifact id}/${version}/${artifact id}-${version}[-${classifier}].${type}
● One project may have multiple repositories
● The central.maven.org is enabled by default
● You are free to define own repositories
○ in project descriptor
○ local or global maven settings
Dependency manager
● Maven recognizes basic dependency scopes
○ compile
○ runtime
○ test (not transitive)
○ provided (not transitive)
● system / import scopes are special kind
● Dependencies can be managed / forced by parent and also overridden
Transient dependencies
What dependency management do
#include <dependency.h>
<dependencyManagement>
<dependency>
<groupId>org.eclipse.smarthome</groupId>
<artifactId>smarthome</artifactId>
<version>0.10.0-SNAPSHOT</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencyManagement>
Pluggable machina
● Maven internally uses simple IoC based on classpath scanning
● Classpath can be extended via plugin dependencies & extensions
● There is whole new extension mechanism in 3.x (enabling polyglot maven)
● Almost all, if not all, components are injected via IoC
● … did I mention that maven supports version ranges?
Versions and ranges under Maven
● 2 becomes 2.0.0 when comparing
● Special values in qualifier:
○ "alpha" < "beta" < "milestone" < "cr" / "rc" < "snapshot" < "final" / "ga" < "sp"
● 2.0-Snapshot matches [1,2.0) boundary (excludes 2.0 release)
● Customisable via SPI:
○ Version Scheme
○ Version Range Resolver
○ OSGi compatible version: https://github.com/Code-House/maven-osgi-resolver
Commonalities
Comparison
Element OSGi Maven
Build unit Bundle Project / Module
Dependency unit Package, req /cap Dependency
Platform definition Target Platform (PDE) Dependency management
Version ranges Yes Yes
Repositories OBR, P2 Maven repos
Project organisation
Systems are like onions
Source: http://www.downvids.net/shrek-moments-quot-ogres-are-like-onions-quot--317773.html, Shrek movie was made by DreamWorks
Each bigger system have
● Domain model
● Persistence
● Communication interface
● Many provider/consumer relationship between these parts
Properly structured project is
easier to run and maintain.
Most of OSGi projects is properly
structured.
Some Maven based projects have
good structure.
Basic project structure
● root
○ model
○ api
○ core
○ dao
■ api
■ core
○ web
■ api
■ core
○ features
Manifest is just another resource
How to generate manifest
<packaging>bundle</packaging>
<!-- … -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Export-Package>org.code_house.eclipsecon.mvnosgi.api</Export-Package>
<Private-Package>org.code_house.eclipsecon.mvnosgi.core</Private-Package>
<Bundle-Activator>org.code_house.eclipsecon.mvnosgi.core.Activator</Bundle-Activator>
</instructions>
</configuration>
</plugin>
bndlib ✔
Manifest defaults
Bundle-SymbolicName: ${project.groupId}.${project.artifactId}
Bundle-Version: ${project.version}
Bundle-Name: ${project.name}
Bundle-Description: ${project.description}
Bundle-Vendor: ${project.organization.name}
Bundle-License: ${project.license*.url}
Import-Package: *
Export-Package: *
Private-Package: *.impl.*, *.internal.*
Deployment
How to bring bundles to runtime
Quick look on Karaf
Pax URL
● By default Java runtime supports following URI schemes:
○ http[s]:
○ file:
● Java / OSGi framework allows to provide new schemes (ie. bundle:)
● Pax URL provides:
○ wrap:
○ classpath:
○ mvn:
○ and few more (exploded dir and similar)
Deploying bundles
● install mvn:org.code-house.eclipsecon.mvnosgi/api/RELEASE
● install mvn:org.code-house.eclipsecon.mvnosgi/core/RELEASE
● install mvn:org.code-house.eclipsecon.mvnosgi.dao/api/RELEASE
● install mvn:org.code-house.eclipsecon.mvnosgi.dao/core/RELEASE/jar
● install mvn:org.code-house.eclipsecon.mvnosgi.web/api/LATEST/x86_64/jar
Karaf feature
<feature name="book-service" version="${project.version}">
<feature>scr</feature>
<feature>cxf-jaxrs</feature>
<feature>aries-blueprint</feature>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi/core/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi/api/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi/model/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi.dao/api/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi.dao/core/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi.web/core/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi.web/api/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi/dto/1.0.0-SNAPSHOT</bundle>
<!-- … rest of stuff ... -->
</feature>
Testing
How to bring bundles to runtime
OSGi -> junit -> test
junit -> OSGi -> test
Demo time
Arquillian
Pax Exam
Pax Tinybundles
InputStream inp = bundle()
.activator(TestActivator.class)
.add(BookService.class)
.add(TestBookService.class)
.symbolicName("test-bundle")
.set(Constants.EXPORT_PACKAGE, "demo")
.set(Constants.IMPORT_PACKAGE, "demo")
.build();
Exam containers
● OSGi
● Karaf
● Tomcat
● Weld
● JBoss / Wildfly 8 / Wildfly 9
Example test
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerMethod.class)
public class ExampleIntegrationTest {
@Configuration public Option[] config() {
return options(junitBundles());
}
@Test …
}
Unit testing - Felix Connect
● Emulates OSGi framework
○ Activators
○ Service lookups
○ Bundles and classloaders
● Perfect candidate for unit testing based on plain maven classpath
Felix Connect
String bundleFilter = "(&(Bundle-SymbolicName=*)(!(Bundle-SymbolicName=org.osgi.*)))";
List<BundleDescriptor> descriptors = new ClasspathScanner().scanForBundles(bundleFilter, loader);
// setup felix-connect to use our bundles
Map<String, Object> config = new HashMap<>();
config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles);
PojoServiceRegistry reg = new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(config);
BundleContext bundleContext = reg.getBundleContext();
JUnit 5
AssertJ
// entry point for all assertThat methods and utility methods (e.g. entry)
import static org.assertj.core.api.Assertions.*;
// basic assertions
assertThat(frodo.getName()).isEqualTo("Frodo");
assertThat(frodo).isNotEqualTo(sauron);
Questions
Thank you!
To correct me:
luke | code-house.org
twitter: @ldywicki
code: https://github.com/Code-House/eclipsecon (under ASL 2.0)

More Related Content

What's hot (20)

PDF
Architektura html, css i javascript - Jan Kraus
Women in Technology Poland
 
PDF
Gradle by Example
Eric Wendelin
 
PDF
An Introduction to Gradle for Java Developers
Kostas Saidis
 
PDF
Hands on the Gradle
Matthias Käppler
 
ODP
Gradle - time for another build
Igor Khotin
 
PPTX
Maven
Chris Roeder
 
PDF
Introduction to Maven
Sperasoft
 
PDF
Gradle plugin, take control of the build
Eyal Lezmy
 
PDF
Efficient Django
David Arcos
 
PDF
Gradle plugins, take it to the next level
Eyal Lezmy
 
PPTX
Gradle,the new build system for android
zhang ghui
 
PPTX
The world of gradle - an introduction for developers
Tricode (part of Dept)
 
PDF
Liferay maven sdk
Mika Koivisto
 
PDF
NetBeans Support for EcmaScript 6
Kostas Saidis
 
PPTX
Android presentation - Gradle ++
Javier de Pedro López
 
PDF
Groovy in the Cloud
Daniel Woods
 
PDF
GWT Reloaded
Marcin Szałomski
 
PDF
Gradle Introduction
Dmitry Buzdin
 
PDF
EuroPython 2013 - Python3 TurboGears Training
Alessandro Molina
 
Architektura html, css i javascript - Jan Kraus
Women in Technology Poland
 
Gradle by Example
Eric Wendelin
 
An Introduction to Gradle for Java Developers
Kostas Saidis
 
Hands on the Gradle
Matthias Käppler
 
Gradle - time for another build
Igor Khotin
 
Introduction to Maven
Sperasoft
 
Gradle plugin, take control of the build
Eyal Lezmy
 
Efficient Django
David Arcos
 
Gradle plugins, take it to the next level
Eyal Lezmy
 
Gradle,the new build system for android
zhang ghui
 
The world of gradle - an introduction for developers
Tricode (part of Dept)
 
Liferay maven sdk
Mika Koivisto
 
NetBeans Support for EcmaScript 6
Kostas Saidis
 
Android presentation - Gradle ++
Javier de Pedro López
 
Groovy in the Cloud
Daniel Woods
 
GWT Reloaded
Marcin Szałomski
 
Gradle Introduction
Dmitry Buzdin
 
EuroPython 2013 - Python3 TurboGears Training
Alessandro Molina
 

Similar to Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Code-House) (20)

PDF
Intelligent Projects with Maven - DevFest Istanbul
Mert Çalışkan
 
PDF
Maven 3 Overview
Mike Ensor
 
PDF
Enterprise OSGi at eBay
Tony Ng
 
PDF
A-Z_Maven.pdf
Mithilesh Singh
 
PPTX
Introduction to maven
Manos Georgopoulos
 
PDF
Eclipse_Building_Blocks
Rahul Shukla
 
PDF
Maven
Jyothi Malapati
 
PDF
Maven
Jyothi Malapati
 
PPT
Maven 2.0 - Improve your build patterns
elliando dias
 
PDF
BMO - Intelligent Projects with Maven
Mert Çalışkan
 
PPTX
An Introduction to Maven
Vadym Lotar
 
PPTX
Ci jenkins maven svn
Ankur Goyal
 
PDF
Apache Maven - eXo TN presentation
Arnaud Héritier
 
PPTX
Maven
Emprovise
 
PDF
Lorraine JUG (1st June, 2010) - Maven
Arnaud Héritier
 
PPTX
20091112 - Mars Jug - Apache Maven
Arnaud Héritier
 
PPT
Introduction tomaven
Manav Prasad
 
PPTX
Introduction to Maven for beginners and DevOps
SISTechnologies
 
PPT
Maven 2 features
Angel Ruiz
 
Intelligent Projects with Maven - DevFest Istanbul
Mert Çalışkan
 
Maven 3 Overview
Mike Ensor
 
Enterprise OSGi at eBay
Tony Ng
 
A-Z_Maven.pdf
Mithilesh Singh
 
Introduction to maven
Manos Georgopoulos
 
Eclipse_Building_Blocks
Rahul Shukla
 
Maven 2.0 - Improve your build patterns
elliando dias
 
BMO - Intelligent Projects with Maven
Mert Çalışkan
 
An Introduction to Maven
Vadym Lotar
 
Ci jenkins maven svn
Ankur Goyal
 
Apache Maven - eXo TN presentation
Arnaud Héritier
 
Maven
Emprovise
 
Lorraine JUG (1st June, 2010) - Maven
Arnaud Héritier
 
20091112 - Mars Jug - Apache Maven
Arnaud Héritier
 
Introduction tomaven
Manav Prasad
 
Introduction to Maven for beginners and DevOps
SISTechnologies
 
Maven 2 features
Angel Ruiz
 
Ad

More from mfrancis (20)

PDF
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
mfrancis
 
PDF
OSGi and Java 9+ - BJ Hargrave (IBM)
mfrancis
 
PDF
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
mfrancis
 
PDF
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
mfrancis
 
PDF
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
mfrancis
 
PDF
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
mfrancis
 
PDF
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
mfrancis
 
PDF
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
mfrancis
 
PDF
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
mfrancis
 
PDF
OSGi CDI Integration Specification - Ray Augé (Liferay)
mfrancis
 
PDF
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
mfrancis
 
PDF
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
mfrancis
 
PDF
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
mfrancis
 
PDF
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
mfrancis
 
PDF
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
mfrancis
 
PDF
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
mfrancis
 
PDF
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
mfrancis
 
PDF
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
mfrancis
 
PDF
How to connect your OSGi application - Dirk Fauth (Bosch)
mfrancis
 
PDF
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
mfrancis
 
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
mfrancis
 
OSGi and Java 9+ - BJ Hargrave (IBM)
mfrancis
 
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
mfrancis
 
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
mfrancis
 
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
mfrancis
 
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
mfrancis
 
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
mfrancis
 
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
mfrancis
 
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
mfrancis
 
OSGi CDI Integration Specification - Ray Augé (Liferay)
mfrancis
 
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
mfrancis
 
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
mfrancis
 
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
mfrancis
 
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
mfrancis
 
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
mfrancis
 
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
mfrancis
 
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
mfrancis
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
mfrancis
 
How to connect your OSGi application - Dirk Fauth (Bosch)
mfrancis
 
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
mfrancis
 
Ad

Recently uploaded (20)

PDF
July Patch Tuesday
Ivanti
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
July Patch Tuesday
Ivanti
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Python basic programing language for automation
DanialHabibi2
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 

Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Code-House)