title: Upgrading gradle 4.5 to 7.2, throws error Could not get unknown property 'java' for SoftwareComponentInternal
body: <p>I am upgrading gradle 4.5 to 7.2. on build.gradle it throws exception &quot;Could not get unknown property 'java' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.&quot; on line 118. The code at line 118 is as follows.</p>
  <pre><code>publishing {
  repositories {
      maven {
          credentials {
              username=mvn_user
              password=mvn_pass
          }
          
          if (version.endsWith(&quot;-SNAPSHOT&quot;)) {
              url snapshotRepo
              println &quot;Publishing to ${snapshotRepo}&quot;
          }
          else {
              url releaseRepo
              println &quot;Publishing to ${releaseRepo}&quot;
          }
      }
  }
  
  publications {
      mavenJava(MavenPublication) {
          
          artifactId = mavenArtifactId 
  
          from project(':server').components.java
          
          artifact project(':server').javadocJar
          artifact project(':server').sourceJar
          artifact examplePropertiesArtifact
          artifact exampleLog4jFileArtifact
          artifact windowsScriptFile
          artifact linuxScriptArtifact
          artifact aixScriptArtifact
  </code></pre>