|
| 1 | +apply plugin: 'idea' |
| 2 | +apply plugin: 'eclipse' |
| 3 | +{{#sourceFolder}} |
| 4 | +apply plugin: 'java' |
| 5 | +{{/sourceFolder}} |
| 6 | +apply plugin: 'com.diffplug.spotless' |
| 7 | + |
| 8 | +group = '{{groupId}}' |
| 9 | +version = '{{artifactVersion}}' |
| 10 | + |
| 11 | +buildscript { |
| 12 | + repositories { |
| 13 | + mavenCentral() |
| 14 | + } |
| 15 | + dependencies { |
| 16 | + classpath 'com.android.tools.build:gradle:2.3.+' |
| 17 | + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' |
| 18 | + classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0' |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +repositories { |
| 23 | + mavenCentral() |
| 24 | +} |
| 25 | +{{#sourceFolder}} |
| 26 | +sourceSets { |
| 27 | + main.java.srcDirs = ['{{sourceFolder}}'] |
| 28 | +} |
| 29 | + |
| 30 | +{{/sourceFolder}} |
| 31 | +if(hasProperty('target') && target == 'android') { |
| 32 | +
|
| 33 | + apply plugin: 'com.android.library' |
| 34 | + apply plugin: 'com.github.dcendents.android-maven' |
| 35 | +
|
| 36 | + android { |
| 37 | + compileSdkVersion 25 |
| 38 | + buildToolsVersion '25.0.2' |
| 39 | + defaultConfig { |
| 40 | + minSdkVersion 14 |
| 41 | + targetSdkVersion 25 |
| 42 | + } |
| 43 | + compileOptions { |
| 44 | + sourceCompatibility JavaVersion.VERSION_1_8 |
| 45 | + targetCompatibility JavaVersion.VERSION_1_8 |
| 46 | + } |
| 47 | + |
| 48 | + // Rename the aar correctly |
| 49 | + libraryVariants.all { variant -> |
| 50 | + variant.outputs.each { output -> |
| 51 | + def outputFile = output.outputFile |
| 52 | + if (outputFile != null && outputFile.name.endsWith('.aar')) { |
| 53 | + def fileName = "${project.name}-${variant.baseName}-${version}.aar" |
| 54 | + output.outputFile = new File(outputFile.parent, fileName) |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + dependencies { |
| 60 | + provided "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + afterEvaluate { |
| 65 | + android.libraryVariants.all { variant -> |
| 66 | + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar |
| 67 | + task.description = "Create jar artifact for ${variant.name}" |
| 68 | + task.dependsOn variant.javaCompile |
| 69 | + task.from variant.javaCompile.destinationDirectory |
| 70 | + task.destinationDirectory = project.file("${project.buildDir}/outputs/jar") |
| 71 | + task.archiveFileName = "${project.name}-${variant.baseName}-${version}.jar" |
| 72 | + artifacts.add('archives', task) |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + task sourcesJar(type: Jar) { |
| 77 | + from android.sourceSets.main.java.srcDirs |
| 78 | + classifier = 'sources' |
| 79 | + } |
| 80 | + |
| 81 | + artifacts { |
| 82 | + archives sourcesJar |
| 83 | + } |
| 84 | + |
| 85 | +} else { |
| 86 | +
|
| 87 | + apply plugin: 'java' |
| 88 | + apply plugin: 'maven-publish' |
| 89 | +
|
| 90 | + sourceCompatibility = JavaVersion.VERSION_1_8 |
| 91 | + targetCompatibility = JavaVersion.VERSION_1_8 |
| 92 | +
|
| 93 | + publishing { |
| 94 | + publications { |
| 95 | + maven(MavenPublication) { |
| 96 | + artifactId = '{{artifactId}}' |
| 97 | + from components.java |
| 98 | + } |
| 99 | + } |
| 100 | + } |
| 101 | + |
| 102 | + task execute(type:JavaExec) { |
| 103 | + main = System.getProperty('mainClass') |
| 104 | + classpath = sourceSets.main.runtimeClasspath |
| 105 | + } |
| 106 | +} |
| 107 | + |
| 108 | +ext { |
| 109 | + {{#swagger1AnnotationLibrary}} |
| 110 | + swagger_annotations_version = "1.6.9" |
| 111 | + {{/swagger1AnnotationLibrary}} |
| 112 | + {{#swagger2AnnotationLibrary}} |
| 113 | + swagger_annotations_version = "2.2.9" |
| 114 | + {{/swagger2AnnotationLibrary}} |
| 115 | + jakarta_annotation_version = "1.3.5" |
| 116 | + {{#useBeanValidation}} |
| 117 | + bean_validation_version = "2.0.2" |
| 118 | + {{/useBeanValidation}} |
| 119 | +} |
| 120 | + |
| 121 | +dependencies { |
| 122 | + {{#swagger1AnnotationLibrary}} |
| 123 | + implementation "io.swagger:swagger-annotations:$swagger_annotations_version" |
| 124 | + {{/swagger1AnnotationLibrary}} |
| 125 | + {{#swagger2AnnotationLibrary}} |
| 126 | + implementation "io.swagger.core.v3:swagger-annotations:$swagger_annotations_version" |
| 127 | + {{/swagger2AnnotationLibrary}} |
| 128 | + implementation "com.google.code.findbugs:jsr305:3.0.2" |
| 129 | + implementation 'com.squareup.okhttp3:okhttp:4.12.0' |
| 130 | + implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0' |
| 131 | + implementation 'com.google.code.gson:gson:2.9.1' |
| 132 | + implementation 'io.gsonfire:gson-fire:1.9.0' |
| 133 | + implementation 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.6' |
| 134 | + {{#openApiNullable}} |
| 135 | + implementation 'org.openapitools:jackson-databind-nullable:0.2.8' |
| 136 | + {{/openApiNullable}} |
| 137 | + {{#withAWSV4Signature}} |
| 138 | + implementation 'software.amazon.awssdk:auth:2.20.157' |
| 139 | + {{/withAWSV4Signature}} |
| 140 | + {{#hasOAuthMethods}} |
| 141 | + implementation group: 'org.json', name: 'json', version: '20250517' |
| 142 | + implementation group: 'org.apache.oltu.oauth2', name: 'org.apache.oltu.oauth2.client', version: '1.0.2' |
| 143 | + {{/hasOAuthMethods}} |
| 144 | + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.18.0' |
| 145 | + {{#joda}} |
| 146 | + implementation 'joda-time:joda-time:2.9.9' |
| 147 | + {{/joda}} |
| 148 | + {{#dynamicOperations}} |
| 149 | + implementation 'io.swagger.parser.v3:swagger-parser-v3:2.0.30' |
| 150 | + {{/dynamicOperations}} |
| 151 | + implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" |
| 152 | + {{#useBeanValidation}} |
| 153 | + implementation "jakarta.validation:jakarta.validation-api:$bean_validation_version" |
| 154 | + {{/useBeanValidation}} |
| 155 | + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3' |
| 156 | + testImplementation 'org.mockito:mockito-core:3.12.4' |
| 157 | + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3' |
| 158 | +} |
| 159 | + |
| 160 | +javadoc { |
| 161 | + options.tags = [ "http.response.details:a:Http Response Details" ] |
| 162 | +} |
| 163 | + |
| 164 | +// Use spotless plugin to automatically format code, remove unused import, etc |
| 165 | +// To apply changes directly to the file, run `gradlew spotlessApply` |
| 166 | +// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle |
| 167 | +spotless { |
| 168 | + // comment out below to run spotless as part of the `check` task |
| 169 | + enforceCheck false |
| 170 | +
|
| 171 | + format 'misc', { |
| 172 | + // define the files (e.g. '*.gradle', '*.md') to apply `misc` to |
| 173 | + target '.gitignore' |
| 174 | +
|
| 175 | + // define the steps to apply to those files |
| 176 | + trimTrailingWhitespace() |
| 177 | + indentWithSpaces() // Takes an integer argument if you don't like 4 |
| 178 | + endWithNewline() |
| 179 | + } |
| 180 | + java { |
| 181 | + // don't need to set target, it is inferred from java |
| 182 | +
|
| 183 | + // apply a specific flavor of google-java-format |
| 184 | + googleJavaFormat('1.8').aosp().reflowLongStrings() |
| 185 | +
|
| 186 | + removeUnusedImports() |
| 187 | + importOrder() |
| 188 | + } |
| 189 | +} |
| 190 | + |
| 191 | +test { |
| 192 | + // Enable JUnit 5 (Gradle 4.6+). |
| 193 | + useJUnitPlatform() |
| 194 | +
|
| 195 | + // Always run tests, even when nothing changed. |
| 196 | + dependsOn 'cleanTest' |
| 197 | +
|
| 198 | + // Show test results. |
| 199 | + testLogging { |
| 200 | + events "passed", "skipped", "failed" |
| 201 | + } |
| 202 | + |
| 203 | +} |
0 commit comments