|
1 | | -apply plugin: 'idea' |
2 | | -apply plugin: 'eclipse' |
3 | | - |
4 | | -group = 'com.launchdarkly' |
5 | | -version = '5.3.0' |
| 1 | +// This replaces the code generator's default build.gradle template (see: |
| 2 | +// https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/build.gradle.mustache) |
| 3 | +// which had a number of issues making it unsuitable for the LaunchDarkly API |
| 4 | +// client build: it relied on a very old version of Gradle and the Gradle plugins, |
| 5 | +// it used the obsolete jcenter repository, and it did not include the necessary |
| 6 | +// javax.annotation dependency. It also had the option of building for Android, |
| 7 | +// but we do not need that. This script also adds code signing and pom properties. |
| 8 | + |
| 9 | +// IMPORTANT: If the Java client fails to build due to a dependency problem, it |
| 10 | +// probably means that the Swagger code generator changed the dependencies in its |
| 11 | +// own build.gradle and we did not update them here. Unfortunately, overriding the |
| 12 | +// build.gradle in this way does not allow us to copy their dependencies. |
6 | 13 |
|
7 | 14 | buildscript { |
8 | 15 | repositories { |
9 | | - jcenter() |
10 | | - } |
11 | | - dependencies { |
12 | | - classpath 'com.android.tools.build:gradle:2.3.+' |
13 | | - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' |
| 16 | + mavenLocal() |
| 17 | + mavenCentral() |
14 | 18 | } |
15 | 19 | } |
16 | 20 |
|
17 | | -repositories { |
18 | | - jcenter() |
| 21 | +plugins { |
| 22 | + id 'java' |
| 23 | + id 'maven-publish' |
| 24 | + id 'signing' |
| 25 | + id 'io.codearte.nexus-staging' version '0.12.0' |
| 26 | + id 'org.ajoberstar.github-pages' version '1.7.2' |
19 | 27 | } |
20 | 28 |
|
| 29 | +repositories { |
| 30 | + mavenLocal() |
| 31 | + mavenCentral() |
| 32 | +} |
21 | 33 |
|
22 | | -if(hasProperty('target') && target == 'android') { |
23 | | - |
24 | | - apply plugin: 'com.android.library' |
25 | | - apply plugin: 'com.github.dcendents.android-maven' |
| 34 | +def ossrhUsername = hasProperty('ossrhUsername') ? ossrhUsername : System.getenv('OSSRH_USERNAME') |
| 35 | +def ossrhPassword = hasProperty('ossrhPassword') ? ossrhPassword : System.getenv('OSSRH_PASSWORD') |
26 | 36 |
|
27 | | - android { |
28 | | - compileSdkVersion 25 |
29 | | - buildToolsVersion '25.0.2' |
30 | | - defaultConfig { |
31 | | - minSdkVersion 14 |
32 | | - targetSdkVersion 25 |
33 | | - } |
34 | | - compileOptions { |
35 | | - sourceCompatibility JavaVersion.VERSION_1_7 |
36 | | - targetCompatibility JavaVersion.VERSION_1_7 |
37 | | - } |
| 37 | +allprojects { |
| 38 | + group = 'com.launchdarkly' |
| 39 | + version = '6.0.0' |
| 40 | + archivesBaseName = 'api-client' |
| 41 | + sourceCompatibility = 1.8 |
| 42 | + targetCompatibility = 1.8 |
| 43 | +} |
38 | 44 |
|
39 | | - // Rename the aar correctly |
40 | | - libraryVariants.all { variant -> |
41 | | - variant.outputs.each { output -> |
42 | | - def outputFile = output.outputFile |
43 | | - if (outputFile != null && outputFile.name.endsWith('.aar')) { |
44 | | - def fileName = "${project.name}-${variant.baseName}-${version}.aar" |
45 | | - output.outputFile = new File(outputFile.parent, fileName) |
46 | | - } |
47 | | - } |
48 | | - } |
| 45 | +dependencies { |
| 46 | + implementation 'io.swagger:swagger-annotations:1.5.24' |
| 47 | + implementation "com.google.code.findbugs:jsr305:3.0.2" |
| 48 | + implementation 'com.squareup.okhttp3:okhttp:4.9.1' |
| 49 | + implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1' |
| 50 | + implementation 'com.google.code.gson:gson:2.8.6' |
| 51 | + implementation 'io.gsonfire:gson-fire:1.8.4' |
| 52 | + implementation 'org.openapitools:jackson-databind-nullable:0.2.1' |
| 53 | + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.10' |
| 54 | + implementation 'org.threeten:threetenbp:1.4.3' |
| 55 | + implementation 'javax.annotation:javax.annotation-api:1.3.2' |
| 56 | + testImplementation 'junit:junit:4.13.1' |
| 57 | +} |
49 | 58 |
|
50 | | - dependencies { |
51 | | - provided 'javax.annotation:jsr250-api:1.0' |
52 | | - } |
| 59 | +githubPages { |
| 60 | + repoUri = 'https://github.com/launchdarkly/api-client-java.git' |
| 61 | + pages { |
| 62 | + from javadoc |
53 | 63 | } |
| 64 | +} |
54 | 65 |
|
55 | | - afterEvaluate { |
56 | | - android.libraryVariants.all { variant -> |
57 | | - def task = project.tasks.create "jar${variant.name.capitalize()}", Jar |
58 | | - task.description = "Create jar artifact for ${variant.name}" |
59 | | - task.dependsOn variant.javaCompile |
60 | | - task.from variant.javaCompile.destinationDir |
61 | | - task.destinationDir = project.file("${project.buildDir}/outputs/jar") |
62 | | - task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" |
63 | | - artifacts.add('archives', task); |
64 | | - } |
65 | | - } |
| 66 | +compileJava { |
| 67 | + // The generated code should be treated as UTF-8 because some of the properties |
| 68 | + // in our openapi.json may include non-ASCII Unicode characters. |
| 69 | + options.encoding = "UTF-8" |
| 70 | +} |
66 | 71 |
|
67 | | - task sourcesJar(type: Jar) { |
68 | | - from android.sourceSets.main.java.srcDirs |
69 | | - classifier = 'sources' |
70 | | - } |
| 72 | +compileTestJava { |
| 73 | + options.encoding = "UTF-8" |
| 74 | +} |
71 | 75 |
|
72 | | - artifacts { |
73 | | - archives sourcesJar |
74 | | - } |
| 76 | +javadoc { |
| 77 | + options.encoding = "UTF-8" |
| 78 | +} |
| 79 | + |
| 80 | +task sourceJar(type: Jar, dependsOn: classes) { |
| 81 | + classifier 'sources' |
| 82 | + from sourceSets.main.allSource |
| 83 | +} |
75 | 84 |
|
76 | | -} else { |
| 85 | +task javadocJar(type: Jar, dependsOn: javadoc) { |
| 86 | + classifier = 'javadoc' |
| 87 | + from javadoc.destinationDir |
| 88 | +} |
77 | 89 |
|
78 | | - apply plugin: 'java' |
79 | | - apply plugin: 'maven' |
| 90 | +if (JavaVersion.current().isJava8Compatible()) { |
| 91 | + // Suppress the many Javadoc warnings that we would otherwise get from the generated code |
| 92 | + tasks.withType(Javadoc) { |
| 93 | + options.addBooleanOption('Xdoclint:none', true) |
| 94 | + } |
| 95 | +} |
80 | 96 |
|
81 | | - sourceCompatibility = JavaVersion.VERSION_1_7 |
82 | | - targetCompatibility = JavaVersion.VERSION_1_7 |
| 97 | +nexusStaging { |
| 98 | + packageGroup = "com.launchdarkly" |
| 99 | + username = ossrhUsername |
| 100 | + password = ossrhPassword |
| 101 | +} |
83 | 102 |
|
84 | | - install { |
85 | | - repositories.mavenInstaller { |
86 | | - pom.artifactId = 'api-client' |
| 103 | +publishing { |
| 104 | + repositories { |
| 105 | + maven { |
| 106 | + url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" |
| 107 | + credentials { |
| 108 | + username = ossrhUsername |
| 109 | + password = ossrhPassword |
| 110 | + } |
87 | 111 | } |
88 | 112 | } |
89 | | - |
90 | | - task execute(type:JavaExec) { |
91 | | - main = System.getProperty('mainClass') |
92 | | - classpath = sourceSets.main.runtimeClasspath |
| 113 | + publications { |
| 114 | + mavenJava(MavenPublication) { |
| 115 | + from components.java |
| 116 | + artifactId = 'api-client' |
| 117 | + artifact sourceJar |
| 118 | + artifact javadocJar |
| 119 | + |
| 120 | + pom { |
| 121 | + name = "API Client for Java" |
| 122 | + packaging = 'jar' |
| 123 | + description = 'Official LaunchDarkly API Client for Java' |
| 124 | + url = 'https://github.com/launchdarkly/api-client-java' |
| 125 | + |
| 126 | + licenses { |
| 127 | + license { |
| 128 | + name = 'The Apache License, Version 2.0' |
| 129 | + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' |
| 130 | + } |
| 131 | + } |
| 132 | + |
| 133 | + developers { |
| 134 | + developer { |
| 135 | + id = 'launchdarkly' |
| 136 | + name = 'LaunchDarkly' |
| 137 | + |
| 138 | + } |
| 139 | + } |
| 140 | + |
| 141 | + scm { |
| 142 | + connection = 'scm:git:git://github.com/launchdarkly/api-client-java.git' |
| 143 | + developerConnection = 'scm:git:ssh:[email protected]:launchdarkly/api-client-java.git' |
| 144 | + url = 'https://github.com/launchdarkly/api-client-java' |
| 145 | + } |
| 146 | + } |
| 147 | + } |
93 | 148 | } |
94 | 149 | } |
95 | 150 |
|
96 | | -dependencies { |
97 | | - compile 'io.swagger:swagger-annotations:1.5.17' |
98 | | - compile 'com.squareup.okhttp:okhttp:2.7.5' |
99 | | - compile 'com.squareup.okhttp:logging-interceptor:2.7.5' |
100 | | - compile 'com.google.code.gson:gson:2.8.1' |
101 | | - compile 'io.gsonfire:gson-fire:1.8.0' |
102 | | - compile 'org.threeten:threetenbp:1.3.5' |
103 | | - testCompile 'junit:junit:4.12' |
| 151 | +signing { |
| 152 | + sign publishing.publications.mavenJava |
104 | 153 | } |
0 commit comments