/
build.gradle
173 lines (146 loc) · 5.15 KB
/
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.github.dcendents:android-maven-gradle-plugin:1.4.1"
}
}
apply plugin: 'com.android.library'
apply plugin: 'signing'
apply plugin: 'com.github.dcendents.android-maven'
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
version = project.VERSION_NAME
group = "info.metadude.android"
archivesBaseName = "typed-preferences"
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
signing {
required {
isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives")
}
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment {
MavenDeployment deployment -> signing.signPom(deployment)
}
repository(url: sonatypeRepo) {
authentication(
userName: sonatypeUserName,
password: sonatypePassword
)
}
pom {
project {
name "Typed Preferences"
packaging "jar", "aar"
description "Preference wrappers for primitive types"
inceptionYear "2014"
url "https://github.com/johnjohndoe/TypedPreferences"
scm {
url "scm:git@github.com:johnjohndoe/TypedPreferences.git"
connection "scm:git@github.com:johnjohndoe/TypedPreferences.git"
developerConnection "scm:git@github.com:johnjohndoe/TypedPreferences.git"
}
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
id "johnjohndoe"
name "Tobias Preuss"
email "tobias.preuss@googlemail.com"
}
}
}
}
}
}
}
android {
compileSdkVersion Integer.parseInt(project.COMPILE_SDK_VERSION)
buildToolsVersion project.BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion Integer.parseInt(project.MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.TARGET_SDK_VERSION)
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
buildConfigField "int", "ROBOLECTRIC_EMULATE_SDK_VERSION", "18"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
android.libraryVariants.all { variant ->
variant.outputs.each { output ->
File outputFile = output.outputFile
String name = outputFile.name
if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
return; // Skip debug builds.
}
task("javadoc${outputFile.name.capitalize()}", type: Javadoc) {
description "Generates Javadoc for $outputFile.name."
source = variant.javaCompile.source
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
}
task("bundleJavadoc${outputFile.name.capitalize()}", type: Jar) {
description "Bundles Javadoc into zip for $variant.name."
classifier = "javadoc"
from tasks["javadoc${outputFile.name.capitalize()}"]
}
}
}
task jar(type: Jar) {
from 'build/intermediates/classes/release'
exclude '**/BuildConfig.class'
exclude '**/R.class'
}
task androidJavadocs(type: Javadoc) {
description "Generates JavaDoc files from all Java files."
source = android.sourceSets.main.java.srcDirs
}
task androidJavadocsJar(type: Jar) {
description "Generates a JavaDoc archive (.jar) from the JavaDoc files."
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
description "Generates a source files archive (.jar)."
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
artifacts {
archives androidSourcesJar
archives androidJavadocsJar
archives jar
}
tasks.withType(Test) {
testLogging {
events TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT
exceptionFormat TestExceptionFormat.FULL
showCauses true
showExceptions true
showStackTraces true
}
}
dependencies {
testCompile 'org.robolectric:robolectric:3.0'
testCompile 'junit:junit:4.12'
}