Put this in a block rather than on the same line as the if; so like this:

    if (jars != null) {
      jars.foreach(...)
    }