Apparently, getNetworkPrefixLength can return -1, which confuses the Ruby side. Therefore fall back to guessing the prefix in this case, as we do it for Java <= 1.6.
Functionality and build result is 1:1 the same as before. Auxiliary ant targets have been converted to Maven profiles.