The solution forgets to mention that you may still have a gradle daemon running. You *must* stop the daemon first, then delete the caches and try a new build. That explains why you may still be running into issues even after a refresh.
Late reaction, but since I ended up here through search, a tip for future readers: If you want to find out how the minecraft items achieve something, look at the minecraft implementation. E.g. if you're using IntelliJ IDEA in your project window, expand 'External libraries' and then the forgeSrc jar file.