/ gradle / publish-java.gradle
publish-java.gradle
 1  /*
 2   * SPDX-FileCopyrightText: 2020, microG Project Team
 3   * SPDX-License-Identifier: Apache-2.0
 4   */
 5  
 6  task javaSourcesJar(type: Jar) {
 7      archiveClassifier.set("sources")
 8      from sourceSets.main.allJava
 9  }
10  
11  javadoc {
12      classpath = configurations.compileClasspath
13      source = sourceSets.main.allJava
14  }
15  
16  task javaJavadocsJar(type: Jar) {
17      archiveClassifier.set("javadoc")
18      from javadoc
19  }
20  
21  artifacts {
22      archives javaSourcesJar
23      archives javaJavadocsJar
24  }
25  
26  afterEvaluate {
27      publishing {
28          publications {
29              release(MavenPublication) {
30                  pom {
31                      name = project.name
32                      description = project.description
33                      url = 'https://github.com/microg/GmsCore'
34                      licenses {
35                          license {
36                              name = 'The Apache Software License, Version 2.0'
37                              url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
38                          }
39                      }
40                      developers {
41                          developer {
42                              id = 'microg'
43                              name = 'microG Team'
44                          }
45                      }
46                      scm {
47                          url = 'https://github.com/microg/GmsCore'
48                          connection = 'scm:git:https://github.com/microg/GmsCore.git'
49                          developerConnection = 'scm:git:ssh://github.com/microg/GmsCore.git'
50                      }
51                  }
52  
53                  from components.java
54                  artifact javaSourcesJar
55                  artifact javaJavadocsJar
56              }
57          }
58          if (project.hasProperty('sonatype.username')) {
59              repositories {
60                  maven {
61                      name = 'sonatype'
62                      url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
63                      credentials {
64                          username project.getProperty('sonatype.username')
65                          password project.getProperty('sonatype.password')
66                      }
67                  }
68              }
69          }
70      }
71      if (project.hasProperty('signing.keyId')) {
72          signing {
73              sign publishing.publications
74          }
75      }
76  }