-1

We have a very big web application containing many features.Now for maintainability we want to split the application in components so that can remove / add particular components (jars). For that one suggestion is coming is to use OSGI. I think converting jars into bundle will take huge effort. I think same functionality can be achieved by Maven. According to my understanding OSGI is packaging tool. If I can make Maven plug-in for each component then any particular component can be included or removed at compile as opposed to run time as in case of OSGI. Modularizing the application using Maven will be simpler than OSGI. I have read similar post on this site and it commented that OSGI and Maven are like comparing apple with orange. But I think in one sense both are same as they both meant for packaging difference is one is used at run time and one for compile time

Looking forward for well though answer :)

best wishes Shailesh

Shailesh
  • 405
  • 1
  • 5
  • 18
  • 1
    OSGI and Maven are like comparing apple with orange – Thilo May 21 '15 at 12:29
  • "OSGI and Maven are like comparing apple with orange", In this case the apple (maven) is better than the orange which turned out to be a lemon. Maven is practically a competitor and a disincentive against osgi, regardless of any apple, orange allegory. Apple/orange allegory is as congruent to this question as osgi is for solving the versioning dependency problem. – Blessed Geek Oct 08 '18 at 09:28

2 Answers2

3

As you already hinted at yourself: you're comparing apple with orange.

OSGi is not a packaging tool.

OSGi bundles are plain JAR files with some OSGi-specific metadata in the Manifest file.

You can create OSGi bundles using Maven e.g. using the Maven Bundle Plugin (I can recommend this approach). So regardless if you're using OSGi or not I strongly recommend using Maven.

Here some use cases for OSGi:

  • You want to create different versions of your application e.g. for different customers. With OSGi you can just add/ remove bundles without having to touch any other configuration.
  • You need a plugin system so 3rd parties can provide plugins to your application
  • You want your application to be truely modular
  • You want to share some code with other applications but want to hide some internal classes
  • ...
Puce
  • 37,247
  • 13
  • 80
  • 152
  • I was expecting answer as in line with below answer. Dont you think below answer is right? – Shailesh May 21 '15 at 16:03
  • @Shailesh Not really. See my comment. – Puce May 21 '15 at 16:08
  • @Shailesh And as I said: I recommend to use Maven and if needed OSGi in addition. It's not an either or question. You can use both. They are complementary. – Puce May 21 '15 at 16:13
  • basic difference between OSGi and Maven I know. OSGi is platform for adding component (bundles) at runtime while Maven is build tool. Please see my question once again. But I was thinking Maven can be simpler to modularize application than oSGi. If I want to break application into independent jars then through Maven it will be simpler. Here is my use I have a a web application using Spring . Hibernate, Struts etc and it is generates a single WAR. Now I want to modularize so that some module can be excluded and resulting WAR can have less features as required. For that Maven will be good – Shailesh May 21 '15 at 17:02
  • @Shailesh Your comment is correct except the "is simpler" part is confusing. You would want to break your application into individual JARs regardless if you're using OSGi or not and as I said - use Maven in any case. What is you question? – Puce May 21 '15 at 17:44
  • My question is application development is evolution can technologies should be used step by step. So first I should use Maven for static modularization of application after that I should think of using OSGi for run-time modularization. If I have independent jar compilation unit then converting them into bundles will be simple? – Shailesh May 22 '15 at 06:45
  • @Shailesh I wouldn't say simple. It depends on how much you want to use from OSGi (Module Layer, Lifecycle Layer, Service Layer). And another concern: Spring doesn't officially support OSGi anymore: http://stackoverflow.com/questions/21181154/where-can-i-find-spring-4-osgi-bundles – Puce May 22 '15 at 07:28
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/78561/discussion-between-shailesh-and-puce). – Shailesh May 22 '15 at 17:13
-1

OSGI is much much more than a packaging tool. You could say that OSGI has a packaging tool inside. Maven is a packaging tool and a dependency manager. I'd say that, given the level of complexity and the use you say you'll make of this technology, go with Maven.

francesco foresti
  • 2,004
  • 20
  • 24
  • I agree with your answer – Shailesh May 21 '15 at 16:00
  • I don't see what you mean with "packaging tool inside". OSGi bundles are plain JAR files with some OSGi-specific metadata in the Manifest file. OSGi is not a packaging tool. It defines how a bundle must be packaged to be bundle, but it's not a packaging tool. – Puce May 21 '15 at 16:08
  • @Puce Yes you are indeed right. It is more correct to say that OSGI prescribes some rules for jar compliance, in the form of manifest metadata. But it has no way of creating packages (i.e. jars) for you, as Maven does, so it is not a tool per se. – francesco foresti May 21 '15 at 16:36
  • I agree with Puce and other including you who has commented on my question. I agree that OSGi can't create jar while Maven can. But in once aspect both are same. Like OSGi is used to package application by including different jars also Maven can be used to create a package of application including different jars. Please read my previous comment – Shailesh May 22 '15 at 04:50