private void addBundleListDependencies() throws IOException, XmlPullParserException, MojoExecutionException { BundleList bundleList; if (bundleListFile.exists()) { bundleList = readBundleList(bundleListFile); } else { bundleList = new BundleList(); } if (additionalBundles != null) { for (ArtifactDefinition def : additionalBundles) { bundleList.add(def.toBundleList()); } } interpolateProperties(bundleList, project, session); for (StartLevel startLevel : bundleList.getStartLevels()) { for (Bundle bundle : startLevel.getBundles()) { log.debug( String.format( "adding bundle (%s) from bundle list to dependencies of project %s", bundle, project)); project.getDependencies().addAll(ArtifactDefinition.toDependencyList(bundle, PROVIDED)); } } }
@Override protected void executeWithArtifacts() throws MojoExecutionException, MojoFailureException { FileWriter out = null; try { out = new FileWriter(outputFile); BundleList bundleList = getInitializedBundleList(); for (StartLevel level : bundleList.getStartLevels()) { for (Bundle bundle : level.getBundles()) { String line = String.format( "mvn:%s/%s/%s@%d\n", bundle.getGroupId(), bundle.getArtifactId(), bundle.getVersion(), level.getStartLevel()); out.write(line); } } projectHelper.attachArtifact(project, TYPE, CLASSIFIER, outputFile); } catch (IOException e) { throw new MojoExecutionException("Unable to write " + outputFile.getName(), e); } finally { if (out != null) { try { out.close(); } catch (IOException e) { } } } }