Package org.apache.felix.bundleplugin
Class BundlePlugin
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.felix.bundleplugin.BundlePlugin
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
AntPlugin,InstructionsPlugin,ManifestPlugin
@Mojo(name="bundle",
requiresDependencyResolution=TEST,
threadSafe=true,
defaultPhase=PACKAGE)
public class BundlePlugin
extends org.apache.maven.plugin.AbstractMojo
Create an OSGi bundle from Maven project
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.maven.artifact.factory.ArtifactFactoryprotected org.apache.maven.artifact.resolver.ArtifactResolverArtifact resolver, needed to download source jars for inclusion in classpath.protected org.sonatype.plexus.build.incremental.BuildContextprotected StringClassifier type of the bundle to be installed.protected booleanIf true, remove any inlined or embedded dependencies from the resulting pom.protected org.apache.maven.shared.dependency.graph.DependencyGraphBuilderprotected FileWhere to put the dependency reduced pom.protected FileFile where the BND class-path will be dumpedprotected FileFile where the BND instructions will be dumpedprotected StringComma separated list of artifactIds to exclude from the dependency classpath passed to BND (use "true" to exclude everything)protected booleanWhen true, dump the generated SCR filesprotected org.apache.maven.artifact.repository.ArtifactRepositoryLocal maven repository.protected FileDirectory where the manifest will be writtenprotected org.apache.maven.project.MavenProjectBuilderProjectBuilder, needed to create projects from the artifacts.protected booleanOutput a nicely formatted manifest that still respects the 72 character line limit.Project types which are not supported, but silently ignored.protected StringPackaging type of the bundle to be installed.protected org.apache.maven.project.MavenProjectThe Maven project.protected List<org.apache.maven.artifact.repository.ArtifactRepository> Remote repositories which will be searched for source attachments.protected FileDirectory where the SCR files will be writtenprotected org.apache.maven.execution.MavenSessionProject types which this plugin supports.protected booleanWhen true, unpack the bundle contents to the outputDirectoryFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddMavenInstructions(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Builder builder) protected static voidaddMavenSourcePath(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Analyzer analyzer, org.apache.maven.plugin.logging.Log log) protected aQute.bnd.osgi.BuilderbuildOSGiBundle(org.apache.maven.project.MavenProject currentProject, Map<String, String> originalInstructions, org.apache.felix.bundleplugin.BundlePlugin.ClassPathItem[] classpath) protected StringconvertVersionToOsgi(String version) Convert a Maven version into an OSGi compliant versionprotected static StringBuilderdumpClasspath(List<aQute.bnd.osgi.Jar> classpath, StringBuilder buf) protected static StringBuilderdumpInstructions(Properties properties, StringBuilder buf) protected static StringBuilderdumpManifest(Manifest manifest, StringBuilder buf) voidexecute()protected voidexecute(Map<String, String> originalInstructions, org.apache.felix.bundleplugin.BundlePlugin.ClassPathItem[] classpath) protected static FilegetBase(org.apache.maven.project.MavenProject currentProject) protected Stringprotected StringgetBundleName(org.apache.maven.project.MavenProject currentProject) TODO this should return getMaven2Osgi().getBundleFileName( project.getArtifact() )protected org.apache.felix.bundleplugin.BundlePlugin.ClassPathItem[]getClasspath(org.apache.maven.project.MavenProject currentProject) protected PropertiesgetDefaultProperties(org.apache.maven.project.MavenProject currentProject) protected Collection<org.apache.maven.artifact.Artifact> getEmbeddableArtifacts(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Analyzer analyzer) protected FilegetFile(org.apache.maven.artifact.Artifact artifact) Get the file for an Artifactprotected Maven2OsgiConverterprotected static StringgetMavenResourcePaths(org.apache.maven.project.MavenProject currentProject, boolean test) getOptionalPackages(org.apache.maven.project.MavenProject currentProject) protected aQute.bnd.osgi.BuildergetOSGiBuilder(org.apache.maven.project.MavenProject currentProject, Map<String, String> originalInstructions, org.apache.felix.bundleplugin.BundlePlugin.ClassPathItem[] classpath) protected Fileprotected org.apache.maven.project.MavenProjectprotected static voidincludeMavenResources(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Analyzer analyzer, org.apache.maven.plugin.logging.Log log) protected booleanisTransitivelyOptional(HashSet<String> optionalArtifactIds, org.apache.maven.artifact.Artifact artifact) Check to see if any dependency along the dependency trail of the artifact is optional.protected static voidmergeManifest(aQute.bnd.osgi.Instructions instructions, Manifest... manifests) protected voidmergeMavenManifest(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Builder builder) protected static StringremoveTagFromInstruction(String instruction, String tag) protected booleanreportErrors(String prefix, aQute.bnd.osgi.Analyzer analyzer) protected static Stringprotected static Propertiessanitize(Properties properties) protected voidsetBuildDirectory(String _buildirectory) protected voidsetOutputDirectory(File _outputDirectory) transformDirectives(Map<String, String> originalInstructions) booleanupdateExcludesInDeps(org.apache.maven.project.MavenProject project, List<org.apache.maven.model.Dependency> dependencies, List<org.apache.maven.model.Dependency> transitiveDeps) Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
manifestLocation
@Parameter(property="manifestLocation", defaultValue="${project.build.outputDirectory}/META-INF") protected File manifestLocationDirectory where the manifest will be written -
niceManifest
@Parameter(property="niceManifest", defaultValue="false") protected boolean niceManifestOutput a nicely formatted manifest that still respects the 72 character line limit. -
dumpInstructions
File where the BND instructions will be dumped -
dumpClasspath
File where the BND class-path will be dumped -
unpackBundle
@Parameter(property="unpackBundle") protected boolean unpackBundleWhen true, unpack the bundle contents to the outputDirectory -
excludeDependencies
Comma separated list of artifactIds to exclude from the dependency classpath passed to BND (use "true" to exclude everything) -
classifier
Classifier type of the bundle to be installed. For example, "jdk14". Defaults to none which means this is the project's main bundle. -
packaging
Packaging type of the bundle to be installed. For example, "jar". Defaults to none which means use the same packaging as the project. -
createDependencyReducedPom
@Parameter protected boolean createDependencyReducedPomIf true, remove any inlined or embedded dependencies from the resulting pom. -
dependencyReducedPomLocation
@Parameter(defaultValue="${basedir}/dependency-reduced-pom.xml") protected File dependencyReducedPomLocationWhere to put the dependency reduced pom. Note: setting a value for this parameter with a directory other than ${basedir} will change the value of ${basedir} for all executions that come after the shade execution. This is often not what you want. This is considered an open issue with this plugin. -
scrLocation
Directory where the SCR files will be written -
exportScr
@Parameter protected boolean exportScrWhen true, dump the generated SCR files -
session
@Parameter(defaultValue="${session}", readonly=true) protected org.apache.maven.execution.MavenSession session -
mavenProjectBuilder
@Component protected org.apache.maven.project.MavenProjectBuilder mavenProjectBuilderProjectBuilder, needed to create projects from the artifacts. -
dependencyGraphBuilder
@Component protected org.apache.maven.shared.dependency.graph.DependencyGraphBuilder dependencyGraphBuilder -
artifactFactory
@Component protected org.apache.maven.artifact.factory.ArtifactFactory artifactFactory -
artifactResolver
@Component protected org.apache.maven.artifact.resolver.ArtifactResolver artifactResolverArtifact resolver, needed to download source jars for inclusion in classpath. -
localRepository
@Parameter(readonly=true, required=true, defaultValue="${localRepository}") protected org.apache.maven.artifact.repository.ArtifactRepository localRepositoryLocal maven repository. -
remoteArtifactRepositories
@Parameter(readonly=true, required=true, defaultValue="${project.remoteArtifactRepositories}") protected List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositoriesRemote repositories which will be searched for source attachments. -
supportedProjectTypes
Project types which this plugin supports. -
noWarningProjectTypes
Project types which are not supported, but silently ignored. -
project
@Parameter(defaultValue="${project}", readonly=true, required=true) protected org.apache.maven.project.MavenProject projectThe Maven project. -
buildContext
@Component protected org.sonatype.plexus.build.incremental.BuildContext buildContext
-
-
Constructor Details
-
BundlePlugin
public BundlePlugin()
-
-
Method Details
-
getMaven2OsgiConverter
-
getProject
protected org.apache.maven.project.MavenProject getProject() -
getInstructions
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException- See Also:
-
transformDirectives
-
reportErrors
-
execute
protected void execute(Map<String, String> originalInstructions, org.apache.felix.bundleplugin.BundlePlugin.ClassPathItem[] classpath) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getOSGiBuilder
protected aQute.bnd.osgi.Builder getOSGiBuilder(org.apache.maven.project.MavenProject currentProject, Map<String, String> originalInstructions, org.apache.felix.bundleplugin.BundlePlugin.ClassPathItem[] classpath) throws Exception- Throws:
Exception
-
sanitize
-
sanitize
-
addMavenInstructions
protected void addMavenInstructions(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Builder builder) throws Exception - Throws:
Exception
-
updateExcludesInDeps
public boolean updateExcludesInDeps(org.apache.maven.project.MavenProject project, List<org.apache.maven.model.Dependency> dependencies, List<org.apache.maven.model.Dependency> transitiveDeps) throws org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException - Throws:
org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException
-
buildOSGiBundle
protected aQute.bnd.osgi.Builder buildOSGiBundle(org.apache.maven.project.MavenProject currentProject, Map<String, String> originalInstructions, org.apache.felix.bundleplugin.BundlePlugin.ClassPathItem[] classpath) throws Exception- Throws:
Exception
-
dumpInstructions
-
dumpClasspath
-
dumpManifest
-
includeMavenResources
protected static void includeMavenResources(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Analyzer analyzer, org.apache.maven.plugin.logging.Log log) -
mergeMavenManifest
protected void mergeMavenManifest(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Builder builder) throws Exception - Throws:
Exception
-
mergeManifest
protected static void mergeManifest(aQute.bnd.osgi.Instructions instructions, Manifest... manifests) throws IOException - Throws:
IOException
-
getOptionalPackages
protected Set<String> getOptionalPackages(org.apache.maven.project.MavenProject currentProject) throws IOException, org.apache.maven.plugin.MojoExecutionException - Throws:
IOExceptionorg.apache.maven.plugin.MojoExecutionException
-
isTransitivelyOptional
protected boolean isTransitivelyOptional(HashSet<String> optionalArtifactIds, org.apache.maven.artifact.Artifact artifact) Check to see if any dependency along the dependency trail of the artifact is optional.- Parameters:
artifact-
-
removeTagFromInstruction
-
getClasspath
protected org.apache.felix.bundleplugin.BundlePlugin.ClassPathItem[] getClasspath(org.apache.maven.project.MavenProject currentProject) throws IOException, org.apache.maven.plugin.MojoExecutionException - Throws:
IOExceptionorg.apache.maven.plugin.MojoExecutionException
-
getFile
Get the file for an Artifact- Parameters:
artifact-
-
convertVersionToOsgi
Convert a Maven version into an OSGi compliant version- Parameters:
version- Maven version- Returns:
- the OSGi version
-
getBundleName
TODO this should return getMaven2Osgi().getBundleFileName( project.getArtifact() ) -
getBuildDirectory
-
setBuildDirectory
-
getDefaultProperties
-
getBase
-
getOutputDirectory
-
setOutputDirectory
-
getMavenResourcePaths
protected static String getMavenResourcePaths(org.apache.maven.project.MavenProject currentProject, boolean test) -
getEmbeddableArtifacts
protected Collection<org.apache.maven.artifact.Artifact> getEmbeddableArtifacts(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Analyzer analyzer) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
addMavenSourcePath
protected static void addMavenSourcePath(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Analyzer analyzer, org.apache.maven.plugin.logging.Log log)
-