Amrit
Amrit

Reputation: 2333

Export OSGi bundles to a specific folder using maven

Can anyone plz guide me how can I copy the generated OSGi bundle to a different location on the disk?

I am using maven for building the OSGi bundle.


Complete Solution: Update on 9th Jan, 2014: I got a better approach and updated the pom.xml with following plugin:

      <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.8</version>
    <executions>
      <execution>
        <id>copy-installed</id>
        <phase>install</phase>
        <goals>
          <goal>copy</goal>
        </goals>
        <configuration>
          <artifactItems>
            <artifactItem>
              <groupId>${project.groupId}</groupId>
              <artifactId>${project.artifactId}</artifactId>
              <version>${project.version}</version>
              <type>${project.packaging}</type>
            </artifactItem>
          </artifactItems>
          <outputDirectory>some-other-place</outputDirectory>
        </configuration>
      </execution>
    </executions>
  </plugin>

This was able to copy once the bundle generation was done an I could give the destination folder too.

Upvotes: 0

Views: 132

Answers (2)

ptyx
ptyx

Reputation: 4164

When do you want to copy your bundle?

Assuming you have a project generating the bundle, then it should be available in your target folder, and will also be installed (running mvn install) in your local repository (~/.m2/repository/...).

You could just use a cp command to copy it wherever you want.

Deploying it to a test folder as part of the build is not necessarily a great idea: you're making your build dependent on machine specific settings or magic injected properties. That said, if you wanted to do that anyway, I'll use the following approach:

  1. have a separate maven project which depends on the bundle and just deploys it wherever you like
  2. define a property specifying the target directory (you can pass it on the command line, define it in your settings.xml or provide a default value for in your pom.xml)
  3. use the maven-dependency-plugin:copy-dependency goal in your deployment project to copy your bundle

Upvotes: 2

evandor
evandor

Reputation: 789

Guess this question is not really related to OSGi, more to maven... maybe you could have a look at the maven resources plugin, specifically http://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html which helps you copying arbitrary resources.

Upvotes: 0

Related Questions