Package org.eclipse.tycho.source
Class SourceFeatureMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.eclipse.tycho.source.SourceFeatureMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="feature-source", defaultPhase=PACKAGE, threadSafe=true) public class SourceFeatureMojo extends org.apache.maven.plugin.AbstractMojo
Generates a source feature for projects of packaging typeeclipse-feature
. By default, the generated source feature- Declares feature id
<originalFeatureId>.source
- Declares feature label
"<originalFeatureLabel> Developer Resources"
- If present, reuses feature provider, description, copyright and license as well as respective URLs from <originalFeature>
- Includes all plugins included by <originalFeature>, but each with
.source
appended to each plugin id - Includes all features included by <originalFeature>, but each with
.source
appended to each feature id - Includes the original feature. This ensures that binaries and corresponding sources match.
sourceTemplateFeature/
. Files added here will be added to the root of the source feature jar. Especially, if filesourceTemplateFeature/feature.properties
is found, values in this file override values of respective keys in<originalFeature>/feature.properties
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SourceFeatureMojo.MissingSourcesAction
-
Field Summary
Fields Modifier and Type Field Description private org.apache.maven.archiver.MavenArchiveConfiguration
archive
private java.lang.String
brandingPlugin
Use this to explicitly set the branding plugin attribute of the generated source feature (overridesreuseBrandingPlugin
).private BuildPropertiesParser
buildPropertiesParser
private EquinoxServiceFactory
equinox
private java.util.Set<java.lang.String>
excludedFeatures
private java.util.Set<java.lang.String>
excludedPlugins
private org.codehaus.plexus.configuration.PlexusConfiguration
excludes
Bundles and features that do not have corresponding sources.private java.util.Set<PluginRef>
extraPlugins
private static java.lang.String
FEATURE_PROPERTIES
static java.lang.String
FEATURE_TEMPLATE_DIR
private java.lang.String
finalName
The filename to be used for the generated archive file.private static java.lang.String
GEN_DIR
private boolean
includeBinaryFeature
Whether to add an include dependency from the source feature to the corresponding binary feature.private org.codehaus.plexus.archiver.jar.JarArchiver
jarArchiver
private java.lang.String
labelSuffix
Source feature label suffix.private LicenseFeatureHelper
licenseFeatureHelper
private static java.lang.Object
LOCK
Lock object to ensure thread-safetyprivate org.codehaus.plexus.logging.Logger
logger
private SourceFeatureMojo.MissingSourcesAction
missingSourcesAction
private org.codehaus.plexus.configuration.PlexusConfiguration
plugins
Additional plugins to include in the generated source feature.private org.apache.maven.project.MavenProject
project
private org.apache.maven.project.MavenProjectHelper
projectHelper
private boolean
reuseBrandingPlugin
Whether to reuse an explicit branding plugin from the binary feature for the generated source feature.private org.apache.maven.execution.MavenSession
session
private boolean
skip
Whether to skip source feature generation.static java.lang.String
SOURCES_FEATURE_CLASSIFIER
protected boolean
useDefaultExcludes
-
Constructor Summary
Constructors Constructor Description SourceFeatureMojo()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addPlugin(Feature sourceFeature, P2ResolutionResult result, PluginRef pluginRef)
(package private) Feature
createSourceFeatureSkeleton(Feature feature, java.util.Properties mergedFeatureProperties, java.util.Properties sourceTemplateProperties)
This only create the new feature skeleton by setting labels and other not-structural values that don't require platform resolution.void
execute()
private void
fillReferences(Feature sourceFeature, Feature feature, TargetPlatform targetPlatform)
Added all references to sourceFeature, as deduced by feature and resolved by targetPlatformprivate java.io.File
generateSourceFeatureXml(java.util.Properties mergedSourceFeatureProps, java.util.Properties sourceTemplateProps)
private java.lang.String
getAttribute(org.codehaus.plexus.configuration.PlexusConfiguration dom, java.lang.String attrName)
protected org.codehaus.plexus.archiver.FileSet
getFileSet(java.io.File basedir, java.util.List<java.lang.String> includes, java.util.List<java.lang.String> excludes)
private org.codehaus.plexus.archiver.FileSet
getManuallyIncludedFiles(java.io.File basedir, BuildProperties buildProperties)
private java.io.File
getMergedSourceFeaturePropertiesFile()
protected java.io.File
getOutputJarFile()
(package private) static java.io.File
getSourcesFeatureOutputDir(org.apache.maven.project.MavenProject project)
protected boolean
isP2GenerationEnabled()
private java.util.Properties
mergeFeatureProperties(java.util.Properties sourceFeatureTemplateProps)
private static java.util.Properties
readPropertiesIfExists(java.io.File propertiesFile)
private java.util.Properties
readSourceTemplateFeatureProperties()
private void
reportMissing(java.lang.String msg, java.util.List<?> missing)
void
setExcludes(org.codehaus.plexus.configuration.PlexusConfiguration excludes)
void
setPlugins(org.codehaus.plexus.configuration.PlexusConfiguration bundles)
protected java.lang.String
toStrictVersionRange(java.lang.String version)
private static java.lang.String
validateValue(java.lang.String fieldValue, java.util.Properties sourceFeatureProperties)
Returns the value for a field.private static void
writeProperties(java.util.Properties props, java.io.File propertiesFile)
-
-
-
Field Detail
-
LOCK
private static final java.lang.Object LOCK
Lock object to ensure thread-safety
-
FEATURE_TEMPLATE_DIR
public static final java.lang.String FEATURE_TEMPLATE_DIR
- See Also:
- Constant Field Values
-
SOURCES_FEATURE_CLASSIFIER
public static final java.lang.String SOURCES_FEATURE_CLASSIFIER
- See Also:
- Constant Field Values
-
FEATURE_PROPERTIES
private static final java.lang.String FEATURE_PROPERTIES
- See Also:
- Constant Field Values
-
GEN_DIR
private static final java.lang.String GEN_DIR
- See Also:
- Constant Field Values
-
project
@Parameter(property="project", readonly=true) private org.apache.maven.project.MavenProject project
-
skip
@Parameter(defaultValue="false") private boolean skip
Whether to skip source feature generation.
-
missingSourcesAction
@Parameter(defaultValue="WARN") private SourceFeatureMojo.MissingSourcesAction missingSourcesAction
-
includeBinaryFeature
@Parameter(defaultValue="true") private boolean includeBinaryFeature
Whether to add an include dependency from the source feature to the corresponding binary feature. Iftrue
, this ensures the version of the installed sources matches the binaries.
-
labelSuffix
@Parameter(defaultValue=" Developer Resources") private java.lang.String labelSuffix
Source feature label suffix. Unless explicitly provided insourceTemplateFeature/feature.properties
, this suffix will be appended to the original feature label to construct the source feature label.
-
brandingPlugin
@Parameter private java.lang.String brandingPlugin
Use this to explicitly set the branding plugin attribute of the generated source feature (overridesreuseBrandingPlugin
).
-
reuseBrandingPlugin
@Parameter(defaultValue="true") private boolean reuseBrandingPlugin
Whether to reuse an explicit branding plugin from the binary feature for the generated source feature.
-
excludes
@Parameter private org.codehaus.plexus.configuration.PlexusConfiguration excludes
Bundles and features that do not have corresponding sources. Example:<excludes> <plugin id="plugin.nosource"/> <feature id="feature.nosource"/> </excludes>
-
plugins
@Parameter private org.codehaus.plexus.configuration.PlexusConfiguration plugins
Additional plugins to include in the generated source feature. Beware that these additional plugins are not considered during build target platform calculation and ordering of reactor projects. Use <extraRequirements> dependency resolver configuration to guarantee proper reactor build order.WARNING This experimental parameter may be removed from future source-feature mojo versions without prior notice.
-
useDefaultExcludes
@Parameter(defaultValue="true") protected boolean useDefaultExcludes
-
session
@Parameter(property="session", readonly=true) private org.apache.maven.execution.MavenSession session
-
excludedPlugins
private final java.util.Set<java.lang.String> excludedPlugins
-
excludedFeatures
private final java.util.Set<java.lang.String> excludedFeatures
-
extraPlugins
private final java.util.Set<PluginRef> extraPlugins
-
archive
@Parameter private org.apache.maven.archiver.MavenArchiveConfiguration archive
-
finalName
@Parameter(property="project.build.finalName") private java.lang.String finalName
The filename to be used for the generated archive file. For the source-feature goal, "-sources-feature" is appended to this filename.
-
jarArchiver
@Component(role=org.codehaus.plexus.archiver.Archiver.class, hint="jar") private org.codehaus.plexus.archiver.jar.JarArchiver jarArchiver
-
projectHelper
@Component private org.apache.maven.project.MavenProjectHelper projectHelper
-
licenseFeatureHelper
@Component private LicenseFeatureHelper licenseFeatureHelper
-
buildPropertiesParser
@Component private BuildPropertiesParser buildPropertiesParser
-
equinox
@Component private EquinoxServiceFactory equinox
-
logger
@Component private org.codehaus.plexus.logging.Logger logger
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
isP2GenerationEnabled
protected boolean isP2GenerationEnabled()
-
getSourcesFeatureOutputDir
static java.io.File getSourcesFeatureOutputDir(org.apache.maven.project.MavenProject project)
-
mergeFeatureProperties
private java.util.Properties mergeFeatureProperties(java.util.Properties sourceFeatureTemplateProps) throws java.io.IOException
- Throws:
java.io.IOException
-
readSourceTemplateFeatureProperties
private java.util.Properties readSourceTemplateFeatureProperties() throws java.io.IOException
- Throws:
java.io.IOException
-
generateSourceFeatureXml
private java.io.File generateSourceFeatureXml(java.util.Properties mergedSourceFeatureProps, java.util.Properties sourceTemplateProps) throws java.io.IOException, org.apache.maven.plugin.MojoExecutionException
- Throws:
java.io.IOException
org.apache.maven.plugin.MojoExecutionException
-
getMergedSourceFeaturePropertiesFile
private java.io.File getMergedSourceFeaturePropertiesFile()
-
readPropertiesIfExists
private static java.util.Properties readPropertiesIfExists(java.io.File propertiesFile) throws java.io.IOException
- Throws:
java.io.IOException
-
writeProperties
private static void writeProperties(java.util.Properties props, java.io.File propertiesFile) throws java.io.IOException
- Throws:
java.io.IOException
-
createSourceFeatureSkeleton
Feature createSourceFeatureSkeleton(Feature feature, java.util.Properties mergedFeatureProperties, java.util.Properties sourceTemplateProperties) throws java.io.IOException, org.apache.maven.plugin.MojoExecutionException
This only create the new feature skeleton by setting labels and other not-structural values that don't require platform resolution.- Throws:
java.io.IOException
org.apache.maven.plugin.MojoExecutionException
-
validateValue
private static java.lang.String validateValue(java.lang.String fieldValue, java.util.Properties sourceFeatureProperties) throws org.apache.maven.plugin.MojoExecutionException
Returns the value for a field. In case the value is a reference to feature.properties, verify that the entry exist in the feature.properties file for source- Parameters:
fieldValue
-sourceFeatureProperties
-- Returns:
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
fillReferences
private void fillReferences(Feature sourceFeature, Feature feature, TargetPlatform targetPlatform) throws org.apache.maven.plugin.MojoExecutionException
Added all references to sourceFeature, as deduced by feature and resolved by targetPlatform- Parameters:
sourceFeature
-feature
-targetPlatform
-- Throws:
org.apache.maven.plugin.MojoExecutionException
-
reportMissing
private void reportMissing(java.lang.String msg, java.util.List<?> missing)
-
toStrictVersionRange
protected java.lang.String toStrictVersionRange(java.lang.String version)
-
addPlugin
protected void addPlugin(Feature sourceFeature, P2ResolutionResult result, PluginRef pluginRef)
-
getOutputJarFile
protected java.io.File getOutputJarFile()
-
setExcludes
public void setExcludes(org.codehaus.plexus.configuration.PlexusConfiguration excludes)
-
setPlugins
public void setPlugins(org.codehaus.plexus.configuration.PlexusConfiguration bundles)
-
getAttribute
private java.lang.String getAttribute(org.codehaus.plexus.configuration.PlexusConfiguration dom, java.lang.String attrName)
-
getManuallyIncludedFiles
private org.codehaus.plexus.archiver.FileSet getManuallyIncludedFiles(java.io.File basedir, BuildProperties buildProperties)
- Returns:
- A
FileSet
including files as configured by the src.includes and src.excludes properties without the files that are always included automatically.
-
getFileSet
protected org.codehaus.plexus.archiver.FileSet getFileSet(java.io.File basedir, java.util.List<java.lang.String> includes, java.util.List<java.lang.String> excludes)
- Returns:
- a
FileSet
with the given includes and excludes and the configured default excludes. An empty list of includes leads to an empty file set.
-
-