1

I am creating osgi bundle by using maven bundle plugin in eclipse.In my application I have non maven jar file on which most of the java classes are depend in my application. my pom.xml file is as follow.

<build>
    ...

    <plugins>
        ....

        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.2.0</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-Activator>org.myapp.Activator</Bundle-Activator>
                    <Include-Resource>a1.jar=${basedir}/src/main/java/lib/a1.jar,a2.jar=${basedir}/src/main/java/lib/a2.jar,a3.jar=${basedir}/src/main/java/lib/a3.jar</Include-Resource>
                    <Bundle-ClassPath>.,${basedir}/src/main/java/lib/a1.jar,${basedir}/src/main/java/lib/a2.jar,${basedir}/src/main/java/lib/a3.jar</Bundle-ClassPath>

                </instructions>
            </configuration>
        </plugin>
        <!-- Maven Compiler plugin -->
        <plugin>
            <inherited>true</inherited>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.1</version>
            <configuration>
                <includes>
                    <include>${project.basedir}/src/main/java/**</include>
                </includes>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

        ....

    </plugins>
</build>

By using this I can build my application successfully and my final jar bundle also contains all needed jar files but the problem is, there is no .class file in the final bundle and my target directory also doesnt contain any .class file.

If I remove includes tag from maven-compiler-plugin then I got class does not exist error.

So please tell me what is the problem with above code which does not create .class files in target directory and also in final bundle.

Jean-Rémy Revy
  • 5,607
  • 3
  • 39
  • 65
ppb
  • 2,299
  • 4
  • 43
  • 75
  • You should try to start from a very simple pom that works, and then extend it, testing it after every step. That way, you will eventually find the problem. – Björn Pollex Sep 27 '12 at 06:42
  • 1
    OK. I have create sample osgi-archetype project in eclipse with only Activator class and its build successfully but next when **I add import com.abc.pqr** and this package is in the another custom non-maven jar file then I got **package does not exist** error. After that I install my custom jar file by using mvn install:install-file and add dependency also in pom.xml and again build the application but still I got the same error **package does not exist**. So what is the problem. – ppb Sep 27 '12 at 11:49
  • At what point do you get the error? Can you post the exact error-message you are getting? Are you sure that the jar you reference actually does contain the package? Please do not post this information in a comment, but rather edit it into your question. – Björn Pollex Sep 28 '12 at 07:28

1 Answers1

0

Your explanation is not very clear, you say it

contains all needed jar files

However, then you say

there is no .class file in the final bundle

So it doesn't contain all needed jar files. Having said that, you seem to be missing the key export-package and private-package BND directives. Check the documentation of the maven bundle plugin here

Hilikus
  • 9,954
  • 14
  • 65
  • 118