private static void applyJavaLibraryPlugin()

in servicetalk-gradle-plugin-internal/src/main/groovy/io/servicetalk/gradle/plugin/internal/ServiceTalkLibraryPlugin.groovy [55:158]


  private static void applyJavaLibraryPlugin(Project project) {
    project.configure(project) {
      pluginManager.apply("java-library")

      sourceCompatibility = TARGET_VERSION
      targetCompatibility = TARGET_VERSION

      jar {
        addManifestAttributes(project, manifest)
      }

      javadoc {
        options.noQualifiers "all"
        options.addBooleanOption("Xwerror", true)
        options.addBooleanOption("Xdoclint:all,-missing", true)
        options.addBooleanOption("protected", true)
      }

      def sourcesJar = createSourcesJarTask(project, sourceSets.main)
      def javadocJar = createJavadocJarTask(project, sourceSets.main)

      artifacts {
        archives sourcesJar
        archives javadocJar
      }

      // Keep publishing and signing configuration in sync with servicetalk-bom/build.gradle
      publishing {
        publications {
          mavenJava(MavenPublication) {
            // publish jars, sources and docs
            from components.java
            artifact(javadocJar)
            artifact(sourcesJar)
            pom {
              name = project.name
              description = 'A networking framework that evolves with your application'
              url = 'https://servicetalk.io'
              licenses {
                license {
                  name = 'The Apache License, Version 2.0'
                  url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                }
              }
              developers {
                developer {
                  id = 'servicetalk-project-authors'
                  name = 'ServiceTalk project authors'
                  email = 'servicetalk-oss@group.apple.com'
                }
              }
              scm {
                connection = "scm:git:git://${scmHost}/${scmPath}.git"
                developerConnection = "scm:git:ssh://${scmHost}:${scmPath}.git"
                url = "https://${scmHost}/${scmPath}"
              }
              issueManagement {
                system = 'ServiceTalk Issues'
                url = "${issueManagementUrl}"
              }
              ciManagement {
                system = 'ServiceTalk CI'
                url = "${ciManagementUrl}"
              }
            }
          }
        }

        if (!repositories) {
          repositories {
            maven {
              name = "sonatype"
              def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
              def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
              url = project.isReleaseBuild ? releasesRepoUrl : snapshotsRepoUrl
              credentials {
                username = System.getenv("SONATYPE_USER")
                password = System.getenv("SONATYPE_TOKEN")
              }
            }
          }
        }
      }

      if (!!findProperty("signingKey") && !!findProperty("signingPassword")) {
        pluginManager.apply("signing")
        signing {
          def signingKey = findProperty("signingKey")
          def signingPassword = findProperty("signingPassword")
          useInMemoryPgpKeys(signingKey, signingPassword)
          sign publishing.publications.mavenJava
        }
      }

      tasks.withType(AbstractPublishToMaven) {
        onlyIf {
          // Disable all tasks that try to publish something else, expect defined "mavenJava" publication.
          // That could be automatically configured "pluginMaven" publication for gradle plugins that are required
          // only for Gradle Plugin Portal and should not be published to Maven Central
          publication == publishing.publications.mavenJava
        }
      }
    }
  }