The normal way to build Apache NiFi from source on Linux is to use:
mvn -T C2.0 clean install
More info is here incidentally. One issue with this is that it also runs all the tests which gives rise to a couple of problems. One is that some of the tests take a while and slow down the build process. The other is that, should some arcane test in code that isn’t interesting fail, the build aborts. To avoid this, build with tests turned off:
mvn -T C2.0 clean install -Dmaven.test.skip=true
Saves quite a bit of time!