Skip to content

Commit

Permalink
Fix detection of targetVersion for Android gradle builds
Browse files Browse the repository at this point in the history
  • Loading branch information
joelittlejohn committed Feb 18, 2023
1 parent 898ca3e commit 0a57923
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/android-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ jobs:
buildTest:
name: Build JDK ${{ matrix.java_version }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: jsonschema2pojo-gradle-plugin/example/android
strategy:
matrix:
java_version: [8]
Expand All @@ -31,5 +28,7 @@ jobs:
distribution: temurin
- name: Install Android SDK
uses: malinskiy/action-android/install-sdk@release/0.1.1
- name: Build project
run: ./gradlew assembleDebug
- name: Install latest jsonschema2pojo SNAPSHOT
run: mvn -B install -DskipTests -Dmaven.javadoc.skip -Dmaven.site.skip
- name: Build projects
run: cd jsonschema2pojo-gradle-plugin/example/android && ./gradlew --info assembleDebug
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ class GenerateJsonSchemaAndroidTask extends SourceTask {

void setTargetVersion(JsonSchemaExtension configuration) {
if (!configuration.targetVersion) {
def compileJavaTask = project.getTasksByName("compileJava", false).first()
configuration.targetVersion = compileJavaTask.getProperties().get("sourceCompatibility")
logger.info 'Using Gradle sourceCompatibility as targetVersion for jsonschema2pojo: ' + configuration.targetVersion
if (project.plugins.hasPlugin("com.android.application")) {
configuration.targetVersion = project.plugins.getPlugin("com.android.application").extension.compileOptions.sourceCompatibility
logger.info 'Using android.compileOptions.sourceCompatibility as targetVersion for jsonschema2pojo: ' + configuration.targetVersion
} else if (project.plugins.hasPlugin("com.android.library")) {
configuration.targetVersion = project.plugins.getPlugin("com.android.library").extension.compileOptions.sourceCompatibility
logger.info 'Using android.compileOptions.sourceCompatibility as targetVersion for jsonschema2pojo: ' + configuration.targetVersion
}
}
}
}

0 comments on commit 0a57923

Please sign in to comment.