title: Add my own bundle sources to pax-exam when building with pax-maven-plugin
body: <p>I'm trying to build my OSGI bundle with <a href="http://www.ops4j.org/projects/pax/construct/maven-pax-plugin/" rel="nofollow noreferrer">pax-maven-build</a> and in the same time test it with <a href="http://team.ops4j.org/wiki/display/paxexam/Pax+Exam" rel="nofollow noreferrer">pax-exam</a>. It have some bundle in provision than I can test with the following pax-exam test configuration:</p>
  <pre><code>@RunWith(JUnit4TestRunner.class)
  @ExamReactorStrategy(AllConfinedStagedReactorFactory.class)
  public class OSGILoaderTest {
  
      @Inject
      protected BundleContext bundleContext;
  
      @Configuration
      public Option[] config() throws MalformedURLException {
  
  
          String projectRoot = // a path to my project
  
          return options(
                  junitBundles(),
                  equinox(),
                  bundle(projectRoot + &quot;libs/org.eclipse.core.variables_3.2.500.v20110511.jar&quot;),
                  bundle(projectRoot + &quot;libs/org.eclipse.core.contenttype_3.4.100.v20110423-0524.jar&quot;),
                  bundle(projectRoot + &quot;libs/org.eclipse.core.expressions_3.4.300.v20110228.jar&quot;),
                  // etc...
          );
      }
  
      @Test
      public void getBundleContext() throws RodinDBException {
          IRodinDB rodinDB = RodinCore.getRodinDB();
          assertNotNull(rodinDB);
      }
  }
  </code></pre>
  <p>Here, I can see I can access to the IRodinDB instance from a jar I have provisonned.</p>
  <p>Now I have code my own bundle, which is going to use all the jar provisionned. But I cannot even test my own code, for instance:</p>
  <pre><code>@Test
  public void checkAccessToRodinDbTest() {
      VTGService service = null;
      assertTrue(true);
  }
  </code></pre>
  <p>give an error <strong>at compilation time</strong>:</p>
  <blockquote>
  <p>[ERROR] Failed to execute goal org.ops4j:maven-pax-plugin:1.5:testCompile (default-testCompile) : Compilation failure</p>
  <p>[ERROR] cannot find symbol</p>
  <p>[ERROR] symbol  : class VTGService</p>
  </blockquote>
  <p>It seems test compilation cannot see 'src/main/java', contrarly as expected by the default behavior of maven-compiler-plugin. But in my case, you can see than maven does not use the compiler plugin but instead maven-pax-plugin.</p>
  <p>The question is: how can i test my own bundle with pax-exam ?</p>
  <p><strong>update1</strong></p>
  <p>It seems that this is a problem with recent version of maven-pax-plugin, as <a href="http://www.ops4j.org/projects/pax/construct/maven-pax-plugin/usage.html" rel="nofollow noreferrer">the basic example available in ops4j pax maven plugin</a> (in section <em>Using the Pax Plugin inside a POM</em>) seems to suffer of the same problem.</p>
  <p><strong>update2</strong></p>
  <p>As requested by Dmytro, this is the pom.xml of my bundle:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;project xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
           xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
  
      &lt;parent&gt;
          &lt;relativePath&gt;../poms/compiled/&lt;/relativePath&gt;
          &lt;groupId&gt;fr.xlim.ssd.vtg.build&lt;/groupId&gt;
          &lt;artifactId&gt;compiled-bundle-settings&lt;/artifactId&gt;
          &lt;version&gt;0.1-SNAPSHOT&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;bundle.symbolicName&gt;fr.xlim.ssd.vtg.bundle&lt;/bundle.symbolicName&gt;
          &lt;bundle.namespace&gt;fr.xlim.ssd.vtg.bundle&lt;/bundle.namespace&gt;
      &lt;/properties&gt;
  
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;fr.xlim.ssd.vtg&lt;/groupId&gt;
      &lt;artifactId&gt;fr.xlim.ssd.vtg.bundle&lt;/artifactId&gt;
      &lt;version&gt;0.1-SNAPSHOT&lt;/version&gt;
  
      &lt;name&gt;${bundle.symbolicName}&lt;/name&gt;
  
      &lt;packaging&gt;bundle&lt;/packaging&gt;
  
      &lt;dependencies&gt;
  
          &lt;dependency&gt;
              &lt;type&gt;pom&lt;/type&gt;
              &lt;groupId&gt;${project.parent.groupId}&lt;/groupId&gt;
              &lt;artifactId&gt;provision&lt;/artifactId&gt;
              &lt;optional&gt;true&lt;/optional&gt;
          &lt;/dependency&gt;
  
          &lt;!-- not needed as equinox bundle are available in provision --&gt; 
          &lt;dependency&gt;
              &lt;groupId&gt;org.osgi&lt;/groupId&gt;
              &lt;artifactId&gt;osgi_R4_core&lt;/artifactId&gt;
              &lt;optional&gt;true&lt;/optional&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.osgi&lt;/groupId&gt;
              &lt;artifactId&gt;osgi_R4_compendium&lt;/artifactId&gt;
              &lt;optional&gt;true&lt;/optional&gt;
          &lt;/dependency--&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.9&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.ops4j.pax.exam&lt;/groupId&gt;
              &lt;artifactId&gt;pax-exam&lt;/artifactId&gt;
              &lt;version&gt;2.3.0&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.ops4j.pax.exam&lt;/groupId&gt;
              &lt;artifactId&gt;pax-exam-junit4&lt;/artifactId&gt;
              &lt;version&gt;2.3.0&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.ops4j.pax.exam&lt;/groupId&gt;
              &lt;artifactId&gt;pax-exam-inject&lt;/artifactId&gt;
              &lt;version&gt;2.3.0&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.ops4j.pax.url&lt;/groupId&gt;
              &lt;artifactId&gt;pax-url-mvn&lt;/artifactId&gt;
              &lt;version&gt;1.3.5&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.ops4j.pax.exam&lt;/groupId&gt;
              &lt;artifactId&gt;pax-exam-container-native&lt;/artifactId&gt;
              &lt;version&gt;2.3.0&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.inject&lt;/groupId&gt;
              &lt;artifactId&gt;javax.inject&lt;/artifactId&gt;
              &lt;version&gt;1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.ops4j.pax.exam&lt;/groupId&gt;
              &lt;artifactId&gt;pax-exam-link-mvn&lt;/artifactId&gt;
              &lt;version&gt;2.3.0&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
              &lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
              &lt;version&gt;1.0.0&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
              &lt;artifactId&gt;logback-core&lt;/artifactId&gt;
              &lt;version&gt;1.0.0&lt;/version&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3.2&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  <hr />
  <p>I am not sure it is the most elegant solution, but I created a new maven project when I can import my own bundle like in the source code of my question.</p>
  <p>Is there an elegant way to add my own java sources directly as new bundle for test in the same Maven project ? It could be not possible (as the bundle assembly operation is done <strong>after</strong> the compilation and tests)...</p>