forked from pcalcado/java-api-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
125 lines (111 loc) · 4.49 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
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'maven'
sourceCompatibility = 1.6
version = '1.2.0'
group = 'com.soundcloud'
repositories { mavenCentral() }
sourceSets {
examples {
compileClasspath = sourceSets.main.output + sourceSets.main.runtimeClasspath
}
}
dependencies {
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.0.3'
compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.0.3'
compile group: 'org.json', name: 'json', version: '20090211'
testCompile group: 'junit', name: 'junit-dep', version: '4.8.2'
testCompile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3.RC2'
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3.RC2'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.8.5'
}
uploadArchives {
repositories {
mavenDeployer {
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots',
id: 'sonatype-nexus-snapshots') {
authentication(getAuth('sonatype-nexus-snapshots'))
}
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/',
id: 'sonatype-nexus-staging') {
authentication(getAuth('sonatype-nexus-staging'))
}
pom {
project {
name 'SoundCloud Java API wrapper'
description 'SoundCloud Java API wrapper (OAuth2 only), works on Android'
url 'https://github.com/soundcloud/java-api-wrapper#readme'
inceptionYear '2011'
licenses {
license {
name 'The MIT License'
url 'https://github.com/soundcloud/java-api-wrapper/raw/master/LICENSE'
distribution 'repo'
}
}
}
withXml { xml ->
new XmlParser().parse(new File("pom-include.xml")).children().each { kid -> xml.asNode().append(kid) }
}
}
}
}
}
[compileJava, compileTestJava]*.options*.compilerArgs = ['-Xlint:all']
ext.httpDebug = ['org.apache.commons.logging.Log': 'org.apache.commons.logging.impl.SimpleLog',
'org.apache.commons.logging.simplelog.showdatetime': 'true',
'org.apache.commons.logging.simplelog.log.org.apache.http': 'DEBUG',
'org.apache.commons.logging.simplelog.log.org.apache.http.wire': 'ERROR']
def example(name, mainClass, arguments) {
task(name, dependsOn: ['compileJava', 'compileExamplesJava']) << {
javaexec {
main = 'com.soundcloud.api.examples.'+mainClass
classpath = sourceSets.main.runtimeClasspath + sourceSets.examples.output
if (logger.debugEnabled) systemProperties ext.httpDebug
args arguments.call()
}
}
}
example('createWrapper', 'CreateWrapper', { [client_id, client_secret, login, password] })
example('facebookLogin', 'FacebookLogin', { [] })
example('getResource', 'GetResource', { resource })
example('putResource', 'PutResource', { [resource, content, contentType] })
example('postResource', 'PostResource', { [resource, content, contentType] })
example('uploadFile', 'UploadFile', { file })
example('dumpToken', 'DumpToken', { [] })
task writePom << {
uploadArchives.repositories.mavenDeployer().getPom().writeTo("pom.xml")
}
task doc(type: Javadoc) {
source = sourceSets.main.allJava
title = "SoundCloud Java API Wrapper $version"
classpath = sourceSets.main.compileClasspath
destinationDir = new File(new File(buildDir, 'javadoc'), version)
options.version = true
options.links = [
"http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/",
"http://json.org/javadoc/"
]
//options.stylesheetFile = new File('styles.css')
}
task jarAll(type: Jar) {
description = "Build a jar file with all dependencies"
dependsOn configurations.runtime, sourceSets.main.output, sourceSets.examples.output
archiveName = project.name + "-" + version +"-all.jar"
from { (configurations.runtime + sourceSets.main.output + sourceSets.examples.output ).collect {
it.isDirectory() ? it : zipTree(it) }
}
}
def getAuth(repo_id) {
def m2_settings = new File("${System.getProperty('user.home')}/.m2/settings.xml")
if (m2_settings.exists()) {
def settings = new XmlSlurper().parse(m2_settings)
def repo = settings.servers.server.find { it.id.text() == repo_id }
if (repo != null) return [userName: repo.username.text(), password: repo.password.text()]
}
[:]
}
task printDebug << {
println ext.httpDebug.collect { "-D"+it.key+"="+it.value }.join(' ')
}