]> git.argeo.org Git - gpl/argeo-slc.git/blob - InstallBundlesMojo.java
d46ff5d40c6016fb6116ba200f156103b779be1b
[gpl/argeo-slc.git] / InstallBundlesMojo.java
1 package org.argeo.slc.maven.plugins.osgi;
2
3 import java.io.File;
4 import java.util.List;
5
6 import org.apache.maven.artifact.installer.ArtifactInstallationException;
7 import org.apache.maven.artifact.installer.ArtifactInstaller;
8 import org.apache.maven.plugin.MojoExecutionException;
9 import org.apache.maven.plugin.MojoFailureException;
10
11 /**
12 * @goal install-bundles
13 * @phase install
14 * @author mbaudier
15 *
16 */
17 public class InstallBundlesMojo extends AbstractBundlesPackagerMojo {
18 /** @component */
19 private ArtifactInstaller installer;
20
21 public void execute() throws MojoExecutionException, MojoFailureException {
22 List bundlePackages = analyze();
23 for (int i = 0; i < bundlePackages.size(); i++) {
24 AbstractBundlesPackagerMojo.BundlePackage bundlePackage = (BundlePackage) bundlePackages
25 .get(i);
26 try {
27 installer.install(bundlePackage.getPackageFile(), bundlePackage
28 .getArtifact(), local);
29 } catch (ArtifactInstallationException e) {
30 throw new MojoExecutionException("Could not install bundle "
31 + bundlePackage.getBundleDir(), e);
32 }
33 }
34
35 // Bundles pom
36 try {
37 installer.install(bundlesPomFile(), bundlesPomArtifact(), local);
38 installer.install(new File(baseDir.getPath() + File.separator
39 + "pom.xml"), project.getArtifact(), local);
40 } catch (ArtifactInstallationException e) {
41 throw new MojoExecutionException("Could not install bundles POM", e);
42 }
43
44 }
45 }