4
votes

I am developing an eclipse plugin using tycho build ,It needs some non-osgi jar files as dependency.when I add the dependency in my pom file ,It does not take the dependency during maven build. So, I have tried to make a osgi bundle which contains all the required dependencies by using the following Plugin.

<plugin>
    <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>1.4.0</version>
            <extensions>true</extensions>
            <configuration>
                <manifestLocation>META-INF</manifestLocation>
                <instructions>
                    <Bundle-SymbolicName>Osgi-bundle</Bundle-SymbolicName>
                    <Bundle-Name>Osgi-dependency</Bundle-Name>
                    <Bundle-Version>1.0.0</Bundle-Version>
                    <Export-Package>*</Export-Package>
                    <Private-Package>com.foo.bundle</Private-Package>
                    <Bundle-Activator>com.foo.bundle.Activator</Bundle-Activator>
                    <Import-Package>*;resolution:=optional</Import-Package>

                    <Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
                    <Embed-Directory>target/dependency</Embed-Directory>
                    <Embed-StripGroup>true</Embed-StripGroup>
                    <Embed-Transitive>true</Embed-Transitive>
                </instructions>
            </configuration>
        </plugin>

After that i have provided the dependency of this osgi bundle to the eclipse plugin .But still it does not take the dependency. I have gone through lot of sites.But I am not able to get the solution for this maven build in continuous integration But,When I tried creating new plugin project with existing jar and add the osgi bundle and export the plugin .Its work fine. But I am in need to maven continuous builds. Please provide some solution to add the dependency to eclipse plugin project.

2
Are you building the OSGi wrapper in a separate build? See this wiki page for more information.oberlies
yea i have tried the way.But it doesnot work. Now i have used p2-maven-plugin to generate the repository and i have set the repository as target definition and added the required bundles... but now eclipse maven building is working but plugin is not workingObuli Sundar

2 Answers

5
votes

I have solved the problem by creating p2 repository and deployed it in the server.I have created a target definition file and linked it to my plugin project.

We can convert non osgi jars to p2 repository by using the following code.

     <build>
        <plugins>
         <plugin>
         <groupId>org.reficio</groupId>
    <artifactId>p2-maven-plugin</artifactId>
    <version>1.1.2-SNAPSHOT</version>
    <executions>
      <execution>
        <id>default-cli</id>
        <configuration>
          <artifacts>
            <!-- specify your depencies here -->
            <!-- groupId:artifactId:version -->
            <artifact>
              <id>org.slf4j:slf4j-log4j12:1.7.10</id>
            </artifact>
          </artifacts>
        </configuration>
      </execution>
    </executions>
  </plugin>
</plugins>

'

For detailed information this site is very helpfull. http://www.vogella.com/tutorials/EclipseTycho/article.html#convertjars

2
votes

One possible option is to download jars into separate folder using maven-dependency-plugin, configure classpath in manifest for OSGi bundle and do not forget to include jars in build.