title: Cannot configure the publishing extension for gradle
body: <p>I am using gradle v3.4 with the following build.gradle file.  However, I get the error copied below with any tasks.  Any thoughts on what might be misconfigured in the build.gradle file?</p>
  
  <p><strong>error</strong></p>
  
  <pre><code>What went wrong:
  A problem occurred evaluating root project 'some-test'.
  &gt; Cannot configure the 'publishing' extension after it has been accessed.
  </code></pre>
  
  <p>The error points to where the publishing task begins. </p>
  
  <p><strong>build.gradle</strong></p>
  
  <pre><code>group 'some.group'
  version '0.0.1' //-SNAPSHOT'
  
  apply plugin: 'java'
  apply plugin: 'application'
  apply plugin: 'idea'
  apply plugin: 'com.google.protobuf'
  apply plugin: 'maven'
  apply plugin: 'maven-publish'
  apply plugin:'com.github.johnrengelman.shadow'
  
  buildscript {
      repositories {
          mavenLocal()
          mavenCentral()
          maven {
              credentials {
                  username project.properties['nexusUsername']
                  password project.properties['nexusPassword']
              }
              url project.properties['nexus.url.snapshot']
          }
          jcenter()
      }
      dependencies {
          classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.0'
          classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
      }
  }
  
  if (!JavaVersion.current().java8Compatible) {
      throw new IllegalStateException("Must be built with Java 8 or higher")
  }
  
  mainClassName = "com.some.project.some.class"
  
  defaultTasks 'clean', 'build', 'shadowJar', 'install'
  
  compileJava {
      sourceCompatibility = '1.8'
      targetCompatibility = '1.8'
  }
  
  [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
  
  repositories {
      maven {
          credentials {
              username project.properties['nexusUsername']
              password project.properties['nexusPassword']
          }
          url project.properties['nexus.url.snapshot']
      }
      mavenLocal()
      mavenCentral()
      jcenter()
  }
  
  def grpcVersion = '1.1.2'
  def log4j2Version = '2.8.1'
  def configVersion = '1.3.1'
  def jacksonVersion = '2.8.7'
  
  dependencies {
      compile "io.grpc:grpc-netty:${grpcVersion}"
      compile "io.grpc:grpc-protobuf:${grpcVersion}"
      compile "io.grpc:grpc-stub:${grpcVersion}"
      compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: jacksonVersion
      compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion
      compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: jacksonVersion
  
      compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: log4j2Version
      compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: log4j2Version
      compile 'io.netty:netty-tcnative-boringssl-static:1.1.33.Fork26'
      compile group: 'org.bouncycastle', name: 'bcprov-jdk16', version: '1.46'
      compile "com.typesafe:config:${configVersion}"
  
      testCompile group: 'junit', name: 'junit', version: '4.11'
      testCompile "org.mockito:mockito-core:1.9.5"
      compile 'commons-lang:commons-lang:2.3'
  }
  
  
  sourceSets {
      main {
          proto {
              srcDir '../../proto' // In addition to the default 'src/main/proto'
          }
          java {
          }
      }
      test {
          proto {
              srcDir '../../proto' // In addition to the default 'src/test/proto'
          }
      }
  }
  
  protobuf {
      protoc {
          artifact = 'com.google.protobuf:protoc:3.2.0'
      }
      plugins {
          grpc {
              artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
          }
      }
      generateProtoTasks {
          all()*.plugins {
              grpc {
                  // To generate deprecated interfaces and static bindService method,
                  // turn the enable_deprecated option to true below:
                  option 'enable_deprecated=false'
              }
          }
      }
  }
  
  
  idea {
      module {
          sourceDirs += file("${projectDir}/build/generated/source/proto/main/java");
          sourceDirs += file("${projectDir}/build/generated/source/proto/main/grpc");
      }
  }
  
  
  
  jar {
      manifest {
             attributes(
                  'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
                  'Main-Class': 'com.some.project.some.class'
          )
      }
  }
  
  shadowJar {
      baseName = 'commons-java'
      classifier = null
      version = null
  }
  
  artifacts {
      archives shadowJar
  }
  
  
  publishing {
      publications {
          shadow(MavenPublication) {
              from components.shadow
          }
      }
      repositories {
          maven {
              credentials {
                  username "someuser"
                  password "somepassword"
              }
              url "http://nexus.somewhere.com/repository/some-test-snapshots/"
          }
      }
  }
  
  tasks.publish.dependsOn 'shadowJar'
  
  startScripts.enabled = false
  </code></pre>