Package org.eclipse.tycho.compiler
Class AbstractOsgiCompilerMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- copied.org.apache.maven.plugin.AbstractCompilerMojo
-
- org.eclipse.tycho.compiler.AbstractOsgiCompilerMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
,JavaCompilerConfiguration
,Adaptable
- Direct Known Subclasses:
OsgiCompilerMojo
public abstract class AbstractOsgiCompilerMojo extends AbstractCompilerMojo implements JavaCompilerConfiguration, Adaptable
-
-
Field Summary
Fields Modifier and Type Field 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 jarprivate 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 matchstatic java.lang.String
RULE_SEPARATOR
private org.apache.maven.execution.MavenSession
session
private boolean
strictCompilerTarget
If set tofalse
(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 totrue
, the settings file ${project.basedir}/.settings/org.eclipse.jdt.core.prefs will be passed to the compiler.-
Fields inherited from class copied.org.apache.maven.plugin.AbstractCompilerMojo
DEFAULT_SOURCE_VERSION, DEFAULT_TARGET_VERSION, release, source, target
-
-
Constructor Summary
Constructors Constructor Description AbstractOsgiCompilerMojo()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 purposesjava.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)
-
Methods inherited from class copied.org.apache.maven.plugin.AbstractCompilerMojo
removeEmptyCompileSourceRoots
-
-
-
-
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 headerBundle-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 tofalse
(the default) issue a warning if effective compiler target level is incompatible with bundle minimal execution environment. If set totrue
will fail the build if effective compiler target and minimal BREE are incompatible.
-
useProjectSettings
@Parameter(defaultValue="true") private boolean useProjectSettings
If set totrue
, 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
-
projectTypes
@Component(role=TychoProject.class) private java.util.Map<java.lang.String,TychoProject> projectTypes
-
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 tofalse
in case you want to keep resources separate from java files insrc/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 iflog
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
-
toolchainProvider
@Component ToolchainProvider toolchainProvider
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Specified by:
execute
in interfaceorg.apache.maven.plugin.Mojo
- Overrides:
execute
in classAbstractCompilerMojo
- 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
-
getOutputDirectory
protected java.io.File getOutputDirectory()
- Specified by:
getOutputDirectory
in classAbstractCompilerMojo
-
getClasspathElements
public java.util.List<java.lang.String> getClasspathElements() throws org.apache.maven.plugin.MojoExecutionException
- Specified by:
getClasspathElements
in classAbstractCompilerMojo
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getBundleProject
private BundleProject getBundleProject() throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
toString
private java.lang.String toString(java.util.List<ClasspathEntry.AccessRule> rules)
-
getCompileSourceRoots
protected final java.util.List<java.lang.String> getCompileSourceRoots() throws org.apache.maven.plugin.MojoExecutionException
- Specified by:
getCompileSourceRoots
in classAbstractCompilerMojo
- 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 interfaceJavaCompilerConfiguration
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getSourceInclusionScanner
protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner getSourceInclusionScanner(int staleMillis)
- Specified by:
getSourceInclusionScanner
in classAbstractCompilerMojo
-
getSourceInclusionScanner
protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner getSourceInclusionScanner(java.lang.String inputFileEnding)
- Specified by:
getSourceInclusionScanner
in classAbstractCompilerMojo
-
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 classAbstractCompilerMojo
- 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 interfaceJavaCompilerConfiguration
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getExecutionEnvironment
public java.lang.String getExecutionEnvironment() throws org.apache.maven.plugin.MojoExecutionException
- Specified by:
getExecutionEnvironment
in interfaceJavaCompilerConfiguration
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getSourceLevel
public java.lang.String getSourceLevel() throws org.apache.maven.plugin.MojoExecutionException
- Specified by:
getSourceLevel
in interfaceJavaCompilerConfiguration
- 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 interfaceJavaCompilerConfiguration
- 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 interfaceAdaptable
-
-