add gradle support. fix result trimming problem