de.rhocas.featuregen:featuregen-feature-ide-configuration-model

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

License

License

MIT
Categories

Categories

IDE Development Tools Configuration Application Layer Libs config
GroupId

GroupId

de.rhocas.featuregen
ArtifactId

ArtifactId

featuregen-feature-ide-configuration-model
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-feature-ide-configuration-model

Download featuregen-feature-ide-configuration-model

How to add to project

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

Dependencies

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
1.0.0