Package: MavenBundlorExecutor

MavenBundlorExecutor

nameinstructionbranchcomplexitylinemethod
MavenBundlorExecutor(Configuration, ConfigurationValidator, ClassPathFactory, ManifestWriterFactory, ManifestTemplateFactory, PropertiesSourceFactory, OsgiProfileFactory)
M: 0 C: 66
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 12
100%
M: 0 C: 1
100%
createContributors(List)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
execute()
M: 0 C: 26
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2008, 2010 VMware Inc.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * VMware Inc. - initial contribution
10: *******************************************************************************/
11:
12: package org.eclipse.virgo.bundlor.maven.plugin.internal;
13:
14: import java.util.List;
15:
16: import org.apache.maven.plugin.MojoExecutionException;
17:
18: import org.eclipse.virgo.bundlor.ClassPath;
19: import org.eclipse.virgo.bundlor.ManifestGenerator;
20: import org.eclipse.virgo.bundlor.ManifestWriter;
21: import org.eclipse.virgo.bundlor.blint.ManifestValidator;
22: import org.eclipse.virgo.bundlor.blint.support.DefaultManifestValidatorContributorsFactory;
23: import org.eclipse.virgo.bundlor.blint.support.StandardManifestValidator;
24: import org.eclipse.virgo.bundlor.maven.plugin.BundlorExecutor;
25: import org.eclipse.virgo.bundlor.support.DefaultManifestGeneratorContributorsFactory;
26: import org.eclipse.virgo.bundlor.support.ManifestGeneratorContributors;
27: import org.eclipse.virgo.bundlor.support.StandardManifestGenerator;
28: import org.eclipse.virgo.bundlor.support.classpath.ClassPathFactory;
29: import org.eclipse.virgo.bundlor.support.manifestwriter.ManifestWriterFactory;
30: import org.eclipse.virgo.bundlor.support.properties.PropertiesSource;
31: import org.eclipse.virgo.util.parser.manifest.ManifestContents;
32:
33: public final class MavenBundlorExecutor implements BundlorExecutor {
34:
35: private final ClassPath inputClassPath;
36:
37: private final ManifestWriter manifestWriter;
38:
39: private final ManifestContents manifestTemplate;
40:
41: private final ManifestGenerator manifestGenerator;
42:
43: private final ManifestValidator manifestValidator;
44:
45: public MavenBundlorExecutor(Configuration configuration, ConfigurationValidator configurationValidator, ClassPathFactory classPathFactory,
46: ManifestWriterFactory manifestWriterFactory, ManifestTemplateFactory manifestTemplateFactory,
47: PropertiesSourceFactory propertiesSourceFactory, OsgiProfileFactory osgiProfileFactory) throws MojoExecutionException {
48:
49: configurationValidator.validate(configuration);
50:
51: this.inputClassPath = classPathFactory.create(configuration.getInputPath());
52: this.manifestWriter = manifestWriterFactory.create(configuration.getInputPath(), configuration.getOutputPath());
53: this.manifestTemplate = manifestTemplateFactory.create(configuration.getManifestTemplatePath(), configuration.getManifestTemplate(),
54: configuration.getBundleSymbolicName(), configuration.getDefaultBundleSymbolicName(), configuration.getBundleVersion(),
55: configuration.getDefaultBundleVersion());
56:
57: List<PropertiesSource> properties = propertiesSourceFactory.create(configuration.getPropertiesPath(), configuration.getProperties());
58: properties.add(osgiProfileFactory.create(configuration.getOsgiProfilePath(), configuration.getOsgiProfile()));
59: this.manifestGenerator = new StandardManifestGenerator(createContributors(properties));
60:
61: this.manifestValidator = new StandardManifestValidator(DefaultManifestValidatorContributorsFactory.create());
62: }
63:
64: /**
65: * {@inheritDoc}
66: */
67: public List<String> execute() {
68: ManifestContents manifest = this.manifestGenerator.generate(this.manifestTemplate, this.inputClassPath);
69:
70: try {
71: this.manifestWriter.write(manifest);
72: } finally {
73: this.manifestWriter.close();
74: }
75:
76: return this.manifestValidator.validate(manifest);
77: }
78:
79: private ManifestGeneratorContributors createContributors(List<PropertiesSource> properties) {
80: return DefaultManifestGeneratorContributorsFactory.create(properties.toArray(new PropertiesSource[properties.size()]));
81: }
82: }