forked from nimrich/mopub-android-mediation
-
Notifications
You must be signed in to change notification settings - Fork 4
/
shared-build.gradle
135 lines (111 loc) · 4.38 KB
/
shared-build.gradle
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
135
// Common boilerplate gradle code shared by all network subprojects.
// Each network subproject's build.gradle should start like this:
//
// project.version = 'X.Y.Z.N'
//
// apply from: '../shared-build.gradle'
//
// Then go on to mention repositories {}, dependencies {} and any other specific gradle directives
// needed to build.
project.description = "MoPub Mediation Adapter for " + project.name
// Assuming the project version is X.Y.Z.N (eg 3.3.7.1), sets 'sdkVersion' to X.Y.Z (eg 3.3.7).
// Use this in your build.gradle for the network SDK dependency, as in:
// implementation "com.adcolony:sdk:${sdkVersion}"
ext.sdkVersion = project.version.toString().replaceFirst(/.[0-9]+$/, '')
// These next two properties have default values specified below, but can be overridden in the
// build.gradle by setting either or both of them just before the
// "apply from ../shared-build.gradle" line.
// Example:
// project.version = '1.2.3.4'
// project.ext.artifactName = 'myArtifact'
// project.ext.networkName = 'myNetwork'
//
// apply from: '../shared-build.gradle'
//
// "artifactName" is the string that becomes the artifactId in the gradle dependency string
// for this network (i.e., continuing the above example, pubs would write "com.mopub:myArtifact:someVersion")
if (!project.ext.has("artifactName")) {
project.ext.artifactName = project.name.toLowerCase()
}
// "networkName" is the string that will be returned by BuildConfig.NETWORK_NAME at runtime.
if (!project.ext.has("networkName")) {
project.ext.networkName = project.ext.artifactName
}
apply plugin: 'maven'
apply plugin: 'signing'
android {
defaultConfig {
versionName project.version
// Add a field called NETWORK_NAME to the BuildConfig class, which can be accessed by
// the AdapterConfig.java code.
buildConfigField("String", "NETWORK_NAME", "\"${project.ext.networkName}\"")
// Set the .aar filename to mopub-NETWORK-adapters-VERSION-release.aar"
project.ext.set("archivesBaseName", "mopub-" + project.ext.artifactName + "-adapters-" + project.version)
}
}
signing {
sign configurations.archives
}
uploadArchives {
repositories.mavenDeployer {
pom.groupId = 'com.mopub.mediation'
pom.artifactId = project.ext.artifactName
pom.version = project.version
pom.project {
name 'MoPub Network Mediation'
description "${project.name} Adapter for MoPub Mediation"
url 'https://github.com/mopub/mopub-android-mediation'
scm {
connection 'scm:git:https://github.com/mopub/mopub-android-mediation.git'
developerConnection 'scm:git:https://github.com/mopub/mopub-android-mediation.git'
url 'https://github.com/mopub/mopub-android-mediation'
}
licenses {
license {
name 'MoPub SDK License Agreement'
url 'http://www.mopub.com/legal/sdk-license-agreement'
}
}
developers {
developer {
id 'mopub'
name 'MoPub (a division of Twitter, Inc.)'
email '[email protected]'
}
}
}
pom.whenConfigured {
pom -> pom.dependencies.clear()
}
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: System.getenv("SONATYPE_USER"), password: System.getenv("SONATYPE_PASS"))
}
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
}
}
// Copy the final (release) .aar file into the top level /libs directory.
task copyAAR(type: Copy) {
from('build/outputs/aar') {
include '*-release.*'
rename '(.*)-release.(.*)', '$1.$2'
}
into("$rootDir/libs")
}
task removeAAR(type: Delete) {
delete fileTree("$rootDir/libs") {
include "mopub-${project.ext.artifactName}-adapters-*.aar"
}
}
afterEvaluate {
bundleReleaseAar.finalizedBy copyAAR
clean.dependsOn removeAAR
}
// Support for publishing to bintray.
// See https://github.com/novoda/bintray-release/wiki for documentation.
publish {
groupId = project.group
artifactId = project.ext.artifactName
publishVersion = project.version
uploadName = project.group + "." + artifactId
desc = project.description
}