-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
156 lines (137 loc) · 4.78 KB
/
build.gradle
File metadata and controls
156 lines (137 loc) · 4.78 KB
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
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'io.swagger:swagger-codegen:2.4.16'
}
}
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
}
repositories {
mavenCentral()
jcenter()
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
import io.swagger.codegen.config.CodegenConfigurator
import io.swagger.codegen.DefaultGenerator
def swaggerInput = 'appbrain-api-spec.json'
def swaggerOutputDir = file('build/swagger')
task generateApi {
inputs.file(swaggerInput)
outputs.dir(swaggerOutputDir)
doLast {
def config = new CodegenConfigurator()
config.setInputSpec(swaggerInput)
config.setOutputDir(swaggerOutputDir.path)
config.setLang('java')
config.setAdditionalProperties([
'invokerPackage' : 'com.appbrain.client',
'modelPackage' : 'com.appbrain.client.model',
'apiPackage' : 'com.appbrain.client.api',
'groupId' : 'com.appbrain',
'artifactId' : 'appbrain-api-client',
'dateLibrary' : 'java8',
'hideGenerationTimestamp': true
])
new DefaultGenerator().opts(config.toClientOptInput()).generate()
}
}
clean.doFirst {
delete(swaggerOutputDir)
}
configurations {
swagger
}
sourceSets {
main {
java {
srcDirs = ['src/main/java', "${project.buildDir.path}/swagger/src/main/java"]
}
}
}
compileJava.dependsOn generateApi
version = '1.0.2-SNAPSHOT'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
publishing {
publications {
appbrainApiClient(MavenPublication) {
groupId = 'com.appbrain'
artifactId = 'appbrain-api-client'
version = version
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'AppBrain API Client'
description = 'The AppBrain API is a web service that allows automated interaction with AppBrain.'
url = 'https://www.appbrain.com/info/help/api/appbrain-api.html'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'appbrain'
name = 'AppBrain Team'
email = 'contact@appbrain.com'
organization = "AppBrain"
organizationUrl = "https://www.appbrain.com"
}
}
scm {
connection = 'scm:git:git://github.com/appbrain/appbrain-api-client-java.git'
developerConnection = 'scm:git:ssh://github.com:appbrain/appbrain-api-client-java.git'
url = 'https://github.com/appbrain/appbrain-api-client-java'
}
}
}
}
repositories {
maven {
def stagingRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = publishing.publications.appbrainApiClient.version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : stagingRepoUrl
credentials {
username project.hasProperty('sonatypeUsername') ? project.property('sonatypeUsername') : ''
password project.hasProperty('sonatypePassword') ? project.property('sonatypePassword') : ''
}
}
}
}
signing {
required { isReleaseVersion && gradle.taskGraph.hasTask("publish") }
sign publishing.publications.appbrainApiClient
}
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
// the recommended gradle plugin to publish artifacts is maven-publish
// however jitpack expects a task "install" which is provided by the older "maven" plugin
task install(dependsOn: 'publishToMavenLocal')
dependencies {
implementation 'io.swagger:swagger-annotations:1.6.1'
implementation 'com.squareup.okhttp:okhttp:2.7.5'
implementation 'com.squareup.okhttp:logging-interceptor:2.7.5'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'io.gsonfire:gson-fire:1.8.0'
}