|
1 | 1 | apply plugin: 'idea' |
2 | 2 | apply plugin: 'eclipse' |
| 3 | +apply plugin: 'com.diffplug.spotless' |
3 | 4 |
|
4 | 5 | group = 'cloud.fastreport.sdk' |
5 | | -version = '2024.1.17' |
| 6 | +version = '2024.1.18' |
6 | 7 |
|
7 | 8 | buildscript { |
8 | 9 | repositories { |
9 | 10 | mavenCentral() |
10 | 11 | } |
11 | 12 | dependencies { |
12 | | - classpath 'com.android.tools.build:gradle:1.5.+' |
13 | | - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' |
| 13 | + classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0' |
14 | 14 | } |
15 | 15 | } |
16 | 16 |
|
17 | 17 | repositories { |
18 | 18 | mavenCentral() |
19 | 19 | } |
20 | 20 |
|
| 21 | +apply plugin: 'java' |
| 22 | +apply plugin: 'maven-publish' |
21 | 23 |
|
22 | | -if(hasProperty('target') && target == 'android') { |
| 24 | +sourceCompatibility = JavaVersion.VERSION_11 |
| 25 | +targetCompatibility = JavaVersion.VERSION_11 |
23 | 26 |
|
24 | | - apply plugin: 'com.android.library' |
25 | | - apply plugin: 'com.github.dcendents.android-maven' |
26 | | - |
27 | | - android { |
28 | | - compileSdkVersion 23 |
29 | | - buildToolsVersion '23.0.2' |
30 | | - defaultConfig { |
31 | | - minSdkVersion 14 |
32 | | - targetSdkVersion 22 |
33 | | - } |
34 | | - compileOptions { |
35 | | - sourceCompatibility JavaVersion.VERSION_1_8 |
36 | | - targetCompatibility JavaVersion.VERSION_1_8 |
37 | | - } |
38 | | - |
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 | | - } |
49 | | - |
50 | | - dependencies { |
51 | | - provided "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" |
52 | | - } |
| 27 | +// Some text from the schema is copy pasted into the source files as UTF-8 |
| 28 | +// but the default still seems to be to use platform encoding |
| 29 | +tasks.withType(JavaCompile) { |
| 30 | + configure(options) { |
| 31 | + options.encoding = 'UTF-8' |
53 | 32 | } |
| 33 | +} |
| 34 | +javadoc { |
| 35 | + options.encoding = 'UTF-8' |
| 36 | +} |
54 | 37 |
|
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.destinationDirectory |
61 | | - task.destinationDirectory = project.file("${project.buildDir}/outputs/jar") |
62 | | - task.archiveFileName = "${project.name}-${variant.baseName}-${version}.jar" |
63 | | - artifacts.add('archives', task); |
| 38 | +publishing { |
| 39 | + publications { |
| 40 | + maven(MavenPublication) { |
| 41 | + artifactId = 'fastreport-cloud-sdk' |
| 42 | + from components.java |
64 | 43 | } |
65 | 44 | } |
| 45 | +} |
66 | 46 |
|
67 | | - task sourcesJar(type: Jar) { |
68 | | - from android.sourceSets.main.java.srcDirs |
69 | | - classifier = 'sources' |
70 | | - } |
71 | | - |
72 | | - artifacts { |
73 | | - archives sourcesJar |
74 | | - } |
75 | | - |
76 | | -} else { |
77 | | - |
78 | | - apply plugin: 'java' |
79 | | - apply plugin: 'maven-publish' |
| 47 | +task execute(type:JavaExec) { |
| 48 | + main = System.getProperty('mainClass') |
| 49 | + classpath = sourceSets.main.runtimeClasspath |
| 50 | +} |
80 | 51 |
|
81 | | - sourceCompatibility = JavaVersion.VERSION_1_8 |
82 | | - targetCompatibility = JavaVersion.VERSION_1_8 |
| 52 | +task sourcesJar(type: Jar, dependsOn: classes) { |
| 53 | + classifier = 'sources' |
| 54 | + from sourceSets.main.allSource |
| 55 | +} |
83 | 56 |
|
84 | | - publishing { |
85 | | - publications { |
86 | | - maven(MavenPublication) { |
87 | | - artifactId = 'fastreport-cloud-sdk' |
88 | | - from components.java |
89 | | - } |
90 | | - } |
91 | | - } |
| 57 | +task javadocJar(type: Jar, dependsOn: javadoc) { |
| 58 | + classifier = 'javadoc' |
| 59 | + from javadoc.destinationDir |
| 60 | +} |
92 | 61 |
|
93 | | - task execute(type:JavaExec) { |
94 | | - main = System.getProperty('mainClass') |
95 | | - classpath = sourceSets.main.runtimeClasspath |
96 | | - } |
| 62 | +artifacts { |
| 63 | + archives sourcesJar |
| 64 | + archives javadocJar |
97 | 65 | } |
98 | 66 |
|
| 67 | + |
99 | 68 | ext { |
100 | | - swagger_annotations_version = "1.6.3" |
101 | | - jackson_version = "2.13.4" |
102 | | - jackson_databind_version = "2.13.4.2" |
103 | | - jackson_databind_nullable_version = "0.2.6" |
| 69 | + jackson_version = "2.14.1" |
104 | 70 | jakarta_annotation_version = "1.3.5" |
105 | | - google_api_client_version = "1.32.2" |
106 | | - jersey_common_version = "2.25.1" |
107 | | - jodatime_version = "2.9.9" |
108 | 71 | junit_version = "4.13.2" |
| 72 | + httpmime_version = "4.5.13" |
109 | 73 | } |
110 | 74 |
|
111 | 75 | dependencies { |
112 | | - implementation "io.swagger:swagger-annotations:$swagger_annotations_version" |
113 | 76 | implementation "com.google.code.findbugs:jsr305:3.0.2" |
114 | | - implementation "com.google.api-client:google-api-client:${google_api_client_version}" |
115 | | - implementation "org.glassfish.jersey.core:jersey-common:${jersey_common_version}" |
116 | 77 | implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version" |
117 | 78 | implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" |
118 | | - implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version" |
119 | | - implementation "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version" |
120 | | - implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version" |
| 79 | + implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version" |
121 | 80 | implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version" |
| 81 | + implementation "org.openapitools:jackson-databind-nullable:0.2.1" |
122 | 82 | implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" |
| 83 | + implementation "org.apache.httpcomponents:httpmime:$httpmime_version" |
123 | 84 | testImplementation "junit:junit:$junit_version" |
124 | 85 | } |
| 86 | + |
| 87 | +// Use spotless plugin to automatically format code, remove unused import, etc |
| 88 | +// To apply changes directly to the file, run `gradlew spotlessApply` |
| 89 | +// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle |
| 90 | +spotless { |
| 91 | + // comment out below to run spotless as part of the `check` task |
| 92 | + enforceCheck false |
| 93 | + format 'misc', { |
| 94 | + // define the files (e.g. '*.gradle', '*.md') to apply `misc` to |
| 95 | + target '.gitignore' |
| 96 | + // define the steps to apply to those files |
| 97 | + trimTrailingWhitespace() |
| 98 | + indentWithSpaces() // Takes an integer argument if you don't like 4 |
| 99 | + endWithNewline() |
| 100 | + } |
| 101 | + java { |
| 102 | + // don't need to set target, it is inferred from java |
| 103 | + // apply a specific flavor of google-java-format |
| 104 | + googleJavaFormat('1.8').aosp().reflowLongStrings() |
| 105 | + removeUnusedImports() |
| 106 | + importOrder() |
| 107 | + } |
| 108 | +} |
0 commit comments