-
Changes in Version 3.6.2 (2021-01-22)
Changes in Version 3.5.0 (2020-06-04)
Changes in Version 3.4.2 (2020-03-26)
Changes in Version 3.3.1 (2019-08-22)
Changes in Version 3.3.0 (2019-01-09)
Changes in Version 3.2.1 (2018-12-21)
Changes in Version 3.2.0 (2018-08-27)
Changes in Version 3.1.1 (2018-06-29)
Changes in Version 3.1.0 (2018-03-27)
Changes in Version 3.0.0 (2018-02-20)
feature-gen
The FeatureIDE project allows to create both feature model files as well as variant configuration files with an Eclipse plugin. The feature-gen project generates a Java API from the model files to be used in the application code. Although the FeatureIDE module supports already the creation of tapir features and variants from the FeatureIDE model files, a drawback is that the model files have to be contained in the same project as the annotated classes. This is the reason why we developed this module. It uses not the FeatureIDE model files to generate the tapir code, but rather the classes which are generated by feature-gen. This allows to use a single model for your features and generate code for both your application and your test code in a consistent way.
Dependency
<dependency>
<groupId>io.tapir-test</groupId>
<artifactId>tapir-extensions-featuregen</artifactId>
<version>1.3.0</version>
</dependency>
Features
To generate the features from your feature model, you can use the dynamic active annotation FeatureGenFeatures. Reference the enumeration generated from feature-gen and the annotation will generate all features. The following example assumes that your root feature is named Root and thus the enum generated from feature-gen is named RootFeature.
@FeatureGenFeatures(RootFeature)
class Features {
}
Per default the features get the suffixes Feature. You can change the prefixes and the suffixes of your features with the annotation properties prefix and suffix.
@FeatureGenFeatures(value=RootFeature, prefix='MyPrefix', suffix='MySuffix')
class Features {
}
As with all of tapir’s dynamic active annotations you can implement an own annotation processor if you need even more control. The default annotation processor is FeatureIDEFeaturesProcessor with an order of -10000.
Variants
To generate a variant from your variant model file, you can use the dynamic active annotation FeatureGenVariant. Reference the class annotated with FeatureIDEVariant and the class annotated with FeatureGenFeatures and the annotated class will be turned into a variant. All selected features are added to the variant. The following example assumes that the features class is named Features as in the above example and that the variant from your feature-gen module is named Variant1.
@FeatureGenVariant(featuresClass=Features, variantClass=Variant1)
class TapirVariant1 {
}
Per default the annotation uses the name of the annotated class as name for the variant. In order to change this behaviour, you can set the name in the annotation.
@FeatureGenVariant(featuresClass=Features, variantClass=Variant1, name='MyVariant')
class TapirVariant1 {
}
As with all of tapir’s dynamic active annotations you can implement an own annotation processor if you need even more control. The default annotation processor is FeatureGenVariantProcessor with an order of -10000.
- Previous
- Next