You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by John Wells <jw...@bea.com> on 2005/12/29 15:53:36 UTC

Help with custom osgi packaging (Maven 2.0)

I am new to Maven, so this might be a simple answer.  I couldn't seem to
find the right way to do this.  Here is what I want:

 

I am trying to create OSGi bundles with maven.  OSGi bundles are just
like regular jar files (with an extension of ".jar") except that in
order for them to be tested, they need to run in an OSGi framework.
Even so, OSGi bundles can implement junit "TestCase" and hence look like
normal junit tests to the default Maven surefile tester.  But I don't
want this, these tests will always fail because they attempt to run the
jars outside the OSGi framework.

 

So, I wanted to come up with my own testing framework (using an junit
OSGi bundle and another OSGi junit utility called junit_runner which
runs your tests as OSGi bundles).

 

I figured that the best way to do this was to define a packaging type
called osgi-bundle.  In order to do this, I created a "plugin" that has
a plexus descriptor like the following (and no other code at all - only
the components.xml file):

 

<component-set>

  <components>

    <component>

      <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>

      <role-hint>osgi-bundle</role-hint>

 
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMappi
ng</implementation>

      <configuration>

        <phases>

 
<process-resources>org.apache.maven.plugins:maven-resources-plugin:resou
rces</process-resources>

 
<compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile
>

 
<process-test-resources>org.apache.maven.plugins:maven-resources-plugin:
testResources</process-test-resources>

 
<test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile
</test-compile>

          <!--
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test> -->

 
<package>org.apache.maven.plugins:maven-jar-plugin:jar</package>

 
<install>org.apache.maven.plugins:maven-install-plugin:install</install>

 
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>

        </phases>

      </configuration>

    </component>

    <component>

      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>

      <role-hint>osgi-bundle</role-hint>

 
<implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler
</implementation>

      <configuration>

        <extension>jar</extension>

        <type>osgi-bundle</type>

        <packaging>jar</packaging>

        <language>java</language>

        <addedToClasspath>false</addedToClasspath>

      </configuration>

    </component>

  </components>

</component-set>

 

Note that the first part seemed to work fine (the test phase is
commented out).  Eventually, I plan to replace the "test" phase with my
own plugin to run an OSGi framework suite.  But I am new to Maven so I
am just trying to get going with the basics first.

 

My problem is that the artifact that gets put into the repository at
"install" time looks like this:

 

Osgi-1.0-SNAPSHOT.osgi-bundle

 

Rather than:

 

Osgi-1.0-SNAPSHOT.jar

 

I thought that the second component of my plugin would make
"osgi-bundle" map to ".jar".

 

I must admit that I am little confused as to what is meant by "type".
Sometimes in the documentation "type" means "packaging" while at other
times there seem to be specific artifact "types"  (Like jar, war,
test-jar).  I tried changing the role-hint and the type fields in the
second component to "jar" but that didn't seem to help.

 

The strange thing is that in my target directory the file created does
have the ".jar" extension.  But when I run "install" it copies the file
from the ".jar" name to the ".osgi-bundle" name.

 

I think there is something simple I am missing here, but I am stuck.
Can someone please help me?

 

John Wells (Aziz)

jwells@bea.comNOSPAM

 


Re: Help with custom osgi packaging (Maven 2.0)

Posted by Brett Porter <br...@gmail.com>.
I'd suggest looking at:
http://svn.apache.org/viewcvs.cgi/incubator/felix/trunk/tools/maven2/maven-osgi-plugin/

I think they've already done what you want to do.

Cheers,
Brett

On 12/30/05, John Wells <jw...@bea.com> wrote:
> I am new to Maven, so this might be a simple answer.  I couldn't seem to
> find the right way to do this.  Here is what I want:
>
>
>
> I am trying to create OSGi bundles with maven.  OSGi bundles are just
> like regular jar files (with an extension of ".jar") except that in
> order for them to be tested, they need to run in an OSGi framework.
> Even so, OSGi bundles can implement junit "TestCase" and hence look like
> normal junit tests to the default Maven surefile tester.  But I don't
> want this, these tests will always fail because they attempt to run the
> jars outside the OSGi framework.
>
>
>
> So, I wanted to come up with my own testing framework (using an junit
> OSGi bundle and another OSGi junit utility called junit_runner which
> runs your tests as OSGi bundles).
>
>
>
> I figured that the best way to do this was to define a packaging type
> called osgi-bundle.  In order to do this, I created a "plugin" that has
> a plexus descriptor like the following (and no other code at all - only
> the components.xml file):
>
>
>
> <component-set>
>
>   <components>
>
>     <component>
>
>       <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
>
>       <role-hint>osgi-bundle</role-hint>
>
>
> <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMappi
> ng</implementation>
>
>       <configuration>
>
>         <phases>
>
>
> <process-resources>org.apache.maven.plugins:maven-resources-plugin:resou
> rces</process-resources>
>
>
> <compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile
> >
>
>
> <process-test-resources>org.apache.maven.plugins:maven-resources-plugin:
> testResources</process-test-resources>
>
>
> <test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile
> </test-compile>
>
>           <!--
> <test>org.apache.maven.plugins:maven-surefire-plugin:test</test> -->
>
>
> <package>org.apache.maven.plugins:maven-jar-plugin:jar</package>
>
>
> <install>org.apache.maven.plugins:maven-install-plugin:install</install>
>
>
> <deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
>
>         </phases>
>
>       </configuration>
>
>     </component>
>
>     <component>
>
>       <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
>
>       <role-hint>osgi-bundle</role-hint>
>
>
> <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler
> </implementation>
>
>       <configuration>
>
>         <extension>jar</extension>
>
>         <type>osgi-bundle</type>
>
>         <packaging>jar</packaging>
>
>         <language>java</language>
>
>         <addedToClasspath>false</addedToClasspath>
>
>       </configuration>
>
>     </component>
>
>   </components>
>
> </component-set>
>
>
>
> Note that the first part seemed to work fine (the test phase is
> commented out).  Eventually, I plan to replace the "test" phase with my
> own plugin to run an OSGi framework suite.  But I am new to Maven so I
> am just trying to get going with the basics first.
>
>
>
> My problem is that the artifact that gets put into the repository at
> "install" time looks like this:
>
>
>
> Osgi-1.0-SNAPSHOT.osgi-bundle
>
>
>
> Rather than:
>
>
>
> Osgi-1.0-SNAPSHOT.jar
>
>
>
> I thought that the second component of my plugin would make
> "osgi-bundle" map to ".jar".
>
>
>
> I must admit that I am little confused as to what is meant by "type".
> Sometimes in the documentation "type" means "packaging" while at other
> times there seem to be specific artifact "types"  (Like jar, war,
> test-jar).  I tried changing the role-hint and the type fields in the
> second component to "jar" but that didn't seem to help.
>
>
>
> The strange thing is that in my target directory the file created does
> have the ".jar" extension.  But when I run "install" it copies the file
> from the ".jar" name to the ".osgi-bundle" name.
>
>
>
> I think there is something simple I am missing here, but I am stuck.
> Can someone please help me?
>
>
>
> John Wells (Aziz)
>
> jwells@bea.comNOSPAM
>
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org