I'm trying to use the requireActiveProfile rule via the
maven-enforcer-plugin, version 1.2:
=====
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${app.maven-enforcer-plugin.version}</version>
<executions>
<execution>
<id>require-orm-profiles</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireActiveProfile>
<profiles>hibernate,datanucleus</profiles>
*/<all>false</all>/*
</requireActiveProfile>
</rules>
</configuration>
</execution>
</executions>
</plugin>
=====
It doesn't work, and here, apparently is why: the code that uses the "all"
attribute on the class RequireActiveProfile is commented out (downloaded
from
http://search.maven.org/remotecontent?filepath=org/apache/maven/enforcer/enforcer-rules/1.2/enforcer-rules-1.2-sources.jar).
=====
public class RequireActiveProfile
extends AbstractNonCacheableEnforcerRule
{
/** Comma separated list of profiles to check. */
public String profiles = null;
/** If all profiles must be active. If false, only one must be active */
public boolean all = true;
/*
* (non-Javadoc)
*
* @see
org.apache.maven.enforcer.rule.api.EnforcerRule#execute(org.apache.maven.enforcer.rule.api.EnforcerRuleHelper)
*/
public void execute( EnforcerRuleHelper theHelper )
throws EnforcerRuleException
{
List<String> missingProfiles = new ArrayList<String>();
try
{
MavenProject project = (MavenProject) theHelper.evaluate(
"${project}" );
if ( StringUtils.isNotEmpty( profiles ) )
{
String[] profs = profiles.split( "," );
for ( String profile : profs )
{
if ( !isProfileActive( project, profile ) )
{
missingProfiles.add( profile );
}
}
boolean fail = false;
if ( !missingProfiles.isEmpty() )
{
fail = true;
*
// if (all && missingProfiles.size() != profs.length)
// {
// fail = true;
// }
// else
// {
// if (!all && missingProfiles.size() >= (profs.length
-1))
// {
// fail = true;
// }
// }
*
}
if ( fail )
{
StringBuilder buf = new StringBuilder();
if ( message != null )
{
buf.append( message + "\n" );
}
for ( String profile : missingProfiles )
{
buf.append( "Profile \"" + profile + "\" is not
activated.\n" );
}
throw new EnforcerRuleException( buf.toString() );
}
}
}
catch ( ExpressionEvaluationException e )
{
throw new EnforcerRuleException( "Unable to retrieve the
project.", e );
}
}
// ...
=====
I saw https://jira.codehaus.org/browse/MENFORCER-143 and it says this was
fixed in 1.1.1. What gives?
/NB: I can't seem to find where the svn repo is that contains
RequireActiveProfile.java, which is why I used the maven repo search link./
Thanks,
Matthew
--
View this message in context:
http://maven.40175.n5.nabble.com/Why-is-the-functionality-of-the-all-attribute-of-the-RequireActiveProfile-rule-commented-out-tp5746380.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]