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 BundleReaderbundleReaderprivate booleancopyResourcesWhether all resources in the source folders should be copied to ${project.build.outputDirectory}.private java.util.Set<java.lang.String>excludeResourcesA 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>excludesA list of exclusion filters for the compiler.private org.apache.maven.model.Dependency[]extraClasspathElementsTransitively add specified maven artifacts to compile classpath in addition to elements calculated according to OSGi rules.private java.util.Set<java.lang.String>includesA list of inclusion filters for the compiler.private java.lang.StringlogThe format of the compiler log file.private java.io.FilelogDirectoryThe directory where the compiler log files should be placed.private static java.util.Set<java.lang.String>MATCH_ALLprivate BuildOutputJaroutputJarCurrent build output jarprivate static java.lang.StringPREFS_FILE_PATHprivate org.apache.maven.project.MavenProjectprojectprivate java.util.Map<java.lang.String,TychoProject>projectTypesprivate org.apache.maven.repository.RepositorySystemrepositorySystemprivate booleanrequireJREPackageImportsWhether a bundle is required to explicitly import non-java.* packages from the JDK.static java.lang.StringRULE_EXCLUDE_ALLExclude all but keep looking for other another matchstatic java.lang.StringRULE_SEPARATORprivate org.apache.maven.execution.MavenSessionsessionprivate booleanstrictCompilerTargetIf set tofalse(the default) issue a warning if effective compiler target level is incompatible with bundle minimal execution environment.private org.apache.maven.toolchain.ToolchainManagerPrivatetoolChainManager(package private) ToolchainProvidertoolchainProviderprivate ToolchainProvider.JDKUsageuseJDKWhich JDK to use for compilation.private booleanuseProjectSettingsIf 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 voidcheckTargetLevelCompatibleWithManifestBREEs(java.lang.String effectiveTargetLevel, StandardExecutionEnvironment[] manifestBREEs)private voidconfigureBootClassPath(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration, org.apache.maven.toolchain.java.DefaultJavaToolChain javaToolChain)private voidconfigureBootclasspathAccessRules(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration)private voidconfigureCompilerLog(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration)private voidconfigureJavaHome(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration)private voidconfigureSourceAndTargetLevel(org.codehaus.plexus.compiler.CompilerConfiguration compilerConfiguration)private voiddoCopyResources()voidexecute()<T> TgetAdapter(java.lang.Class<T> adapter)private BundleProjectgetBundleProject()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.CompilerConfigurationgetCompilerConfiguration(java.util.List<java.lang.String> compileSourceRoots)protected java.util.List<java.lang.String>getCompileSourceRoots()EclipsePluginProjectgetEclipsePluginProject()public for testing purposesjava.lang.StringgetExecutionEnvironment()protected java.io.FilegetOutputDirectory()protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScannergetSourceInclusionScanner(int staleMillis)protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScannergetSourceInclusionScanner(java.lang.String inputFileEnding)java.lang.StringgetSourceLevel()private java.lang.StringgetSourceLevel(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 ExecutionEnvironmentgetTargetExecutionEnvironment()java.lang.StringgetTargetLevel()java.lang.StringgetTargetLevel(ExecutionEnvironment ee)private static java.lang.String[]getValues(org.codehaus.plexus.util.xml.Xpp3Dom[] doms)private java.lang.StringscanBootclasspath(java.lang.String javaHome, org.codehaus.plexus.util.xml.Xpp3Dom[] includes, org.codehaus.plexus.util.xml.Xpp3Dom excludeParent)private java.lang.StringtoString(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-RequiredExecutionEnvironmentis 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 totruewill 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}.falsemeans that no resources are copied from the source folders to${project.build.outputDirectory}. Set this tofalsein case you want to keep resources separate from java files insrc/main/resourcesand handle them using maven-resources-plugin (e.g. for resource filtering.
-
logDirectory
@Parameter(defaultValue="${project.build.directory}/compile-logs") private java.io.File logDirectoryThe 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 iflogis specified. Default:${project.build.directory}/compile-logs
-
log
@Parameter private java.lang.String log
The format of the compiler log file.plainwill log into a plain text file (.log),xmlwill 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:
executein interfaceorg.apache.maven.plugin.Mojo- Overrides:
executein classAbstractCompilerMojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.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:
getOutputDirectoryin classAbstractCompilerMojo
-
getClasspathElements
public java.util.List<java.lang.String> getClasspathElements() throws org.apache.maven.plugin.MojoExecutionException- Specified by:
getClasspathElementsin 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:
getCompileSourceRootsin classAbstractCompilerMojo- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getSourcepath
public java.util.List<SourcepathEntry> getSourcepath() throws org.apache.maven.plugin.MojoExecutionException
Description copied from interface:JavaCompilerConfigurationComputes and returns sourcepath of a Tycho eclipse-plugin or eclipse-test-plugin project.- Specified by:
getSourcepathin interfaceJavaCompilerConfiguration- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getSourceInclusionScanner
protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner getSourceInclusionScanner(int staleMillis)
- Specified by:
getSourceInclusionScannerin classAbstractCompilerMojo
-
getSourceInclusionScanner
protected org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner getSourceInclusionScanner(java.lang.String inputFileEnding)
- Specified by:
getSourceInclusionScannerin 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:
getCompilerConfigurationin classAbstractCompilerMojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.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:JavaCompilerConfigurationComputes and returns compile classpath of a Tycho eclipse-plugin or eclipse-test-plugin project.- Specified by:
getClasspathin interfaceJavaCompilerConfiguration- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getExecutionEnvironment
public java.lang.String getExecutionEnvironment() throws org.apache.maven.plugin.MojoExecutionException- Specified by:
getExecutionEnvironmentin interfaceJavaCompilerConfiguration- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getSourceLevel
public java.lang.String getSourceLevel() throws org.apache.maven.plugin.MojoExecutionException- Specified by:
getSourceLevelin 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:
getTargetLevelin 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:
getAdapterin interfaceAdaptable
-
-