Q:

Intellij: Define default task to be used for all new Java projects

For almost every Java project I have, I define a new Gradle task to build a jar with the javadocs.  Specifically, I add the following to almost every build.gradle:
task jarJavadoc(type: Jar, dependsOn: ['javadoc']) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives jarJavadoc
}

Is there a way to configure Intellij so that it automatically adds these lines to every new Gradle Java project?  

A:

I think you could explore couple of options:

First is creating a gradle file (e.g. init.gradle) in your GRADLE_HOME directory (e.g ~/.gradle/) and define the common parts there.  Gradle always applies those files first while processing your build scripts.  Note, everything you configure there is going to be available in
every Gradle project on your machine.  Which means e.g. if you depend
on Java plugin (like you do in an example you provided) and you create
other project which doesn't depend on Java, this approach may produce
configuration errors so use it with caution. 
You could write a simple Gradle plugin which adds common tasks you require to a project.  With this approach you will still need to duplicate the apply plugin: 'your plugin'
You could leverage File and Code templates and update Gradle build script template to include the common code.   
You can also mix the last 2 examples and write a plugin which configures the common tasks and modify Gradle build script template to include your plugin. 