Class SourceFeatureMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="source-feature",
          defaultPhase=PACKAGE,
          threadSafe=true)
    public class SourceFeatureMojo
    extends org.apache.maven.plugin.AbstractMojo
    Generates a source feature for projects of packaging type eclipse-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.
    Source feature generation can be customized by adding files under path sourceTemplateFeature/. Files added here will be added to the root of the source feature jar. Especially, if file sourceTemplateFeature/feature.properties is found, values in this file override values of respective keys in <originalFeature>/feature.properties.
    • 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
      • 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.
      • includeBinaryFeature

        @Parameter(defaultValue="true")
        private boolean includeBinaryFeature
        Whether to add an include dependency from the source feature to the corresponding binary feature. If true, 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 in sourceTemplateFeature/feature.properties, this suffix will be appended to the original feature label to construct the source feature label.
      • 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
      • logger

        @Component
        private org.codehaus.plexus.logging.Logger logger
    • Constructor Detail

      • SourceFeatureMojo

        public SourceFeatureMojo()
    • 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
      • 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
      • toStrictVersionRange

        protected java.lang.String toStrictVersionRange​(java.lang.String version)
      • 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.