use of org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.StartLevel in project sling by apache.
the class BundleListContentProviderTest method testParsedBundlesCount.
@Test
public void testParsedBundlesCount() {
int counter = 0;
for (StartLevel level : bundleList.getStartLevels()) {
counter += level.getBundles().size();
}
assertEquals(BUNDLES_IN_TEST_BUNDLE_LIST, counter);
}
use of org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.StartLevel 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) {
}
}
}
}
use of org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.StartLevel in project sling by apache.
the class ArtifactDefinition method toBundleList.
public List<Bundle> toBundleList() {
ArrayList<Bundle> bundleList = new ArrayList<Bundle>();
if (bundles == null) {
Bundle bnd = new Bundle();
bnd.setArtifactId(artifactId);
bnd.setGroupId(groupId);
bnd.setVersion(version);
if (type != null) {
bnd.setType(type);
}
bnd.setClassifier(classifier);
bnd.setStartLevel(startLevel);
bundleList.add(bnd);
} else {
for (ArtifactDefinition bundle : bundles) {
bundleList.addAll(bundle.toBundleList());
}
}
return bundleList;
}
use of org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.StartLevel in project sling by apache.
the class CheckBundleListForSnapshotsMojo method executeWithArtifacts.
@Override
protected void executeWithArtifacts() throws MojoExecutionException, MojoFailureException {
List<Bundle> snapshots = new ArrayList<Bundle>();
BundleList bundleList = getInitializedBundleList();
for (StartLevel level : bundleList.getStartLevels()) {
for (Bundle bundle : level.getBundles()) {
if (isSnapshot(bundle)) {
snapshots.add(bundle);
}
}
}
if (!snapshots.isEmpty()) {
getLog().error("The following entries in the bundle list file are SNAPSHOTs:");
for (Bundle bundle : snapshots) {
getLog().error(String.format(" %s:%s:%s", bundle.getGroupId(), bundle.getArtifactId(), bundle.getVersion()));
}
if (failOnSnapshot) {
throw new MojoFailureException("SNAPSHOTs were found in the bundle list. See log.");
}
}
}
use of org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.StartLevel in project sling by apache.
the class CreateKarafFeatureDescriptorMojo method executeWithArtifacts.
@Override
protected void executeWithArtifacts() throws MojoExecutionException, MojoFailureException {
Document doc = new Document();
Element features = new Element("features");
doc.setRootElement(features);
features.setAttribute("name", featuresName);
Element feature = new Element("feature");
features.addContent(feature);
feature.setAttribute("name", featureName);
feature.setAttribute("version", featureVersion);
BundleList bundleList = getInitializedBundleList();
for (StartLevel level : bundleList.getStartLevels()) {
for (Bundle bundle : level.getBundles()) {
String bundleRef = String.format("mvn:%s/%s/%s", bundle.getGroupId(), bundle.getArtifactId(), bundle.getVersion());
feature.addContent(new Element("bundle").setText(bundleRef));
}
}
FileOutputStream out = null;
try {
out = new FileOutputStream(outputFile);
new XMLOutputter(Format.getPrettyFormat().setEncoding("UTF-8")).output(doc, out);
projectHelper.attachArtifact(project, TYPE, CLASSIFIER, outputFile);
} catch (IOException e) {
throw new MojoExecutionException("Unable to write features.xml", e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
}
}
}
}
Aggregations