Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add jar Non-osgi jar files as dependency to eclipse plugin?

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.

like image 599
Obuli Sundar Avatar asked Mar 15 '23 10:03

Obuli Sundar


1 Answers

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

like image 105
Obuli Sundar Avatar answered Apr 29 '23 11:04

Obuli Sundar