use of org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle in project sling by apache.
the class BundleListUtils method interpolateProperties.
public static void interpolateProperties(BundleList bundleList, MavenProject project, MavenSession mavenSession) throws MojoExecutionException {
Interpolator interpolator = createInterpolator(project, mavenSession);
for (final StartLevel sl : bundleList.getStartLevels()) {
for (final Bundle bndl : sl.getBundles()) {
try {
bndl.setArtifactId(interpolator.interpolate(bndl.getArtifactId()));
bndl.setGroupId(interpolator.interpolate(bndl.getGroupId()));
bndl.setVersion(interpolator.interpolate(bndl.getVersion()));
bndl.setClassifier(interpolator.interpolate(bndl.getClassifier()));
bndl.setType(interpolator.interpolate(bndl.getType()));
} catch (InterpolationException e) {
throw new MojoExecutionException("Unable to interpolate properties for bundle " + bndl.toString(), e);
}
}
}
}
use of org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle in project sling by apache.
the class BaseBundleList method add.
/**
* Merge bundle into a start level using the supplied level if present.
* @param mergeStartLevel
* @param newBnd
*/
private void add(StartLevel mergeStartLevel, Bundle newBnd) {
Bundle current = get(newBnd, false);
if (current != null) {
final Maven2OsgiConverter converter = new DefaultMaven2OsgiConverter();
// compare versions, the highest will be used
final Version newVersion = new Version(converter.getVersion(newBnd.getVersion()));
final Version oldVersion = new Version(converter.getVersion(current.getVersion()));
if (newVersion.compareTo(oldVersion) > 0) {
current.setVersion(newBnd.getVersion());
}
} else {
StartLevel startLevel = null;
if (mergeStartLevel == null || newBnd.getStartLevel() != 0) {
startLevel = getOrCreateStartLevel(newBnd.getStartLevel());
} else {
startLevel = getOrCreateStartLevel(mergeStartLevel.getStartLevel());
}
startLevel.getBundles().add(newBnd);
}
}
use of org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle in project sling by apache.
the class CreatePaxRunnerBundleProvisionFileMojo method executeWithArtifacts.
@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) {
}
}
}
}
Aggregations