de.rhocas.featuregen:featuregen-generator

feature-gen is a small open-source framework that lets you generate typesafe feature checks from FeatureIDE models.

License

License

MIT
GroupId

GroupId

de.rhocas.featuregen
ArtifactId

ArtifactId

featuregen-generator
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

feature-gen is a small open-source framework that lets you generate typesafe feature checks from FeatureIDE models.
Source Code Management

Source Code Management

http://github.com/nils-christian/feature-gen/tree/master/featuregen-generator

Download featuregen-generator

How to add to project

<!-- https://jarcasting.com/artifacts/de.rhocas.featuregen/featuregen-generator/ -->
<dependency>
    <groupId>de.rhocas.featuregen</groupId>
    <artifactId>featuregen-generator</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/de.rhocas.featuregen/featuregen-generator/
implementation 'de.rhocas.featuregen:featuregen-generator:2.0.0'
// https://jarcasting.com/artifacts/de.rhocas.featuregen/featuregen-generator/
implementation ("de.rhocas.featuregen:featuregen-generator:2.0.0")
'de.rhocas.featuregen:featuregen-generator:jar:2.0.0'
<dependency org="de.rhocas.featuregen" name="featuregen-generator" rev="2.0.0">
  <artifact name="featuregen-generator" type="jar" />
</dependency>
@Grapes(
@Grab(group='de.rhocas.featuregen', module='featuregen-generator', version='2.0.0')
)
libraryDependencies += "de.rhocas.featuregen" % "featuregen-generator" % "2.0.0"
[de.rhocas.featuregen/featuregen-generator "2.0.0"]

Dependencies

compile (4)

Group / Artifact Type Version
de.rhocas.featuregen : featuregen-feature-ide-configuration-model jar 2.0.0
de.rhocas.featuregen : featuregen-feature-ide-feature-model jar 2.0.0
de.rhocas.featuregen : featuregen-lib jar 2.0.0
org.eclipse.xtend : org.eclipse.xtend.lib jar 2.14.0

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.hamcrest : hamcrest-all jar 1.3

Project Modules

There are no modules declared in this project.

logo Build Status Maven Central License: MIT

feature-gen

feature-gen is a small open-source framework that lets you generate typesafe feature checks from FeatureIDE models

How do I use it?

You can generate the features and variants either with the standalone generator or with the Xtend based active annotations. The standalone generator requires Java 8 and the annotation processor requires additionaly Xtend 2.14 or newer.

The Java API for both approaches is the same. Assuming your root feature is named Root, you can do the following:

RootFeatureCheckService featureCheckService = RootFeatureCheckService.of( Variant1.class );

if ( featureCheckService.isFeatureActive( RootFeature.MY_FEATURE ) ) {
   ...
}

Xtend Active Annotation

A simple example for the active annotations can be found here.

In order to use the active annotations from feature-gen in your project, you need to add the Maven dependencies to your project.

<dependency>
	<groupId>de.rhocas.featuregen</groupId>
	<artifactId>featuregen-annotation-processor</artifactId>
	<version>2.0.0</version>
</dependency>
<dependency>
	<groupId>de.rhocas.featuregen</groupId>
	<artifactId>featuregen-lib</artifactId>
	<version>2.0.0</version>
</dependency>

Once you have the dependency in your classpath, you can add classes with the annotations FeatureIDEFeatures and FeatureIDEVariant to your project. Both classes use Xtend's active annotations mechanism to generate the required classes and enums to check features from your feature model.

In its simplest form, you have your feature model in a file named model.xml next to your annotated class.

@FeatureIDEFeatures
class Features {   
}

Your annotated variant class has to reference the feature class. In the following case it is assumed that the variant configuration is in a file named Variant1.xml next to the annotated class.

@FeatureIDEVariant(featuresClass = Features)
class Variant1 { 
}

Now feature-gen generates everything to use the feature model in your application.

Standalone Generator

A simple example for the generator can be found here.

In order to use the standalone generator from feature-gen in your project, you need to add the Maven dependencies to your project.

<dependency>
	<groupId>de.rhocas.featuregen</groupId>
	<artifactId>featuregen-generator</artifactId>
	<version>2.0.0</version>
</dependency>
<dependency>
	<groupId>de.rhocas.featuregen</groupId>
	<artifactId>featuregen-lib</artifactId>
	<version>2.0.0</version>
</dependency>

Now you can call the classes FeatureIDEFeaturesGenerator and FeatureIDEVariantGenerator as Java applications and generate the features and variants from your models.

The FeatureIDEFeaturesGenerator requires at least three parameters: The path to the FeatureIDE feature model file, the path to the output folder, and the package name of the newly generated classes. Optionally you can also provide the prefix and suffix which are appended to each feature.

The FeatureIDEVariantGenerator requires at least six parameters: The path to the FeatureIDE configuration model file, the path to the feature model file, the path to the output folder, the package name of the newly generated variant, the simple class name of the new variant, and the package name of the features. Optionally you can also provide the prefix and suffix which are appended to each feature.

An easy way to include the generator in your IDE is to use the exec-maven-plugin. Please consult the Wiki for this.

Once you called the generators, feature-gen generates everything to use the feature model in your application.

License

feature-gen is licensed under the MIT-License. The complete license text can be found in the provided file LICENSE.

Versions

Version
2.0.0