apache/maven · error · IllegalArgumentException
not function requires exactly one argument
Error message
not function requires exactly one argument
What it means
not() is a built-in function of Maven 4.1 profile activation conditions (<activation><condition>). ConditionFunctions.not throws IllegalArgumentException unless exactly one boolean argument is supplied; the activator records 'Error parsing profile activation condition' and the profile remains inactive.
Source
Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionFunctions.java:170
public Object matches(List<Object> args) {
if (args.size() != 2) {
throw new IllegalArgumentException("matches function requires exactly two arguments");
}
String s = ConditionParser.toString(args.get(0));
String regex = ConditionParser.toString(args.get(1));
return s.matches(regex);
}
/**
* Negates a boolean value.
*
* @param args A list containing a single boolean argument
* @return The negation of the input boolean
* @throws IllegalArgumentException if the number of arguments is not exactly one
*/
public Object not(List<Object> args) {
if (args.size() != 1) {
throw new IllegalArgumentException("not function requires exactly one argument");
}
return !ConditionParser.toBoolean(args.get(0));
}
/**
* Implements an if-then-else operation.
*
* @param args A list containing three arguments: condition, value if true, value if false
* @return The second argument if the condition is true, the third argument otherwise
* @throws IllegalArgumentException if the number of arguments is not exactly three
*/
@SuppressWarnings("checkstyle:MethodName")
public Object if_(List<Object> args) {
if (args.size() != 3) {
throw new IllegalArgumentException("if function requires exactly three arguments");
}
boolean condition = ConditionParser.toBoolean(args.get(0));
return condition ? args.get(1) : args.get(2);View on GitHub (pinned to e4093d4e12)
Solutions
- Wrap exactly one boolean expression: not(exists('src/main/groovy'))
- For multiple conditions use operators, e.g. not(exists('a')) and not(exists('b'))
- Verify with mvn help:active-profiles after the fix
Example fix
<!-- before -->
<condition>not(exists('src/main/groovy'), exists('src/main/scala'))</condition>
<!-- after -->
<condition>not(exists('src/main/groovy')) and not(exists('src/main/scala'))</condition> Defensive patterns
Strategy: validation
Validate before calling
static boolean arityOk(String condition, String fn, int min, int max) {
int i = condition.indexOf(fn + "(");
if (i < 0) return true;
String args = condition.substring(i + fn.length() + 1, condition.indexOf(')', i));
int n = args.isBlank() ? 0 : args.split(",", -1).length;
return n >= min && n <= max;
}
boolean ok = arityOk(condition, "not", 1, 1); Try / catch
try {
Object r = new ConditionParser(functions, resolver).parse(condition);
} catch (IllegalArgumentException e) {
// report and treat the profile as inactive
} Prevention
- not wraps exactly one boolean expression; combine multiple negations with and/or
- Prefer the De Morgan form (not(a or b) vs not(a) and not(b)) consistently across the team
When it happens
Trigger: A condition like not(exists('x'), exists('y')) with two arguments, or not() with none — the only valid form is not(<boolean expression>), e.g. not(exists('src/main/groovy')).
Common situations: Trying to negate two conditions in one call instead of using 'and'/'or' operators; an empty argument list left behind after deleting the inner expression.
Related errors
- length function requires exactly one argument
- upper function requires exactly one argument
- lower function requires exactly one argument
- substring function requires 2 or 3 arguments
- indexOf function requires exactly two arguments
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/3eec5920e16f1839.
Report an issue: GitHub.