package is a keyword in Java / Groovy, and you will need to use a different syntax to declare a task with that name.
In any case, the task declaration for package must be removed, since the jar task already serves this purpose. The configuration of the jar task ( jar { from ... } ) should be at the most remote level (not nested in another task), but from configurations.compile it is unlikely that you want, since this will include Jars from dependency compilation in the Jar (which regular java cool loaders can't handle it) rather than merging them with jar. (Are you even sure you need a fat jar?)
Similarly, the publish task declaration must be removed and replaced with publishing { publications { ... } } .
In addition, the buildscript block buildscript probably be removed, and repositories { ... } and dependencies { ... } moved to the outermost level. ( buildscript { dependencies { ... } } declares the dependencies of the script collector itself (for example, Gradle), and not the dependency on the compiled / executed code.)
I suggest checking out many standalone build examples in the samples directory of the full Gradle distribution ( gradle-all ).
source share