summaryrefslogtreecommitdiff
path: root/lib/java/gradle/publishing.gradle
blob: 481fcbc695c68a4422a35e3d2d9a9628f23d73cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

// Following Gradle best practices to keep build logic organized

// ----------------------------------------------------------------------------
// Installation subtasks, not used currently, we use "make install/fast"
task installDist(type: Copy, group: 'Install') {
    description = "Copy Thrift JAR and dependencies into $installPath location"

    destinationDir = file(installPath)

    from jar
    from configurations.compile
}

task installJavadoc(type: Copy, group: 'Install', dependsOn: javadoc) {
    description = "Install Thrift JavaDoc into $installJavadocPath location"

    destinationDir = file(installJavadocPath)

    from javadoc.destinationDir
}

// This is not needed by Gradle builds but the remaining Ant builds seem to
// need access to the generated test classes for Thrift unit tests so we
// assist them to use it this way.
task copyDependencies(type: Copy, group: 'Build') {
    description = 'Copy runtime dependencies in a common location for other Ant based projects'
    project.assemble.dependsOn it

    destinationDir = file("$buildDir/deps")
    from configurations.testRuntime
    // exclude some very specific unit test dependencies
    exclude '**/junit*.jar', '**/mockito*.jar', '**/hamcrest*.jar'
}

// ----------------------------------------------------------------------------
// Allow this configuration to be shared between install and uploadArchives tasks
def configurePom(pom) {
    pom.project {
        name 'Apache Thrift'
        description 'Thrift is a software framework for scalable cross-language services development.'
        packaging 'jar'
        url 'http://thrift.apache.org'

        scm {
            url 'https://github.com/apache/thrift'
            connection 'scm:git:https://github.com/apache/thrift.git'
            developerConnection 'scm:git:git@github.com:apache/thrift.git'
        }

        licenses {
            license {
                name 'The Apache Software License, Version 2.0'
                url "${project.license}"
                distribution 'repo'
            }
        }

        developers {
            developer {
                id 'dev'
                name 'Apache Thrift Developers'
                email 'dev@thrift.apache.org'
            }
        }
    }

    pom.whenConfigured {
        // Fixup the scope for servlet-api to be 'provided' instead of 'compile'
        dependencies.find { dep -> dep.groupId == 'javax.servlet' && dep.artifactId == 'servlet-api' }.with {
            if(it != null) {
              // it.optional = true
              it.scope = 'provided'
            }
        }
    }
}

install {
    repositories.mavenInstaller {
        configurePom(pom)
    }
}

uploadArchives {
    dependsOn test // make sure we run unit tests when publishing
    repositories.mavenDeployer {
        // signPom will silently do nothing when no signing information is provided
        beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
        repository(url: project.mavenRepositoryUrl) {
            if (project.hasProperty('mavenUser') && project.hasProperty('mavenPassword')) {
                authentication(userName: mavenUser, password: mavenPassword)
            }
        }
        configurePom(pom)
    }
}

// Signing configuration, optional, only when release and uploadArchives is activated
signing {
    required { !version.endsWith("SNAPSHOT") && gradle.taskGraph.hasTask("uploadArchives") }
    sign configurations.archives
}