When is it boilerplate vs. when is it plagiarism?

Doing an involved mobile app for a class and there seems to be a TON of boilerplate code from "other sources" so I'm a bit uneasy with the academic integrity bit. In industry 80% is finding what someone else did and 20% tweaking it but I don't want to turn this in and get smacked with cheating. In short, where is the line at and when it comes to courses with languages with seemingly copious boilerplate, when do you know you crossed it?