public abstract class AbstractOsgiCompilerMojo extends AbstractCompilerMojo implements JavaCompilerConfiguration, Adaptable
| Modifier and Type | Field and Description |
|---|---|
private BundleReader |
bundleReader |
private boolean |
copyResources
Whether all resources in the source folders should be copied to
${project.build.outputDirectory}.
|
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.
|
private java.util.Set<java.lang.String> |
excludes
A list of exclusion filters for the compiler.
|
private org.apache.maven.model.Dependency[] |
extraClasspathElements
Transitively add specified maven artifacts to compile classpath in addition to elements
calculated according to OSGi rules.
|
private java.util.Set<java.lang.String> |
includes
A list of inclusion filters for the compiler.
|
private java.lang.String |
log
The format of the compiler log file.
|
private java.io.File |
logDirectory
The directory where the compiler log files should be placed.
|
private static java.util.Set<java.lang.String> |
MATCH_ALL |
private BuildOutputJar |
outputJar
Current build output jar
|
private static java.lang.String |
PREFS_FILE_PATH |
private org.apache.maven.project.MavenProject |
project |
private java.util.Map<java.lang.String,TychoProject> |
projectTypes |
private org.apache.maven.repository.RepositorySystem |
repositorySystem |
private boolean |
requireJREPackageImports
Whether a bundle is required to explicitly import non-java.* packages from the JDK.
|
static java.lang.String |
RULE_EXCLUDE_ALL
Exclude all but keep looking for other another match
|
static java.lang.String |
RULE_SEPARATOR |
private org.apache.maven.execution.MavenSession |
session |
private boolean |
strictCompilerTarget
If set to
false (the default) issue a warning if effective compiler target level
is incompatible with bundle minimal execution environment. |
private org.apache.maven.toolchain.ToolchainManagerPrivate |
toolChainManager |
(package private) ToolchainProvider |
toolchainProvider |
private ToolchainProvider.JDKUsage |
useJDK
Which JDK to use for compilation.
|
private boolean |
useProjectSettings
If set to
true, the settings file
${project.basedir}/.settings/org.eclipse.jdt.core.prefs will be passed to the compiler. |
DEFAULT_SOURCE_VERSION, DEFAULT_TARGET_VERSION, source, target| Constructor and Description |
|---|
AbstractOsgiCompilerMojo() |
| Modifier and Type | Method and Description |
|---|---|
private void |
checkTargetLevelCompatibleWithManifestBREEs(java.lang.String effectiveTargetLevel,
StandardExecutionEnvironment[] manifestBREEs) |
private void |
configureBootClassPath(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration,
org.apache.maven.toolchain.java.DefaultJavaToolChain javaToolChain) |
private void |
configureBootclasspathAccessRules(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration) |
private void |
configureCompilerLog(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration) |
private void |
configureJavaHome(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration) |
private void |
configureSourceAndTargetLevel(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration) |
private void |
doCopyResources() |
void |
execute() |
<T> T |
getAdapter(java.lang.Class<T> adapter) |
private BundleProject |
getBundleProject() |
java.util.List<ClasspathEntry> |
getClasspath()
Computes and returns compile classpath of a Tycho eclipse-plugin or eclipse-test-plugin
project.
|
java.util.List<java.lang.String> |
getClasspathElements() |
protected org.codehaus.plexus.compiler.CompilerConfiguration |
getCompilerConfiguration(java.util.List<java.lang.String> compileSourceRoots) |
protected java.util.List<java.lang.String> |
getCompileSourceRoots() |
EclipsePluginProject |
getEclipsePluginProject()
public for testing purposes
|
java.lang.String |
getExecutionEnvironment() |
protected java.io.File |
getOutputDirectory() |
protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner |
getSourceInclusionScanner(int staleMillis) |
protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner |
getSourceInclusionScanner(java.lang.String inputFileEnding) |
java.lang.String |
getSourceLevel() |
private java.lang.String |
getSourceLevel(ExecutionEnvironment ee) |
java.util.List<SourcepathEntry> |
getSourcepath()
Computes and returns sourcepath of a Tycho eclipse-plugin or eclipse-test-plugin project.
|
private java.util.List<ClasspathEntry.AccessRule> |
getStrictBootClasspathAccessRules() |
private ExecutionEnvironment |
getTargetExecutionEnvironment() |
java.lang.String |
getTargetLevel() |
java.lang.String |
getTargetLevel(ExecutionEnvironment ee) |
private static java.lang.String[] |
getValues(org.codehaus.plexus.util.xml.Xpp3Dom[] doms) |
private java.lang.String |
scanBootclasspath(java.lang.String javaHome,
org.codehaus.plexus.util.xml.Xpp3Dom[] includes,
org.codehaus.plexus.util.xml.Xpp3Dom excludeParent) |
private java.lang.String |
toString(java.util.List<ClasspathEntry.AccessRule> rules) |
removeEmptyCompileSourceRootspublic static final java.lang.String RULE_SEPARATOR
public static final java.lang.String RULE_EXCLUDE_ALL
private static final java.util.Set<java.lang.String> MATCH_ALL
private static final java.lang.String PREFS_FILE_PATH
@Parameter(property="project",
readonly=true)
private org.apache.maven.project.MavenProject project
@Parameter private org.apache.maven.model.Dependency[] extraClasspathElements
@Parameter(property="session",
readonly=true)
private org.apache.maven.execution.MavenSession session
@Component private org.apache.maven.repository.RepositorySystem repositorySystem
@Parameter(defaultValue="SYSTEM") private ToolchainProvider.JDKUsage useJDK
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>
@Component private org.apache.maven.toolchain.ToolchainManagerPrivate toolChainManager
@Parameter private java.util.Set<java.lang.String> includes
@Parameter private java.util.Set<java.lang.String> excludes
@Parameter private java.util.Set<java.lang.String> excludeResources
@Parameter(defaultValue="false") private boolean requireJREPackageImports
@Parameter(defaultValue="false") private boolean strictCompilerTarget
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.@Parameter(defaultValue="true") private boolean useProjectSettings
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.private BuildOutputJar outputJar
@Component(role=TychoProject.class) private java.util.Map<java.lang.String,TychoProject> projectTypes
@Component private BundleReader bundleReader
@Parameter(defaultValue="true") private boolean copyResources
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.@Parameter(defaultValue="${project.build.directory}/compile-logs")
private java.io.File logDirectory
log is specified. Default: ${project.build.directory}/compile-logs@Parameter private java.lang.String log
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
@Component ToolchainProvider toolchainProvider
public void execute()
throws org.apache.maven.plugin.MojoExecutionException,
org.apache.maven.plugin.MojoFailureException
execute in interface org.apache.maven.plugin.Mojoexecute in class AbstractCompilerMojoorg.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureExceptionprivate void doCopyResources()
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionpublic EclipsePluginProject getEclipsePluginProject() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprotected java.io.File getOutputDirectory()
getOutputDirectory in class AbstractCompilerMojopublic java.util.List<java.lang.String> getClasspathElements()
throws org.apache.maven.plugin.MojoExecutionException
getClasspathElements in class AbstractCompilerMojoorg.apache.maven.plugin.MojoExecutionExceptionprivate BundleProject getBundleProject() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate java.lang.String toString(java.util.List<ClasspathEntry.AccessRule> rules)
protected final java.util.List<java.lang.String> getCompileSourceRoots()
throws org.apache.maven.plugin.MojoExecutionException
getCompileSourceRoots in class AbstractCompilerMojoorg.apache.maven.plugin.MojoExecutionExceptionpublic java.util.List<SourcepathEntry> getSourcepath() throws org.apache.maven.plugin.MojoExecutionException
JavaCompilerConfigurationgetSourcepath in interface JavaCompilerConfigurationorg.apache.maven.plugin.MojoExecutionExceptionprotected org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner getSourceInclusionScanner(int staleMillis)
getSourceInclusionScanner in class AbstractCompilerMojoprotected org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner getSourceInclusionScanner(java.lang.String inputFileEnding)
getSourceInclusionScanner in class AbstractCompilerMojoprotected org.codehaus.plexus.compiler.CompilerConfiguration getCompilerConfiguration(java.util.List<java.lang.String> compileSourceRoots)
throws org.apache.maven.plugin.MojoExecutionException,
org.apache.maven.plugin.MojoFailureException
getCompilerConfiguration in class AbstractCompilerMojoorg.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureExceptionprivate void configureCompilerLog(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration)
throws org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoFailureExceptionprivate void configureBootclasspathAccessRules(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration)
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate java.util.List<ClasspathEntry.AccessRule> getStrictBootClasspathAccessRules() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate void configureJavaHome(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration)
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate void configureBootClassPath(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration,
org.apache.maven.toolchain.java.DefaultJavaToolChain javaToolChain)
private java.lang.String scanBootclasspath(java.lang.String javaHome,
org.codehaus.plexus.util.xml.Xpp3Dom[] includes,
org.codehaus.plexus.util.xml.Xpp3Dom excludeParent)
private static java.lang.String[] getValues(org.codehaus.plexus.util.xml.Xpp3Dom[] doms)
private void configureSourceAndTargetLevel(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration)
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate ExecutionEnvironment getTargetExecutionEnvironment() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionpublic java.util.List<ClasspathEntry> getClasspath() throws org.apache.maven.plugin.MojoExecutionException
JavaCompilerConfigurationgetClasspath in interface JavaCompilerConfigurationorg.apache.maven.plugin.MojoExecutionExceptionpublic java.lang.String getExecutionEnvironment()
throws org.apache.maven.plugin.MojoExecutionException
getExecutionEnvironment in interface JavaCompilerConfigurationorg.apache.maven.plugin.MojoExecutionExceptionpublic java.lang.String getSourceLevel()
throws org.apache.maven.plugin.MojoExecutionException
getSourceLevel in interface JavaCompilerConfigurationorg.apache.maven.plugin.MojoExecutionExceptionprivate java.lang.String getSourceLevel(ExecutionEnvironment ee) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionpublic java.lang.String getTargetLevel()
throws org.apache.maven.plugin.MojoExecutionException
getTargetLevel in interface JavaCompilerConfigurationorg.apache.maven.plugin.MojoExecutionExceptionpublic java.lang.String getTargetLevel(ExecutionEnvironment ee) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate void checkTargetLevelCompatibleWithManifestBREEs(java.lang.String effectiveTargetLevel,
StandardExecutionEnvironment[] manifestBREEs)
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionpublic <T> T getAdapter(java.lang.Class<T> adapter)
getAdapter in interface Adaptable