use of org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList in project sling by apache.
the class DisplayBundleUpdatesMojo method readBundleList.
private BundleList readBundleList(File file) throws IOException, XmlPullParserException {
BundleListXpp3Reader reader = new BundleListXpp3Reader();
FileInputStream fis = new FileInputStream(file);
try {
return reader.read(fis);
} finally {
fis.close();
}
}
use of org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList in project sling by apache.
the class DisplayBundleUpdatesMojo method execute.
@SuppressWarnings("unchecked")
public void execute() throws MojoExecutionException, MojoFailureException {
try {
BundleList bundleList = readBundleList(bundleListFile);
Set<Dependency> bundlesAsDependencies = new HashSet<Dependency>();
for (StartLevel startLevel : bundleList.getStartLevels()) {
for (Bundle bundle : startLevel.getBundles()) {
bundlesAsDependencies.add(asDependency(bundle));
}
}
logUpdates(getHelper().lookupDependenciesUpdates(bundlesAsDependencies, false));
} catch (Exception e) {
throw new MojoExecutionException("Unable to read bundle list.", e);
}
}
use of org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList in project sling by apache.
the class AttachPartialBundleListMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
final BundleList initializedBundleList;
if (bundleListFile.exists()) {
try {
initializedBundleList = readBundleList(bundleListFile);
} catch (IOException e) {
throw new MojoExecutionException("Unable to read bundle list file", e);
} catch (XmlPullParserException e) {
throw new MojoExecutionException("Unable to read bundle list file", e);
}
} else {
throw new MojoFailureException(String.format("Bundle list file %s does not exist.", bundleListFile.getAbsolutePath()));
}
interpolateProperties(initializedBundleList, this.project, this.mavenSession);
final BundleListXpp3Writer writer = new BundleListXpp3Writer();
try {
this.bundleListOutput.getParentFile().mkdirs();
writer.write(new FileWriter(bundleListOutput), initializedBundleList);
} catch (IOException e) {
throw new MojoExecutionException("Unable to write bundle list", e);
}
// if this project is a partial bundle list, it's the main artifact
if (project.getPackaging().equals(PARTIAL)) {
project.getArtifact().setFile(bundleListOutput);
} else {
// otherwise attach it as an additional artifact
projectHelper.attachArtifact(project, TYPE, CLASSIFIER, bundleListOutput);
}
this.getLog().info("Attaching bundle list configuration");
try {
this.attachConfigurations();
} catch (final IOException ioe) {
throw new MojoExecutionException("Unable to attach configuration.", ioe);
} catch (final ArchiverException ioe) {
throw new MojoExecutionException("Unable to attach configuration.", ioe);
}
}
use of org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList in project sling by apache.
the class BundleListUtils method readBundleList.
public static BundleList readBundleList(File file) throws IOException, XmlPullParserException {
BundleListXpp3Reader reader = new BundleListXpp3Reader();
FileInputStream fis = new FileInputStream(file);
try {
return reader.read(fis);
} finally {
fis.close();
}
}
use of org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList in project sling by apache.
the class CreateBundleJarMojo method addBundles.
private void addBundles() throws MojoExecutionException {
BundleList bundles = getInitializedBundleList();
for (StartLevel level : bundles.getStartLevels()) {
for (Bundle bundle : level.getBundles()) {
Artifact artifact = getArtifact(new ArtifactDefinition(bundle, level.getStartLevel()));
final String destFileName = getPathForArtifact(level.getStartLevel(), bundle.getRunModes(), artifact.getFile().getName());
try {
jarArchiver.addFile(artifact.getFile(), destFileName);
} catch (ArchiverException e) {
throw new MojoExecutionException("Unable to add file to bundle jar file: " + artifact.getFile().getAbsolutePath(), e);
}
}
}
}
Aggregations