Class AbstractOsgiCompilerMojo

    • Field Detail

      • RULE_SEPARATOR

        public static final java.lang.String RULE_SEPARATOR
      • RULE_EXCLUDE_ALL

        public static final java.lang.String RULE_EXCLUDE_ALL
        Exclude all but keep looking for other another match
        See Also:
        Constant Field Values
      • MATCH_ALL

        private static final java.util.Set<java.lang.String> MATCH_ALL
      • PREFS_FILE_PATH

        private static final java.lang.String PREFS_FILE_PATH
      • project

        @Parameter(property="project",
                   readonly=true)
        private org.apache.maven.project.MavenProject project
      • extraClasspathElements

        @Parameter
        private org.apache.maven.model.Dependency[] extraClasspathElements
        Transitively add specified maven artifacts to compile classpath in addition to elements calculated according to OSGi rules. All packages from additional entries will be accessible at compile time. Useful when OSGi runtime classpath contains elements not defined using normal dependency mechanisms. For example, when Eclipse Equinox is started from application server with -Dosgi.parentClassloader=fwk parameter.
      • session

        @Parameter(property="session",
                   readonly=true)
        private org.apache.maven.execution.MavenSession session
      • repositorySystem

        @Component
        private org.apache.maven.repository.RepositorySystem repositorySystem
      • useJDK

        @Parameter(defaultValue="SYSTEM")
        private ToolchainProvider.JDKUsage useJDK
        Which JDK to use for compilation. Default value is SYSTEM which means the currently running JDK. If BREE is specified, MANIFEST header Bundle-RequiredExecutionEnvironment is used to define the JDK to compile against. In this case, you need to provide a toolchains.xml configuration file. The value of BREE will be matched against the id of the toolchain elements in toolchains.xml. Example:
         <toolchains>
           <toolchain>
              <type>jdk</type>
              <provides>
                  <id>J2SE-1.5</id>
              </provides>
              <configuration>
                 <jdkHome>/path/to/jdk/1.5</jdkHome>
              </configuration>
           </toolchain>
         </toolchains>
         
        The default value of the bootclasspath used for compilation is <jdkHome>/lib/*;<jdkHome>/lib/ext/*;<jdkHome>/lib/endorsed/* . For JDKs with different filesystem layouts, the bootclasspath can be specified explicitly in the configuration section. Example:
         <configuration>
           <jdkHome>/path/to/jdk/1.5</jdkHome>
           <bootClassPath>
             <includes>
               <include>jre/lib/amd64/default/jclSC160/*.jar</include>
             </includes>
             <excludes>
               <exclude>**/alt-*.jar</exclude>
             </excludes>
           </bootClassPath>
         </configuration>
         
      • toolChainManager

        @Component
        private org.apache.maven.toolchain.ToolchainManagerPrivate toolChainManager
      • includes

        @Parameter
        private java.util.Set<java.lang.String> includes
        A list of inclusion filters for the compiler.
      • excludes

        @Parameter
        private java.util.Set<java.lang.String> excludes
        A list of exclusion filters for the compiler.
      • excludeResources

        @Parameter
        private java.util.Set<java.lang.String> excludeResources
        A list of exclusion filters for non-java resource files which should not be copied to the output directory.
      • requireJREPackageImports

        @Parameter(defaultValue="false")
        private boolean requireJREPackageImports
        Whether a bundle is required to explicitly import non-java.* packages from the JDK. This is the design-time equivalent to the equinox runtime option osgi.compatibility.bootdelegation.
      • strictCompilerTarget

        @Parameter(defaultValue="false")
        private boolean strictCompilerTarget
        If set to false (the default) issue a warning if effective compiler target level is incompatible with bundle minimal execution environment. If set to true will fail the build if effective compiler target and minimal BREE are incompatible.
      • useProjectSettings

        @Parameter(defaultValue="true")
        private boolean useProjectSettings
        If set to true, the settings file ${project.basedir}/.settings/org.eclipse.jdt.core.prefs will be passed to the compiler. If the file is not present, the build will not fail.
      • outputJar

        private BuildOutputJar outputJar
        Current build output jar
      • bundleReader

        @Component
        private BundleReader bundleReader
      • copyResources

        @Parameter(defaultValue="true")
        private boolean copyResources
        Whether all resources in the source folders should be copied to ${project.build.outputDirectory}. true (default) means that all resources are copied from the source folders to ${project.build.outputDirectory}. false means that no resources are copied from the source folders to ${project.build.outputDirectory}. Set this to false in case you want to keep resources separate from java files in src/main/resources and handle them using maven-resources-plugin (e.g. for resource filtering.
      • logDirectory

        @Parameter(defaultValue="${project.build.directory}/compile-logs")
        private java.io.File logDirectory
        The directory where the compiler log files should be placed. For each output jar a log file will be created and stored in this directory. Logging into files is only enabled if log is specified. Default: ${project.build.directory}/compile-logs
      • log

        @Parameter
        private java.lang.String log
        The format of the compiler log file. plain will log into a plain text file (.log), xml will log in xml format (.xml). If omitted, no logging into files is done. The log file name is derived from the jar file name:
         Example:
         build.properties:
         
         output.lib1/library.jar = lib1bin/ 
         output.lib2/library.jar = lib2bin/ 
         output.. = bin/
         
         And a configuration:
         
         <configuration>
           <logEnabled>true</logEnabled>
           <logDirectory>${project.build.directory}/logfiles</logDirectory>
           <log>xml</log> 
         </configuration>
         
         Will produce the following log files
         
         ${project.build.directory}/logfiles/@dot.xml
         ${project.build.directory}/logfiles/lib1_library.jar.xml
         ${project.build.directory}/logfiles/lib2_library.jar.xml
         
    • Constructor Detail

      • AbstractOsgiCompilerMojo

        public AbstractOsgiCompilerMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException,
                            org.apache.maven.plugin.MojoFailureException
        Specified by:
        execute in interface org.apache.maven.plugin.Mojo
        Overrides:
        execute in class AbstractCompilerMojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • doCopyResources

        private void doCopyResources()
                              throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getEclipsePluginProject

        public EclipsePluginProject getEclipsePluginProject()
                                                     throws org.apache.maven.plugin.MojoExecutionException
        public for testing purposes
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getClasspathElements

        public java.util.List<java.lang.String> getClasspathElements()
                                                              throws org.apache.maven.plugin.MojoExecutionException
        Specified by:
        getClasspathElements in class AbstractCompilerMojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getBundleProject

        private BundleProject getBundleProject()
                                        throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getCompileSourceRoots

        protected final java.util.List<java.lang.String> getCompileSourceRoots()
                                                                        throws org.apache.maven.plugin.MojoExecutionException
        Specified by:
        getCompileSourceRoots in class AbstractCompilerMojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getSourcepath

        public java.util.List<SourcepathEntry> getSourcepath()
                                                      throws org.apache.maven.plugin.MojoExecutionException
        Description copied from interface: JavaCompilerConfiguration
        Computes and returns sourcepath of a Tycho eclipse-plugin or eclipse-test-plugin project.
        Specified by:
        getSourcepath in interface JavaCompilerConfiguration
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getSourceInclusionScanner

        protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner getSourceInclusionScanner​(java.lang.String inputFileEnding)
        Specified by:
        getSourceInclusionScanner in class AbstractCompilerMojo
      • getCompilerConfiguration

        protected org.codehaus.plexus.compiler.CompilerConfiguration getCompilerConfiguration​(java.util.List<java.lang.String> compileSourceRoots)
                                                                                       throws org.apache.maven.plugin.MojoExecutionException,
                                                                                              org.apache.maven.plugin.MojoFailureException
        Overrides:
        getCompilerConfiguration in class AbstractCompilerMojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • configureCompilerLog

        private void configureCompilerLog​(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration)
                                   throws org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoFailureException
      • configureBootclasspathAccessRules

        private void configureBootclasspathAccessRules​(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration)
                                                throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getStrictBootClasspathAccessRules

        private java.util.List<ClasspathEntry.AccessRule> getStrictBootClasspathAccessRules()
                                                                                     throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • configureJavaHome

        private void configureJavaHome​(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration)
                                throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • configureBootClassPath

        private void configureBootClassPath​(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration,
                                            org.apache.maven.toolchain.java.DefaultJavaToolChain javaToolChain)
      • scanBootclasspath

        private java.lang.String scanBootclasspath​(java.lang.String javaHome,
                                                   org.codehaus.plexus.util.xml.Xpp3Dom[] includes,
                                                   org.codehaus.plexus.util.xml.Xpp3Dom excludeParent)
      • getValues

        private static java.lang.String[] getValues​(org.codehaus.plexus.util.xml.Xpp3Dom[] doms)
      • configureSourceAndTargetLevel

        private void configureSourceAndTargetLevel​(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration)
                                            throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getTargetExecutionEnvironment

        private ExecutionEnvironment getTargetExecutionEnvironment()
                                                            throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getClasspath

        public java.util.List<ClasspathEntry> getClasspath()
                                                    throws org.apache.maven.plugin.MojoExecutionException
        Description copied from interface: JavaCompilerConfiguration
        Computes and returns compile classpath of a Tycho eclipse-plugin or eclipse-test-plugin project.
        Specified by:
        getClasspath in interface JavaCompilerConfiguration
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getExecutionEnvironment

        public java.lang.String getExecutionEnvironment()
                                                 throws org.apache.maven.plugin.MojoExecutionException
        Specified by:
        getExecutionEnvironment in interface JavaCompilerConfiguration
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getSourceLevel

        public java.lang.String getSourceLevel()
                                        throws org.apache.maven.plugin.MojoExecutionException
        Specified by:
        getSourceLevel in interface JavaCompilerConfiguration
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getSourceLevel

        private java.lang.String getSourceLevel​(ExecutionEnvironment ee)
                                         throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getTargetLevel

        public java.lang.String getTargetLevel()
                                        throws org.apache.maven.plugin.MojoExecutionException
        Specified by:
        getTargetLevel in interface JavaCompilerConfiguration
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getTargetLevel

        public java.lang.String getTargetLevel​(ExecutionEnvironment ee)
                                        throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • checkTargetLevelCompatibleWithManifestBREEs

        private void checkTargetLevelCompatibleWithManifestBREEs​(java.lang.String effectiveTargetLevel,
                                                                 StandardExecutionEnvironment[] manifestBREEs)
                                                          throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getAdapter

        public <T> T getAdapter​(java.lang.Class<T> adapter)
        Specified by:
        getAdapter in interface Adaptable