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 TypeFieldDescriptionprivate org.apache.maven.archiver.MavenArchiveConfiguration
The archive configuration to use.private org.apache.maven.artifact.resolver.ArtifactCollector
protected org.apache.maven.artifact.factory.ArtifactFactory
private org.apache.maven.artifact.metadata.ArtifactMetadataSource
protected org.apache.maven.artifact.resolver.ArtifactResolver
Artifact resolver, needed to download source jars for inclusion in classpath.protected org.sonatype.plexus.build.incremental.BuildContext
private String
The directory for the generated JAR.private static final String
private static final String
protected String
Classifier type of the bundle to be installed.protected boolean
If true, remove any inlined or embedded dependencies from the resulting pom.private static final String[]
protected org.apache.maven.shared.dependency.graph.DependencyGraphBuilder
The dependency graph builder to use.protected File
Where to put the dependency reduced pom.protected File
File where the BND class-path will be dumpedprotected File
File where the BND instructions will be dumpedprivate static final String[]
protected String
Comma separated list of artifactIds to exclude from the dependency classpath passed to BND (use "true" to exclude everything)protected boolean
When true, dump the generated SCR filesprivate String
Final name of the bundle (without classifier or extension)The BND instructions for the bundle.private static final String
protected org.apache.maven.artifact.repository.ArtifactRepository
Local maven repository.private org.codehaus.plexus.archiver.manager.ArchiverManager
private org.apache.maven.artifact.handler.manager.ArtifactHandlerManager
protected org.apache.maven.shared.dependency.graph.DependencyGraphBuilder
private final Maven2OsgiConverter
Use locally patched version for now.private org.apache.maven.execution.MavenSession
private org.apache.maven.project.MavenProjectHelper
protected File
Directory where the manifest will be writtenprivate static final String
private static final String
private static final String
private static final String
private static final String
protected org.apache.maven.project.MavenProjectBuilder
ProjectBuilder, needed to create projects from the artifacts.protected boolean
Output a nicely formatted manifest that still respects the 72 character line limit.private static final String
private File
The directory for the generated bundles.protected String
Packaging type of the bundle to be installed.protected org.apache.maven.project.MavenProject
The Maven project.protected List<org.apache.maven.artifact.repository.ArtifactRepository>
Remote repositories which will be searched for source attachments.protected File
Directory where the SCR files will be writtenprotected org.apache.maven.execution.MavenSession
Project types which this plugin supports.protected boolean
When true, unpack the bundle contents to the outputDirectoryFields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
addLocalPackages
(File outputDirectory, aQute.bnd.osgi.Analyzer analyzer) protected void
addMavenInstructions
(org.apache.maven.project.MavenProject currentProject, org.apache.maven.shared.dependency.graph.DependencyNode dependencyGraph, aQute.bnd.osgi.Builder builder) protected static void
addMavenSourcePath
(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Analyzer analyzer, org.apache.maven.plugin.logging.Log log) protected org.apache.maven.shared.dependency.graph.DependencyNode
buildDependencyGraph
(org.apache.maven.project.MavenProject mavenProject) protected aQute.bnd.osgi.Builder
buildOSGiBundle
(org.apache.maven.project.MavenProject currentProject, org.apache.maven.shared.dependency.graph.DependencyNode dependencyGraph, Map<String, String> originalInstructions, Properties properties, aQute.bnd.osgi.Jar[] classpath) protected String
convertVersionToOsgi
(String version) Convert a Maven version into an OSGi compliant versionprivate void
createDependencyReducedPom
(Set<String> artifactsToRemove) private void
doMavenMetadata
(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Jar jar) protected static StringBuilder
dumpClasspath
(List<aQute.bnd.osgi.Jar> classpath, StringBuilder buf) protected static StringBuilder
dumpInstructions
(Properties properties, StringBuilder buf) protected static StringBuilder
dumpManifest
(Manifest manifest, StringBuilder buf) void
execute()
protected void
execute
(org.apache.maven.project.MavenProject currentProject, org.apache.maven.shared.dependency.graph.DependencyNode dependencyGraph, Map<String, String> originalInstructions, Properties properties) protected void
execute
(org.apache.maven.project.MavenProject currentProject, org.apache.maven.shared.dependency.graph.DependencyNode dependencyGraph, Map<String, String> originalInstructions, Properties properties, aQute.bnd.osgi.Jar[] classpath) private static Attributes
filterAttributes
(aQute.bnd.osgi.Instructions instructions, Attributes source, Set<aQute.bnd.osgi.Instruction> nomatch) protected static File
getBase
(org.apache.maven.project.MavenProject currentProject) protected String
protected String
getBundleName
(org.apache.maven.project.MavenProject currentProject) TODO this should return getMaven2Osgi().getBundleFileName( project.getArtifact() )protected aQute.bnd.osgi.Jar[]
getClasspath
(org.apache.maven.project.MavenProject currentProject, org.apache.maven.shared.dependency.graph.DependencyNode dependencyGraph) protected Properties
getDefaultProperties
(org.apache.maven.project.MavenProject currentProject) protected Collection<org.apache.maven.artifact.Artifact>
getEmbeddableArtifacts
(org.apache.maven.project.MavenProject currentProject, org.apache.maven.shared.dependency.graph.DependencyNode dependencyGraph, aQute.bnd.osgi.Analyzer analyzer) protected File
getFile
(org.apache.maven.artifact.Artifact artifact) Get the file for an Artifactprivate String
private String
getId
(org.apache.maven.artifact.Artifact artifact) private String
getId
(org.apache.maven.model.Dependency dependency) protected Maven2OsgiConverter
protected static String
getMavenResourcePaths
(org.apache.maven.project.MavenProject currentProject, boolean test) private static List<org.apache.maven.model.Resource>
getMavenResources
(org.apache.maven.project.MavenProject currentProject, boolean test) getOptionalPackages
(org.apache.maven.project.MavenProject currentProject, org.apache.maven.shared.dependency.graph.DependencyNode dependencyGraph) protected aQute.bnd.osgi.Builder
getOSGiBuilder
(org.apache.maven.project.MavenProject currentProject, Map<String, String> originalInstructions, Properties properties, aQute.bnd.osgi.Jar[] classpath) protected File
private static String
getPackageName
(String filename) protected org.apache.maven.project.MavenProject
getProperties
(org.apache.maven.model.Model projectModel, String prefix) private Collection<org.apache.maven.artifact.Artifact>
getSelectedDependencies
(org.apache.maven.shared.dependency.graph.DependencyNode dependencyGraph, Collection<org.apache.maven.artifact.Artifact> artifacts) private static void
header
(Properties properties, String key, Object value) protected static void
includeJava9Fixups
(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Analyzer analyzer) Downgrade the message "Classes found in the wrong directory" to a warning.protected static void
includeMavenResources
(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Analyzer analyzer, org.apache.maven.plugin.logging.Log log) 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.private static void
mergeAttributes
(Attributes... attributesArray) protected static void
mergeManifest
(aQute.bnd.osgi.Instructions instructions, Manifest... manifests) protected void
mergeMavenManifest
(org.apache.maven.project.MavenProject currentProject, org.apache.maven.shared.dependency.graph.DependencyNode dependencyGraph, aQute.bnd.osgi.Builder builder) private static StringBuffer
printLicenses
(List<org.apache.maven.model.License> licenses) protected static String
removeTagFromInstruction
(String instruction, String tag) protected boolean
reportErrors
(String prefix, aQute.bnd.osgi.Analyzer analyzer) protected static String
protected static Properties
sanitize
(Properties properties) protected void
setBuildDirectory
(String _buildirectory) protected void
setOutputDirectory
(File _outputDirectory) transformDirectives
(Map<String, String> originalInstructions) private void
unpackBundle
(File jarFile) boolean
updateExcludesInDeps
(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) -
finalName
Final name of the bundle (without classifier or extension) -
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 -
m_projectHelper
@Component private org.apache.maven.project.MavenProjectHelper m_projectHelper -
m_archiverManager
@Component private org.codehaus.plexus.archiver.manager.ArchiverManager m_archiverManager -
m_artifactHandlerManager
@Component private org.apache.maven.artifact.handler.manager.ArtifactHandlerManager m_artifactHandlerManager -
m_dependencyGraphBuilder
@Component protected org.apache.maven.shared.dependency.graph.DependencyGraphBuilder m_dependencyGraphBuilder -
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 dependencyGraphBuilderThe dependency graph builder to use. -
artifactMetadataSource
@Component private org.apache.maven.artifact.metadata.ArtifactMetadataSource artifactMetadataSource -
artifactCollector
@Component private org.apache.maven.artifact.resolver.ArtifactCollector artifactCollector -
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. -
outputDirectory
The directory for the generated bundles. -
buildDirectory
The directory for the generated JAR. -
project
@Parameter(defaultValue="${project}", readonly=true, required=true) protected org.apache.maven.project.MavenProject projectThe Maven project. -
instructions
The BND instructions for the bundle. Maven will expand property macros in these values. If you want to use a BND macro, you must double the dollar sign for the plugin to pass it to BND correctly. For example:
<_consumer-policy>$${range;[===,+)}<code>
</_consumer-policy>
-
m_maven2OsgiConverter
Use locally patched version for now. -
archive
@Parameter private org.apache.maven.archiver.MavenArchiveConfiguration archiveThe archive configuration to use. -
m_mavenSession
@Parameter(defaultValue="${session}", readonly=true, required=true) private org.apache.maven.execution.MavenSession m_mavenSession -
buildContext
@Component protected org.sonatype.plexus.build.incremental.BuildContext buildContext -
MAVEN_SYMBOLICNAME
- See Also:
-
MAVEN_RESOURCES
- See Also:
-
MAVEN_TEST_RESOURCES
- See Also:
-
LOCAL_PACKAGES
- See Also:
-
MAVEN_SOURCES
- See Also:
-
MAVEN_TEST_SOURCES
- See Also:
-
BUNDLE_PLUGIN_EXTENSION
- See Also:
-
BUNDLE_PLUGIN_PREPEND_EXTENSION
- See Also:
-
EMPTY_STRING_ARRAY
-
DEFAULT_INCLUDES
-
NL
-
-
Constructor Details
-
BundlePlugin
public BundlePlugin()
-
-
Method Details
-
getMaven2OsgiConverter
-
getProject
protected org.apache.maven.project.MavenProject getProject() -
buildDependencyGraph
protected org.apache.maven.shared.dependency.graph.DependencyNode buildDependencyGraph(org.apache.maven.project.MavenProject mavenProject) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
- See Also:
-
Mojo.execute()
-
transformDirectives
-
reportErrors
-
getOSGiBuilder
protected aQute.bnd.osgi.Builder getOSGiBuilder(org.apache.maven.project.MavenProject currentProject, Map<String, String> originalInstructions, Properties properties, aQute.bnd.osgi.Jar[] classpath) throws Exception- Throws:
Exception
-
sanitize
-
sanitize
-
createDependencyReducedPom
private void createDependencyReducedPom(Set<String> artifactsToRemove) throws IOException, org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException, org.apache.maven.project.ProjectBuildingException - Throws:
IOException
org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException
org.apache.maven.project.ProjectBuildingException
-
getId
-
getId
-
getId
-
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
-
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) -
mergeManifest
protected static void mergeManifest(aQute.bnd.osgi.Instructions instructions, Manifest... manifests) throws IOException - Throws:
IOException
-
filterAttributes
private static Attributes filterAttributes(aQute.bnd.osgi.Instructions instructions, Attributes source, Set<aQute.bnd.osgi.Instruction> nomatch) - See Also:
-
Analyzer.filter(aQute.bnd.osgi.Instructions, aQute.bnd.osgi.Packages, java.util.Set<aQute.bnd.osgi.Instruction>)
-
mergeAttributes
- Throws:
IOException
-
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
-
-
unpackBundle
-
removeTagFromInstruction
-
getProperties
-
printLicenses
-
doMavenMetadata
private void doMavenMetadata(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Jar jar) throws IOException - Parameters:
jar
-- Throws:
IOException
-
getFile
Get the file for an Artifact- Parameters:
artifact
-
-
header
-
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
-
addLocalPackages
private static void addLocalPackages(File outputDirectory, aQute.bnd.osgi.Analyzer analyzer) throws IOException - Throws:
IOException
-
getPackageName
-
getMavenResources
private static List<org.apache.maven.model.Resource> getMavenResources(org.apache.maven.project.MavenProject currentProject, boolean test) -
getMavenResourcePaths
protected static String getMavenResourcePaths(org.apache.maven.project.MavenProject currentProject, boolean test) -
addMavenSourcePath
protected static void addMavenSourcePath(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Analyzer analyzer, org.apache.maven.plugin.logging.Log log) -
includeJava9Fixups
protected static void includeJava9Fixups(org.apache.maven.project.MavenProject currentProject, aQute.bnd.osgi.Analyzer analyzer) Downgrade the message "Classes found in the wrong directory" to a warning. This allows the plugin to process a multi-release JAR (see JEP 238, http://openjdk.java.net/jeps/238). Note that the version-specific paths will NOT be visible at runtime nor processed by bnd for imported packages etc. This will not be possible until a runtime solution for multi-release JARs exists in OSGi. This fix only allows these JARs to be processed at all and to be usable on Java 8 (and below), and also on Java 9 where the version-specific customizations are optional.
-