aboutsummaryrefslogtreecommitdiff
path: root/gradle-model/build.gradle
blob: e6d006b68e9903a46e8809ba3e6099c3e53bea97 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'clone-artifacts'

def toolingApiVersion = gradle.gradleVersion

// Custom config that cloneArtifact will not look into, since this
// artifact is not in mavenCentral, but in the gradle repo instead.
configurations{
  gradleRepo
}

dependencies {
    // should be build-model but until builder is in a repo w/o it's local dependencies, we have to
    // depend on builder itself to not have a dependency on 'common'
    compile project(':builder-model')

    testCompile 'junit:junit:3.8.1'
    // Need an SLF4J implementation at runtime
    testRuntime 'org.slf4j:slf4j-simple:1.7.2'

    // this is technically testCompile, but we don't want
    // it in there to avoid breaking cloneArtifact.
    // we'll add it to the test compile classpath manually below
    gradleRepo "org.gradle:gradle-tooling-api:${toolingApiVersion}"

}

//Include custom for compilation
sourceSets.test.compileClasspath += configurations.gradleRepo
sourceSets.test.runtimeClasspath += configurations.gradleRepo

def getVersion() {
    if (project.has("release")) {
        return project.ext.baseVersion
    }

    return project.ext.baseVersion + '-SNAPSHOT'
}

test.dependsOn ':gradle:publishLocal'

version = getVersion()
archivesBaseName = 'gradle-model'

task publishLocal(type: Upload) {
    configuration = configurations.archives
    repositories {
        mavenDeployer {
            repository(url: uri("$rootProject.ext.androidHostOut/repo"))
        }
    }
}

project.ext.sonatypeUsername = hasProperty('sonatypeUsername') ? sonatypeUsername : ""
project.ext.sonatypePassword = hasProperty('sonatypePassword') ? sonatypePassword : ""

uploadArchives {
    repositories {
        mavenDeployer {
            beforeDeployment { MavenDeployment deployment ->
                if (!project.has("release")) {
                    throw new StopExecutionException("uploadArchives must be called with the release.gradle init script")
                }

                if (project.ext.sonatypeUsername.length() == 0 || project.ext.sonatypePassword.length() == 0) {
                    throw new StopExecutionException("uploadArchives cannot be called without sonatype username and password")
                }

                signing.signPom(deployment)
            }

            repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
                authentication(userName: project.ext.sonatypeUsername, password: project.ext.sonatypePassword)
            }

            pom.project {
                name 'Android Gradle Model'
                description 'Model for the Android Gradle plugin.'
                url 'http://tools.android.com'
                inceptionYear '2007'

                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                        distribution 'repo'
                    }
                }

                scm {
                    url "https://android.googlesource.com/platform/tools/build"
                    connection "git://android.googlesource.com/platform/tools/build.git"
                }
                developers {
                    developer {
                        name 'The Android Open Source Project'
                    }
                }
            }
        }
    }
}

// custom tasks for creating source/javadoc jars
task sourcesJar(type: Jar, dependsOn:classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

javadoc {
    exclude               "**/internal/**"
    options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED

    title                 "Android Model"
}

task javadocJar(type: Jar, dependsOn:javadoc) {
    classifier         'javadoc'
    from               javadoc.destinationDir
}
 
// add javadoc/source jar tasks as artifacts
artifacts {
    archives jar
    archives sourcesJar
    archives javadocJar
}

signing {
    required { project.has("release") && gradle.taskGraph.hasTask("uploadArchives") }
    sign configurations.archives
}