Class ManifestPlugin

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
    Direct Known Subclasses:
    BundleAllPlugin

    @Mojo(name="manifest",
          requiresDependencyResolution=TEST,
          threadSafe=true,
          defaultPhase=PROCESS_CLASSES)
    public class ManifestPlugin
    extends BundlePlugin
    Generate an OSGi manifest for this project
    • Field Detail

      • rebuildBundle

        @Parameter(property="rebuildBundle")
        protected boolean rebuildBundle
        When true, generate the manifest by rebuilding the full bundle in memory
      • supportIncrementalBuild

        @Parameter(property="supportIncrementalBuild")
        private boolean supportIncrementalBuild
        When true, manifest generation on incremental builds is supported in IDEs like Eclipse. Please note that the underlying BND library does not support incremental build, which means always the whole manifest and SCR metadata is generated.
      • showStaleFiles

        @Parameter(property="showStaleFiles")
        private boolean showStaleFiles
        When true, show stale files in the log at info level else at debug level.
      • buildContext

        @Component
        private org.sonatype.plexus.build.incremental.BuildContext buildContext
    • Constructor Detail

      • ManifestPlugin

        public ManifestPlugin()
    • Method Detail

      • execute

        protected void execute​(java.util.Map<java.lang.String,​java.lang.String> instructions,
                               BundlePlugin.ClassPathItem[] classpath)
                        throws org.apache.maven.plugin.MojoExecutionException
        Overrides:
        execute in class BundlePlugin
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • anyJavaSourceFileTouchedSinceLastBuild

        private boolean anyJavaSourceFileTouchedSinceLastBuild()
        Checks if any *.java file was added, updated or removed since last build in any source directory.
      • containsJavaFile

        private boolean containsJavaFile​(org.codehaus.plexus.util.Scanner scanner)
      • getManifest

        public java.util.jar.Manifest getManifest​(org.apache.maven.project.MavenProject project,
                                                  BundlePlugin.ClassPathItem[] classpath)
                                           throws java.io.IOException,
                                                  org.apache.maven.plugin.MojoFailureException,
                                                  org.apache.maven.plugin.MojoExecutionException,
                                                  java.lang.Exception
        Throws:
        java.io.IOException
        org.apache.maven.plugin.MojoFailureException
        org.apache.maven.plugin.MojoExecutionException
        java.lang.Exception
      • getManifest

        public java.util.jar.Manifest getManifest​(org.apache.maven.project.MavenProject project,
                                                  java.util.Map<java.lang.String,​java.lang.String> instructions,
                                                  BundlePlugin.ClassPathItem[] classpath,
                                                  org.sonatype.plexus.build.incremental.BuildContext buildContext)
                                           throws java.io.IOException,
                                                  org.apache.maven.plugin.MojoFailureException,
                                                  org.apache.maven.plugin.MojoExecutionException,
                                                  java.lang.Exception
        Throws:
        java.io.IOException
        org.apache.maven.plugin.MojoFailureException
        org.apache.maven.plugin.MojoExecutionException
        java.lang.Exception
      • exportScr

        private static void exportScr​(aQute.bnd.osgi.Analyzer analyzer,
                                      aQute.bnd.osgi.Jar jar,
                                      java.io.File scrLocation,
                                      org.sonatype.plexus.build.incremental.BuildContext buildContext,
                                      org.apache.maven.plugin.logging.Log log)
                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • writeSCR

        private static void writeSCR​(aQute.bnd.osgi.Resource resource,
                                     java.io.File destination,
                                     org.sonatype.plexus.build.incremental.BuildContext buildContext,
                                     org.apache.maven.plugin.logging.Log log)
                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getAnalyzer

        protected aQute.bnd.osgi.Analyzer getAnalyzer​(org.apache.maven.project.MavenProject project,
                                                      BundlePlugin.ClassPathItem[] classpath)
                                               throws java.io.IOException,
                                                      org.apache.maven.plugin.MojoExecutionException,
                                                      java.lang.Exception
        Throws:
        java.io.IOException
        org.apache.maven.plugin.MojoExecutionException
        java.lang.Exception
      • getAnalyzer

        protected aQute.bnd.osgi.Analyzer getAnalyzer​(org.apache.maven.project.MavenProject project,
                                                      java.util.Map<java.lang.String,​java.lang.String> instructions,
                                                      BundlePlugin.ClassPathItem[] classpath)
                                               throws java.io.IOException,
                                                      org.apache.maven.plugin.MojoExecutionException,
                                                      java.lang.Exception
        Throws:
        java.io.IOException
        org.apache.maven.plugin.MojoExecutionException
        java.lang.Exception
      • writeIncrementalInfo

        private void writeIncrementalInfo​(org.apache.maven.project.MavenProject project)
                                   throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • isUpToDate

        private boolean isUpToDate​(org.apache.maven.project.MavenProject project)
                            throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • isMetadataUpToDate

        private boolean isMetadataUpToDate​(java.io.File outputFile,
                                           org.apache.maven.project.MavenProject project)
                                    throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getManifestUptodateCheckException

        private static org.apache.maven.plugin.MojoExecutionException getManifestUptodateCheckException​(java.io.IOException e)
      • getIncrementalData

        private java.lang.String getIncrementalData()
      • getIncrementalDataPath

        private java.nio.file.Path getIncrementalDataPath​(org.apache.maven.project.MavenProject project)
      • lastmod

        private long lastmod​(java.nio.file.Path p)
      • lastModified

        private static long lastModified​(java.nio.file.Path p)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • newer

        private java.util.stream.Stream<java.lang.String> newer​(long lastmod,
                                                                java.io.File file)
      • writeManifest

        public static void writeManifest​(aQute.bnd.osgi.Analyzer analyzer,
                                         java.io.File outputFile,
                                         boolean niceManifest,
                                         boolean exportScr,
                                         java.io.File scrLocation,
                                         org.sonatype.plexus.build.incremental.BuildContext buildContext,
                                         org.apache.maven.plugin.logging.Log log)
                                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • writeManifest

        public static void writeManifest​(java.util.jar.Manifest manifest,
                                         java.io.File outputFile,
                                         boolean niceManifest,
                                         org.sonatype.plexus.build.incremental.BuildContext buildContext,
                                         org.apache.maven.plugin.logging.Log log)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • calculateExportsFromContents

        public static java.lang.String calculateExportsFromContents​(aQute.bnd.osgi.Jar bundle)