You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2016/09/24 15:19:52 UTC
[30/33] maven git commit: [MNG-6056] Implement Feature Toggle Module
to handle Feature Toggles o Implemented feature toggle module plus command
line options etc. to activate feature and list available feature toggles. o
Added example feature locatio
[MNG-6056] Implement Feature Toggle Module to handle Feature Toggles
o Implemented feature toggle module plus command line options
etc. to activate feature and list available feature toggles.
o Added example feature locations which should be removed before
really using it.
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/1b3edccd
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/1b3edccd
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/1b3edccd
Branch: refs/heads/MNG-6056-feature-toggle
Commit: 1b3edccd04189bed02cbd50ec47496829cccbf98
Parents: 9f2452a
Author: Karl Heinz Marbaise <kh...@apache.org>
Authored: Sat Jul 2 22:47:46 2016 +0200
Committer: Karl Heinz Marbaise <kh...@apache.org>
Committed: Fri Aug 12 22:50:47 2016 +0200
----------------------------------------------------------------------
maven-core/pom.xml | 4 +
.../java/org/apache/maven/DefaultMaven.java | 16 ++
.../apache/maven/graph/DefaultGraphBuilder.java | 10 +
maven-embedder/pom.xml | 4 +
.../java/org/apache/maven/cli/CLIManager.java | 6 +
.../java/org/apache/maven/cli/MavenCli.java | 234 +++++++++++++------
.../java/org/apache/maven/cli/MavenCliTest.java | 1 +
maven-feature/pom.xml | 62 +++++
.../maven/feature/AvailableFeatureToggles.java | 102 ++++++++
.../maven/feature/DefaultFeatureToggles.java | 82 +++++++
.../apache/maven/feature/FeatureToggles.java | 65 ++++++
.../feature/AvailableFeatureTogglesTest.java | 52 +++++
.../feature/DefaultSelectedFeaturesTest.java | 79 +++++++
pom.xml | 6 +
14 files changed, 649 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/1b3edccd/maven-core/pom.xml
----------------------------------------------------------------------
diff --git a/maven-core/pom.xml b/maven-core/pom.xml
index adf63a6..ec35f98 100644
--- a/maven-core/pom.xml
+++ b/maven-core/pom.xml
@@ -38,6 +38,10 @@ under the License.
</properties>
<dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-feature</artifactId>
+ </dependency>
<!-- Maven -->
<dependency>
<groupId>org.apache.maven</groupId>
http://git-wip-us.apache.org/repos/asf/maven/blob/1b3edccd/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
index da17830..f4090d6 100644
--- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
+++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
@@ -38,6 +38,8 @@ import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.ProjectDependencyGraph;
+import org.apache.maven.feature.AvailableFeatureToggles;
+import org.apache.maven.feature.FeatureToggles;
import org.apache.maven.graph.GraphBuilder;
import org.apache.maven.internal.aether.DefaultRepositorySystemSessionFactory;
import org.apache.maven.lifecycle.internal.ExecutionEventCatapult;
@@ -92,6 +94,9 @@ public class DefaultMaven
@Requirement
private DefaultRepositorySystemSessionFactory repositorySessionFactory;
+
+ @Requirement
+ private FeatureToggles selectedFeatures;
@Requirement( hint = GraphBuilder.HINT )
private GraphBuilder graphBuilder;
@@ -101,6 +106,17 @@ public class DefaultMaven
{
MavenExecutionResult result;
+ List<AvailableFeatureToggles> activatedFeatures = selectedFeatures.getActiveFeatureToggles();
+ if ( !activatedFeatures.isEmpty() )
+ {
+ logger.debug( "-------------------------------------------" );
+ for ( AvailableFeatureToggles feature : activatedFeatures )
+ {
+ logger.debug( "Feature: " + feature.name() + " has been activated by user request.");
+ }
+ logger.debug( "-------------------------------------------" );
+ }
+
try
{
result = doExecute( request );
http://git-wip-us.apache.org/repos/asf/maven/blob/1b3edccd/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java b/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
index 680d584..a41f6ba 100644
--- a/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
+++ b/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
@@ -36,6 +36,8 @@ import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.ProjectDependencyGraph;
+import org.apache.maven.feature.AvailableFeatureToggles;
+import org.apache.maven.feature.FeatureToggles;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.building.DefaultModelProblem;
import org.apache.maven.model.building.ModelProblem;
@@ -65,6 +67,10 @@ public class DefaultGraphBuilder
@Requirement
protected ProjectBuilder projectBuilder;
+
+ @Requirement
+ private FeatureToggles selectedFeatures;
+
@Override
public Result<ProjectDependencyGraph> build( MavenSession session )
@@ -74,6 +80,10 @@ public class DefaultGraphBuilder
return dependencyGraph( session, session.getProjects(), false );
}
+ if (selectedFeatures.isToggleActive( AvailableFeatureToggles.MNG10000 )) {
+ logger.info( " -> Features MNG 10000 is activated." );
+ }
+
List<MavenProject> projects = session.getProjects();
if ( projects == null )
http://git-wip-us.apache.org/repos/asf/maven/blob/1b3edccd/maven-embedder/pom.xml
----------------------------------------------------------------------
diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml
index f9973c5..12fb613 100644
--- a/maven-embedder/pom.xml
+++ b/maven-embedder/pom.xml
@@ -36,6 +36,10 @@ under the License.
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
+ <artifactId>maven-feature</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
<artifactId>maven-builder-support</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/maven/blob/1b3edccd/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
index f86f48b..a2cc344 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
@@ -100,6 +100,10 @@ public class CLIManager
public static final String LEGACY_LOCAL_REPOSITORY = "llr";
public static final String BUILDER = "b";
+
+ public static final String LIST_FEATURES = "lf";
+
+ public static final String ACTIVATE_FEATURES = "af";
protected Options options;
@@ -140,6 +144,8 @@ public class CLIManager
options.addOption( OptionBuilder.withLongOpt( "threads" ).hasArg().withDescription( "Thread count, for instance 2.0C where C is core multiplied" ).create( THREADS ) );
options.addOption( OptionBuilder.withLongOpt( "legacy-local-repository" ).withDescription( "Use Maven 2 Legacy Local Repository behaviour, ie no use of _remote.repositories. Can also be activated by using -Dmaven.legacyLocalRepo=true" ).create( LEGACY_LOCAL_REPOSITORY ) );
options.addOption( OptionBuilder.withLongOpt( "builder" ).hasArg().withDescription( "The id of the build strategy to use" ).create( BUILDER ) );
+ options.addOption( OptionBuilder.withLongOpt( "list-features" ).withDescription( "List the exiting features which can be activated." ).create( LIST_FEATURES) );
+ options.addOption( OptionBuilder.withLongOpt( "activate-features" ).withDescription( "Comma-delimited list of features to be actived." ).hasArg().create( ACTIVATE_FEATURES ) );
// Adding this back in for compatibility with the verifier that hard codes this option.
options.addOption( OptionBuilder.withLongOpt( "no-plugin-registry" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "npr" ) );
http://git-wip-us.apache.org/repos/asf/maven/blob/1b3edccd/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
index 822f696..1b230df 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -41,10 +41,12 @@ import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
+
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.UnrecognizedOptionException;
import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.text.WordUtils;
import org.apache.maven.BuildAbort;
import org.apache.maven.InternalErrorException;
import org.apache.maven.Maven;
@@ -79,6 +81,8 @@ import org.apache.maven.execution.MavenExecutionRequestPopulator;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.extension.internal.CoreExports;
import org.apache.maven.extension.internal.CoreExtensionEntry;
+import org.apache.maven.feature.AvailableFeatureToggles;
+import org.apache.maven.feature.FeatureToggles;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.model.Profile;
import org.apache.maven.model.Repository;
@@ -105,13 +109,11 @@ import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.classworlds.ClassWorld;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
+import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.LoggerManager;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
-import com.google.inject.AbstractModule;
import org.eclipse.aether.transfer.TransferListener;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
@@ -122,6 +124,11 @@ import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher;
import org.sonatype.plexus.components.sec.dispatcher.SecUtil;
import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity;
+import com.google.common.base.Charsets;
+import com.google.common.base.Splitter;
+import com.google.common.io.Files;
+import com.google.inject.AbstractModule;
+
// TODO: push all common bits back to plexus cli and prepare for transition to Guice. We don't need 50 ways to make CLIs
/**
@@ -187,6 +194,9 @@ public class MavenCli
private Map<String, ConfigurationProcessor> configurationProcessors;
private ProfileSelector profileSelector;
+
+ @Requirement
+ private FeatureToggles featureToggles;
public MavenCli()
{
@@ -228,8 +238,8 @@ public class MavenCli
}
/**
- * This supports painless invocation by the Verifier during embedded execution of the core ITs.
- * See <a href="http://maven.apache.org/shared/maven-verifier/xref/org/apache/maven/it/Embedded3xLauncher.html">
+ * This supports painless invocation by the Verifier during embedded execution of the core ITs. See
+ * <a href="http://maven.apache.org/shared/maven-verifier/xref/org/apache/maven/it/Embedded3xLauncher.html">
* <code>Embedded3xLauncher</code> in <code>maven-verifier</code></a>
*/
public int doMain( String[] args, String workingDirectory, PrintStream stdout, PrintStream stderr )
@@ -356,8 +366,7 @@ public class MavenCli
String basedirProperty = System.getProperty( MULTIMODULE_PROJECT_DIRECTORY );
if ( basedirProperty == null )
{
- System.err.format(
- "-D%s system property is not set.", MULTIMODULE_PROJECT_DIRECTORY );
+ System.err.format( "-D%s system property is not set.", MULTIMODULE_PROJECT_DIRECTORY );
throw new ExitException( 1 );
}
File basedir = basedirProperty != null ? new File( basedirProperty ) : new File( "" );
@@ -448,6 +457,48 @@ public class MavenCli
System.out.println( CLIReportingUtils.showVersion() );
throw new ExitException( 0 );
}
+
+ if ( cliRequest.commandLine.hasOption( CLIManager.LIST_FEATURES ) )
+ {
+ AvailableFeatureToggles[] availableFeatures = AvailableFeatureToggles.getAvailableFeatureToggles();
+
+ if ( availableFeatures.length > 0 )
+ {
+ System.out.println( "" );
+ System.out.println( "Currently existing feature toggles which you can enable:" );
+ System.out.println( "" );
+ System.out.println( "Issue Option Description" );
+ System.out.println( "--------- -------- ----------------------------------------------------" );
+ for ( AvailableFeatureToggles feature : availableFeatures )
+ {
+ String wrappedString = WordUtils.wrap( feature.getDescription(), 60 );
+ List<String> splitToList = Splitter.on( System.lineSeparator() ).splitToList( wrappedString );
+ for ( int i = 0; i < splitToList.size(); i++ )
+ {
+ if ( i == 0 )
+ {
+ System.out.print( String.format( "%-9s %-8s", feature.getIssue(), feature.name() ) + " " );
+ }
+ else
+ {
+ System.out.print( String.format( "%-9s %-8s", "", "" ) + " " );
+ }
+ System.out.println( splitToList.get( i ) );
+ }
+ }
+
+ System.out.println( "" );
+ System.out.println( "If you like to know more about a particular issue please visit: issues.apache.org/jira/browse/[ISSUE]" );
+ throw new ExitException( 0 );
+ }
+ else
+ {
+ System.out.println( "" );
+ System.out.println( "There are no feature toggles available." );
+ throw new ExitException( 0 );
+
+ }
+ }
}
/**
@@ -582,9 +633,8 @@ public class MavenCli
ClassRealm containerRealm = setupContainerRealm( cliRequest.classWorld, coreRealm, extClassPath, extensions );
- ContainerConfiguration cc = new DefaultContainerConfiguration().setClassWorld( cliRequest.classWorld ).setRealm(
- containerRealm ).setClassPathScanning( PlexusConstants.SCANNING_INDEX ).setAutoWiring( true ).setName(
- "maven" );
+ ContainerConfiguration cc =
+ new DefaultContainerConfiguration().setClassWorld( cliRequest.classWorld ).setRealm( containerRealm ).setClassPathScanning( PlexusConstants.SCANNING_INDEX ).setAutoWiring( true ).setName( "maven" );
Set<String> exportedArtifacts = new HashSet<>( coreEntry.getExportedArtifacts() );
Set<String> exportedPackages = new HashSet<>( coreEntry.getExportedPackages() );
@@ -622,6 +672,10 @@ public class MavenCli
Thread.currentThread().setContextClassLoader( container.getContainerRealm() );
+ //Explicitly startup lookup for the component, cause it's used during command line
+ //parsing etc.
+ featureToggles = container.lookup( FeatureToggles.class );
+
eventSpyDispatcher = container.lookup( EventSpyDispatcher.class );
DefaultEventSpyContext eventSpyContext = new DefaultEventSpyContext();
@@ -676,11 +730,11 @@ public class MavenCli
}
ContainerConfiguration cc = new DefaultContainerConfiguration() //
- .setClassWorld( cliRequest.classWorld ) //
- .setRealm( containerRealm ) //
- .setClassPathScanning( PlexusConstants.SCANNING_INDEX ) //
- .setAutoWiring( true ) //
- .setName( "maven" );
+ .setClassWorld( cliRequest.classWorld ) //
+ .setRealm( containerRealm ) //
+ .setClassPathScanning( PlexusConstants.SCANNING_INDEX ) //
+ .setAutoWiring( true ) //
+ .setName( "maven" );
DefaultPlexusContainer container = new DefaultPlexusContainer( cc, new AbstractModule()
{
@@ -746,7 +800,7 @@ public class MavenCli
{
CoreExtensionsXpp3Reader parser = new CoreExtensionsXpp3Reader();
- try ( InputStream is = new BufferedInputStream( new FileInputStream( extensionsFile ) ) )
+ try (InputStream is = new BufferedInputStream( new FileInputStream( extensionsFile ) ))
{
return parser.read( is ).getExtensions();
@@ -756,7 +810,7 @@ public class MavenCli
private ClassRealm setupContainerRealm( ClassWorld classWorld, ClassRealm coreRealm, List<File> extClassPath,
List<CoreExtensionEntry> extensions )
- throws Exception
+ throws Exception
{
if ( !extClassPath.isEmpty() || !extensions.isEmpty() )
{
@@ -852,8 +906,8 @@ public class MavenCli
DefaultPlexusCipher cipher = new DefaultPlexusCipher();
- System.out.println(
- cipher.encryptAndDecorate( passwd, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ) );
+ System.out.println( cipher.encryptAndDecorate( passwd,
+ DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ) );
throw new ExitException( 0 );
}
@@ -909,7 +963,7 @@ public class MavenCli
throws Exception
{
if ( cliRequest.commandLine.hasOption( CLIManager.LEGACY_LOCAL_REPOSITORY )
- || Boolean.getBoolean( "maven.legacyLocalRepo" ) )
+ || Boolean.getBoolean( "maven.legacyLocalRepo" ) )
{
cliRequest.request.setUseLegacyLocalRepository( true );
}
@@ -928,9 +982,8 @@ public class MavenCli
profileActivationContext.setInactiveProfileIds( request.getInactiveProfiles() );
profileActivationContext.setSystemProperties( request.getSystemProperties() );
profileActivationContext.setUserProperties( request.getUserProperties() );
- profileActivationContext.setProjectDirectory( request.getPom() != null
- ? request.getPom().getParentFile()
- : null );
+ profileActivationContext.setProjectDirectory( request.getPom() != null ? request.getPom().getParentFile()
+ : null );
final List<ModelProblem> modelProblems = new ArrayList<>();
final List<Profile> activeProfiles =
@@ -941,10 +994,12 @@ public class MavenCli
@Override
public void add( final ModelProblemCollectorRequest req )
{
- modelProblems.add( new DefaultModelProblem(
- req.getMessage(), req.getSeverity(),
- req.getVersion(), Profile.SOURCE_SETTINGS, -1, -1,
- null, req.getException() ) );
+ modelProblems.add( new DefaultModelProblem( req.getMessage(),
+ req.getSeverity(),
+ req.getVersion(),
+ Profile.SOURCE_SETTINGS,
+ -1, -1, null,
+ req.getException() ) );
}
@@ -973,14 +1028,14 @@ public class MavenCli
{
try
{
- request.addRemoteRepository(
- MavenRepositorySystem.buildArtifactRepository( remoteRepository ) );
+ request.addRemoteRepository( MavenRepositorySystem.buildArtifactRepository( remoteRepository ) );
}
catch ( final InvalidRepositoryException e )
{
slf4jLogger.warn( String.format( "Failure adding repository '%s' from profile '%s'.",
- remoteRepository.getId(), profile.getId() ), e );
+ remoteRepository.getId(), profile.getId() ),
+ e );
}
}
@@ -991,14 +1046,14 @@ public class MavenCli
{
try
{
- request.addPluginArtifactRepository(
- MavenRepositorySystem.buildArtifactRepository( pluginRepository ) );
+ request.addPluginArtifactRepository( MavenRepositorySystem.buildArtifactRepository( pluginRepository ) );
}
catch ( InvalidRepositoryException e )
{
slf4jLogger.warn( String.format( "Failure adding plugin repository '%s' from profile '%s'.",
- pluginRepository.getId(), profile.getId() ), e );
+ pluginRepository.getId(), profile.getId() ),
+ e );
}
}
@@ -1056,7 +1111,7 @@ public class MavenCli
{
slf4jLogger.error( "" );
slf4jLogger.error( "For more information about the errors and possible solutions"
- + ", please read the following articles:" );
+ + ", please read the following articles:" );
for ( Map.Entry<String, String> entry : references.entrySet() )
{
@@ -1068,8 +1123,7 @@ public class MavenCli
{
slf4jLogger.error( "" );
slf4jLogger.error( "After correcting the problems, you can resume the build with the command" );
- slf4jLogger.error( buffer().a( " " ).strong( "mvn <goals> -rf :"
- + project.getArtifactId() ).toString() );
+ slf4jLogger.error( buffer().strong().a( " mvn <goals> -rf :" ).a( project.getArtifactId() ).reset().toString() );
}
if ( MavenExecutionRequest.REACTOR_FAIL_NEVER.equals( cliRequest.request.getReactorFailureBehavior() ) )
@@ -1124,8 +1178,8 @@ public class MavenCli
{
String line = indent + lines[i].trim();
- if ( ( i == lines.length - 1 ) && ( showErrors
- || ( summary.getException() instanceof InternalErrorException ) ) )
+ if ( ( i == lines.length - 1 )
+ && ( showErrors || ( summary.getException() instanceof InternalErrorException ) ) )
{
slf4jLogger.error( line, summary.getException() );
}
@@ -1192,9 +1246,9 @@ public class MavenCli
//
// There are too many ConfigurationProcessors so we don't know which one to run so report the error.
//
- StringBuilder sb = new StringBuilder(
- String.format( "\nThere can only be one user supplied ConfigurationProcessor, there are %s:\n\n",
- userSuppliedConfigurationProcessorCount ) );
+ StringBuilder sb =
+ new StringBuilder( String.format( "\nThere can only be one user supplied ConfigurationProcessor, there are %s:\n\n",
+ userSuppliedConfigurationProcessorCount ) );
for ( Entry<String, ConfigurationProcessor> entry : configurationProcessors.entrySet() )
{
String hint = entry.getKey();
@@ -1223,8 +1277,8 @@ public class MavenCli
if ( !userToolchainsFile.isFile() )
{
- throw new FileNotFoundException(
- "The specified user toolchains file does not exist: " + userToolchainsFile );
+ throw new FileNotFoundException( "The specified user toolchains file does not exist: "
+ + userToolchainsFile );
}
}
else
@@ -1242,8 +1296,8 @@ public class MavenCli
if ( !globalToolchainsFile.isFile() )
{
- throw new FileNotFoundException(
- "The specified global toolchains file does not exist: " + globalToolchainsFile );
+ throw new FileNotFoundException( "The specified global toolchains file does not exist: "
+ + globalToolchainsFile );
}
}
else
@@ -1266,11 +1320,10 @@ public class MavenCli
eventSpyDispatcher.onEvent( toolchainsRequest );
- slf4jLogger.debug(
- "Reading global toolchains from " + getLocation( toolchainsRequest.getGlobalToolchainsSource(),
- globalToolchainsFile ) );
- slf4jLogger.debug( "Reading user toolchains from " + getLocation( toolchainsRequest.getUserToolchainsSource(),
- userToolchainsFile ) );
+ slf4jLogger.debug( "Reading global toolchains from "
+ + getLocation( toolchainsRequest.getGlobalToolchainsSource(), globalToolchainsFile ) );
+ slf4jLogger.debug( "Reading user toolchains from "
+ + getLocation( toolchainsRequest.getUserToolchainsSource(), userToolchainsFile ) );
ToolchainsBuildingResult toolchainsResult = toolchainsBuilder.build( toolchainsRequest );
@@ -1320,7 +1373,7 @@ public class MavenCli
if ( commandLine.hasOption( deprecatedOption ) )
{
slf4jLogger.warn( "Command line option -" + deprecatedOption
- + " is deprecated and will be removed in future Maven versions." );
+ + " is deprecated and will be removed in future Maven versions." );
}
}
@@ -1474,19 +1527,20 @@ public class MavenCli
userToolchainsFile = MavenCli.DEFAULT_USER_TOOLCHAINS_FILE;
}
- request.setBaseDirectory( baseDirectory ).setGoals( goals ).setSystemProperties(
- cliRequest.systemProperties ).setUserProperties( cliRequest.userProperties ).setReactorFailureBehavior(
- reactorFailureBehaviour ) // default: fail fast
- .setRecursive( recursive ) // default: true
- .setShowErrors( showErrors ) // default: false
- .addActiveProfiles( activeProfiles ) // optional
- .addInactiveProfiles( inactiveProfiles ) // optional
- .setExecutionListener( executionListener ).setTransferListener(
- transferListener ) // default: batch mode which goes along with interactive
- .setUpdateSnapshots( updateSnapshots ) // default: false
- .setNoSnapshotUpdates( noSnapshotUpdates ) // default: false
- .setGlobalChecksumPolicy( globalChecksumPolicy ) // default: warn
- .setMultiModuleProjectDirectory( cliRequest.multiModuleProjectDirectory );
+ request.setBaseDirectory( baseDirectory ).setGoals( goals ).setSystemProperties( cliRequest.systemProperties ).setUserProperties( cliRequest.userProperties ).setReactorFailureBehavior( reactorFailureBehaviour ) // default:
+ // fail
+ // fast
+ .setRecursive( recursive ) // default: true
+ .setShowErrors( showErrors ) // default: false
+ .addActiveProfiles( activeProfiles ) // optional
+ .addInactiveProfiles( inactiveProfiles ) // optional
+ .setExecutionListener( executionListener ).setTransferListener( transferListener ) // default: batch mode which
+ // goes along with
+ // interactive
+ .setUpdateSnapshots( updateSnapshots ) // default: false
+ .setNoSnapshotUpdates( noSnapshotUpdates ) // default: false
+ .setGlobalChecksumPolicy( globalChecksumPolicy ) // default: warn
+ .setMultiModuleProjectDirectory( cliRequest.multiModuleProjectDirectory );
if ( alternatePomFile != null )
{
@@ -1555,18 +1609,18 @@ public class MavenCli
request.setExcludedProjects( exclProjects );
}
- if ( commandLine.hasOption( CLIManager.ALSO_MAKE ) && !commandLine.hasOption(
- CLIManager.ALSO_MAKE_DEPENDENTS ) )
+ if ( commandLine.hasOption( CLIManager.ALSO_MAKE )
+ && !commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) )
{
request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_UPSTREAM );
}
- else if ( !commandLine.hasOption( CLIManager.ALSO_MAKE ) && commandLine.hasOption(
- CLIManager.ALSO_MAKE_DEPENDENTS ) )
+ else if ( !commandLine.hasOption( CLIManager.ALSO_MAKE )
+ && commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) )
{
request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM );
}
- else if ( commandLine.hasOption( CLIManager.ALSO_MAKE ) && commandLine.hasOption(
- CLIManager.ALSO_MAKE_DEPENDENTS ) )
+ else if ( commandLine.hasOption( CLIManager.ALSO_MAKE )
+ && commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) )
{
request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_BOTH );
}
@@ -1594,10 +1648,13 @@ public class MavenCli
// parameters but this is sufficient for now. Ultimately we want components like Builders to provide a way to
// extend the command line to accept its own configuration parameters.
//
- final String threadConfiguration = commandLine.hasOption( CLIManager.THREADS )
- ? commandLine.getOptionValue( CLIManager.THREADS )
- : request.getSystemProperties().getProperty(
- MavenCli.THREADS_DEPRECATED ); // TODO: Remove this setting. Note that the int-tests use it
+ final String threadConfiguration =
+ commandLine.hasOption( CLIManager.THREADS ) ? commandLine.getOptionValue( CLIManager.THREADS )
+ : request.getSystemProperties().getProperty( MavenCli.THREADS_DEPRECATED ); // TODO: Remove
+ // this setting.
+ // Note that the
+ // int-tests use
+ // it
if ( threadConfiguration != null )
{
@@ -1624,6 +1681,35 @@ public class MavenCli
request.setBuilderId( commandLine.getOptionValue( CLIManager.BUILDER ) );
}
+ if ( commandLine.hasOption( CLIManager.ACTIVATE_FEATURES ) )
+ {
+ String activateFeaturesOptionValue = commandLine.getOptionValue( CLIManager.ACTIVATE_FEATURES );
+
+ List<AvailableFeatureToggles> activatedFeatures = new ArrayList<>();
+
+ if ( activateFeaturesOptionValue != null )
+ {
+ StringTokenizer featureTokens = new StringTokenizer( activateFeaturesOptionValue, "," );
+
+ while ( featureTokens.hasMoreTokens() )
+ {
+ String featureToken = featureTokens.nextToken().trim();
+
+ try
+ {
+ AvailableFeatureToggles resultingFeature = AvailableFeatureToggles.valueOf( featureToken.toUpperCase() );
+ activatedFeatures.add( resultingFeature );
+ }
+ catch ( java.lang.IllegalArgumentException e )
+ {
+ slf4jLogger.warn( "The requested feature '" + featureToken + "' Does not exist." );
+ }
+ }
+ }
+
+ featureToggles.setActivatedFeatureToggles( activatedFeatures );
+ }
+
return request;
}
http://git-wip-us.apache.org/repos/asf/maven/blob/1b3edccd/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java b/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
index d926624..dc3496f 100644
--- a/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
+++ b/maven-embedder/src/test/java/org/apache/maven/cli/MavenCliTest.java
@@ -22,6 +22,7 @@ package org.apache.maven.cli;
import java.io.File;
import org.apache.commons.cli.ParseException;
+import org.apache.maven.feature.AvailableFeatureToggles;
import junit.framework.TestCase;
http://git-wip-us.apache.org/repos/asf/maven/blob/1b3edccd/maven-feature/pom.xml
----------------------------------------------------------------------
diff --git a/maven-feature/pom.xml b/maven-feature/pom.xml
new file mode 100644
index 0000000..0ddd5fc
--- /dev/null
+++ b/maven-feature/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven</artifactId>
+ <version>3.4.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>maven-feature</artifactId>
+
+ <name>Maven Feature</name>
+ <description>Feature Toggle Module. Can be used in any other module.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>org.eclipse.sisu.plexus</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-metadata</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/maven/blob/1b3edccd/maven-feature/src/main/java/org/apache/maven/feature/AvailableFeatureToggles.java
----------------------------------------------------------------------
diff --git a/maven-feature/src/main/java/org/apache/maven/feature/AvailableFeatureToggles.java b/maven-feature/src/main/java/org/apache/maven/feature/AvailableFeatureToggles.java
new file mode 100644
index 0000000..9bdf41c
--- /dev/null
+++ b/maven-feature/src/main/java/org/apache/maven/feature/AvailableFeatureToggles.java
@@ -0,0 +1,102 @@
+package org.apache.maven.feature;
+
+import java.util.Arrays;
+import java.util.List;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmarbaise@apache.org</a>
+ *
+ * @since 3.4.0
+ */
+public enum AvailableFeatureToggles
+{
+
+ //FIXME: Only some examples given. Nothing which exists in reality.
+
+ /**
+ * MNG9991 this feature toggle is intended to do the following..
+ */
+ MNG9991( "MNG-9991", "First Feature to be toggable via command line option. "
+ + "First Feature to be toggable via command line option." ),
+ /**
+ * MNG9992 this feature toggle is intended to do the following..
+ */
+ MNG9992( "MNG-9992", "First Feature to be toggable via command line option. "
+ + "First Feature to be toggable via command line option. XX asdfa. asdf dsf." ),
+ /**
+ * MNG9993 this feature toggle is intended to do the following..
+ */
+ MNG9993( "MNG-9993", "First Feature to be toggable via command line option. "
+ + "More text than you think." ),
+ /**
+ * MNG10000 this feature toggle is intended to do the following..
+ */
+ MNG10000( "MNG-10000", "First Feature to be toggable via command line option. "
+ + "Here much more than you thing." ),
+
+ /**
+ * This is an feature toggle which will never being used nor does it exist.
+ * This is only to mark the end of feature toggles. Also used for unit tests.
+ * Furthermore by using this you can remove all other features but this
+ * type keep a single entry.
+ *
+ * Keep it at the last position in this enumeration.
+ */
+ UNKNOWN ("UNKNOWN", "The unknown feature.");
+
+ private String issue;
+
+ private String description;
+
+ private AvailableFeatureToggles( String issue, String description )
+ {
+ this.issue = issue;
+ this.description = description;
+ }
+
+ /**
+ * @return The list of features without {@code #UNKNOWN}.
+ */
+ public static AvailableFeatureToggles[] getAvailableFeatureToggles() {
+ List<AvailableFeatureToggles> asList = Arrays.asList( AvailableFeatureToggles.values());
+
+ AvailableFeatureToggles[] result = new AvailableFeatureToggles[asList.size() - 1];
+
+ for ( int i = 0; i < asList.size() - 1; i++ )
+ {
+ if (asList.get( i ) != UNKNOWN) {
+ result[i] = asList.get( i );
+ }
+ }
+ return result;
+ }
+
+ public String getDescription()
+ {
+ return this.description;
+ }
+
+ public String getIssue()
+ {
+ return this.issue;
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/1b3edccd/maven-feature/src/main/java/org/apache/maven/feature/DefaultFeatureToggles.java
----------------------------------------------------------------------
diff --git a/maven-feature/src/main/java/org/apache/maven/feature/DefaultFeatureToggles.java b/maven-feature/src/main/java/org/apache/maven/feature/DefaultFeatureToggles.java
new file mode 100644
index 0000000..2f75fbe
--- /dev/null
+++ b/maven-feature/src/main/java/org/apache/maven/feature/DefaultFeatureToggles.java
@@ -0,0 +1,82 @@
+package org.apache.maven.feature;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.logging.Logger;
+
+/**
+ * This implements features toggles which can activated or
+ * asked if a particular feature toggle is active or not.
+ *
+ * @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmarbaise@apache.org</a>
+ *
+ * @since 3.4.0
+ */
+@Component( instantiationStrategy = "singleton", role = FeatureToggles.class )
+public class DefaultFeatureToggles
+ implements FeatureToggles
+{
+ @Requirement
+ private Logger logger;
+
+ private List<AvailableFeatureToggles> activatedFeatureToggles;
+
+ /** {@inheritDoc} */
+ public void setActivatedFeatureToggles( List<AvailableFeatureToggles> featuresToBeActivated )
+ {
+ if ( featuresToBeActivated == null )
+ {
+ this.activatedFeatureToggles = new ArrayList<>();
+ }
+ else
+ {
+ this.activatedFeatureToggles = featuresToBeActivated;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public boolean isToggleActive( AvailableFeatureToggles feature )
+ {
+ if ( activatedFeatureToggles != null )
+ {
+ return activatedFeatureToggles.contains( feature );
+ }
+ return false;
+ }
+
+ public List<AvailableFeatureToggles> getActiveFeatureToggles()
+ {
+ if ( activatedFeatureToggles == null )
+ {
+ return Collections.emptyList();
+ }
+ else
+ {
+ return activatedFeatureToggles;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/1b3edccd/maven-feature/src/main/java/org/apache/maven/feature/FeatureToggles.java
----------------------------------------------------------------------
diff --git a/maven-feature/src/main/java/org/apache/maven/feature/FeatureToggles.java b/maven-feature/src/main/java/org/apache/maven/feature/FeatureToggles.java
new file mode 100644
index 0000000..415dc75
--- /dev/null
+++ b/maven-feature/src/main/java/org/apache/maven/feature/FeatureToggles.java
@@ -0,0 +1,65 @@
+package org.apache.maven.feature;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.List;
+
+/**
+ * This gives access to the feature toggles which can be used during the run of Maven.
+ *
+ * @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmarbaise@apache.org</a>
+ * @since 3.4.0
+ */
+public interface FeatureToggles
+{
+
+ /**
+ * @return The list of features which will be activated.
+ * @see AvailableFeatureToggles
+ * @since 3.4.0
+ */
+ void setActivatedFeatureToggles( List<AvailableFeatureToggles> activatedFeatures );
+
+ /**
+ * Example code looks like this:
+ * <pre>
+ * <code>
+ * if (feature.isToggleActive( AvailableFeatureToggles.MNG10000 )) {
+ * // Do what is needed for the particular feature
+ * }
+ * </code>
+ * </pre>
+ *
+ * @param feature The feature toggle to check for if it is activated or not.
+ * @return <code>true</code> in case of feature has been activated via command line.
+ * <code>--activate-features MNG10000</code>, <code>false</code> otherwise.
+ * @see AvailableFeatureToggles
+ * @since 3.4.0
+ */
+ boolean isToggleActive( AvailableFeatureToggles feature );
+
+ /**
+ * @return The list of feature toggles which have been activated.
+ * @see AvailableFeatureToggles
+ * @since 3.4.0
+ */
+ List<AvailableFeatureToggles> getActiveFeatureToggles();
+
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/1b3edccd/maven-feature/src/test/java/org/apache/maven/feature/AvailableFeatureTogglesTest.java
----------------------------------------------------------------------
diff --git a/maven-feature/src/test/java/org/apache/maven/feature/AvailableFeatureTogglesTest.java b/maven-feature/src/test/java/org/apache/maven/feature/AvailableFeatureTogglesTest.java
new file mode 100644
index 0000000..b00b80d
--- /dev/null
+++ b/maven-feature/src/test/java/org/apache/maven/feature/AvailableFeatureTogglesTest.java
@@ -0,0 +1,52 @@
+package org.apache.maven.feature;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * This implements some checks on the enumeration type.
+ *
+ * @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmarbaise@apache.org</a>
+ * @since 3.4.0
+ */
+public class AvailableFeatureTogglesTest
+{
+
+ @Test
+ public void getAvailableFeatureToggolesShouldReturnFour()
+ {
+ assertEquals( 4, AvailableFeatureToggles.getAvailableFeatureToggles().length );
+ }
+
+ @Test
+ public void getAvailableFeatureTogglesShouldReturnCorrectValues()
+ {
+ AvailableFeatureToggles[] aft = AvailableFeatureToggles.getAvailableFeatureToggles();
+
+ assertEquals( AvailableFeatureToggles.MNG9991, aft[0] );
+ assertEquals( AvailableFeatureToggles.MNG9992, aft[1] );
+ assertEquals( AvailableFeatureToggles.MNG9993, aft[2] );
+ assertEquals( AvailableFeatureToggles.MNG10000, aft[3] );
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/1b3edccd/maven-feature/src/test/java/org/apache/maven/feature/DefaultSelectedFeaturesTest.java
----------------------------------------------------------------------
diff --git a/maven-feature/src/test/java/org/apache/maven/feature/DefaultSelectedFeaturesTest.java b/maven-feature/src/test/java/org/apache/maven/feature/DefaultSelectedFeaturesTest.java
new file mode 100644
index 0000000..7400196
--- /dev/null
+++ b/maven-feature/src/test/java/org/apache/maven/feature/DefaultSelectedFeaturesTest.java
@@ -0,0 +1,79 @@
+package org.apache.maven.feature;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This implements some unit tests for checking the behaviour of the implementation.
+ *
+ * @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmarbaise@apache.org</a>
+ * @since 3.4.0
+ */
+public class DefaultSelectedFeaturesTest
+{
+ private FeatureToggles sf;
+
+ @Before
+ public void before()
+ {
+ sf = new DefaultFeatureToggles();
+ }
+
+ @Test
+ public void getActiveFeaturesShouldNotReturnNotNullAndSizeOfListZero()
+ {
+ assertNotNull( sf.getActiveFeatureToggles() );
+ assertEquals( sf.getActiveFeatureToggles().size(), 0 );
+ }
+
+ @Test
+ public void isToggleActiveShouldReturnFalseIfNoTogglesHadBeenActivatedAtAll()
+ {
+ assertFalse( sf.isToggleActive( AvailableFeatureToggles.UNKNOWN ) );
+ }
+
+ @Test
+ public void isToggleActiveShouldReturnFalseIfNotTheCorrectFeatureIsActivated()
+ {
+ sf.setActivatedFeatureToggles( Arrays.asList( AvailableFeatureToggles.UNKNOWN ) );
+ assertFalse( sf.isToggleActive( AvailableFeatureToggles.MNG10000 ) );
+ assertTrue( sf.isToggleActive( AvailableFeatureToggles.UNKNOWN ) );
+ }
+
+
+ @Test
+ public void getActiveFeatureTogglesShouldReturnFalse()
+ {
+ List<AvailableFeatureToggles> activeFeatureToggles = sf.getActiveFeatureToggles();
+ assertEquals( 2, activeFeatureToggles.size() );
+ assertFalse( sf.isToggleActive( AvailableFeatureToggles.MNG10000 ) );
+ assertTrue( sf.isToggleActive( AvailableFeatureToggles.UNKNOWN ) );
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven/blob/1b3edccd/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 861b915..cc6d9b8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -81,6 +81,7 @@ under the License.
</properties>
<modules>
+ <module>maven-feature</module>
<module>maven-plugin-api</module>
<module>maven-builder-support</module>
<module>maven-model</module>
@@ -165,6 +166,11 @@ under the License.
<dependencyManagement>
<!--bootstrap-end-comment-->
<dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-feature</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- Maven Modules -->
<!--bootstrap-start-comment-->
<dependency>