abrensch / brouter

configurable OSM offline router with elevation awareness, Java + Android
MIT License
473 stars 113 forks source link

Update PMD to 7.0.0 #689

Closed zod closed 2 months ago

zod commented 3 months ago

PMD has finally released version 7.0.0 which offers better analysis and new rules.

It required a gradle update but Android Studio kept nagging me to upgrade gradle & AGP (Android Gradle Plugin) anyway...

zod commented 3 months ago

I've implemented targeting a specific Java version using conventions plugins because the gradle documentation suggested to avoid cross configuration using allprojects/subprojects

Currently it targets Java 11 because we already use some functionality from Java 9. It's mostly in test code but the new Hgt processing also uses it. This code won't be run on Android so it should not cause any issues. Going forward we should pick a Java version we really want to target and adopt the build configuration to treat using newer code as error.

I'd also like to add a dependency from distZip target to :brouter-routing-app:packageRelease to ensure it's built before distZip, but unfortunately adding this dependency won't work if the android SDK isn't present because the target isn't defined. If you have any suggestions I would be very happy :)

afischerdev commented 2 months ago

I made some tests:

afischerdev commented 2 months ago

I'd also like to add a dependency from distZip ...

As you see in the current release, the distribution file is not produced. I used

distZip {
    dependsOn fatJar
    dependsOn (':brouter-routing-app:assemble')
    archiveFileName = 'brouter-' + project.version + '.zip'
}
zod commented 2 months ago

Your suggestion would break builds without android SDK because the :brouter-routing-app:assemble wouldn't exist. The docker build doesn't add the android SDK and therefore would fail.

afischerdev commented 2 months ago

Yes, you are right. This is only a temporary solution to get an apk inside the zip when Android tasks are present. My attempts with doLast or Exception were unsuccessful. So no idea at the moment.

afischerdev commented 2 months ago

I've masked the dependencies now, that should do the job.

if (file('../local.properties').exists()) dependsOn (':brouter-routing-app:assemble')

zod commented 2 months ago

I'm not to happy with this check because not we check for local.properties in multiple locations instead of detecting if the target was added, but let's just use it for now and perhaps I'll come up with a different check in a future PR.

afischerdev commented 2 months ago

@zod I understand that, but we already use this way in settings.gradle. My tests with hasProperty('sdk.dir') or similar were not successful. My be there are other ideas?