Skip to content

Commit c5af9cd

Browse files
committed
Temporary disable Generated annotation for Android, if tool java version is too high
Generated annotation used by jsonschema2pojo is not compatible with packages used in Android and selected by AGP.
1 parent 35359c6 commit c5af9cd

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

demo/android/app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,6 @@ jsonSchema2Pojo {
130130

131131
// Whether to initialize Set and List fields as empty collections, or leave them as null.
132132
boolean initializeCollections = true
133+
// Include @Generated annotation
134+
boolean includeGeneratedAnnotation = true
133135
}

demo/android/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
rootProject.name = 'js2p-gradle sample'
1+
rootProject.name = 'js2d-gradle Android sample'
22

33
include ':app'
44
include ':lib'

src/main/groovy/com/github/eirnym/js2p/JsonSchemaPlugin.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ class JsonSchemaPlugin implements Plugin<Project> {
7171
}
7272

7373
JsonSchemaExtension config = project.extensions.getByType(JsonSchemaExtension)
74+
75+
if (System.getProperty('java.specification.version').toFloat() >= 9) {
76+
config.includeGeneratedAnnotation = false // Temporary fixes #71 and upstream issue #1212 (used Generated annotation is not compatible with AGP 7+)
77+
}
78+
7479
ConfigurableFileCollection sourceFiles
7580

7681
if (config.source.isEmpty()) {

0 commit comments

Comments
 (0)