driptaroop / plantuml-generator-gradle

PlantUml generator plugin for Gradle
4 stars 0 forks source link

Fails to recognize main sourceSet in Android #6

Open es0329 opened 2 years ago

es0329 commented 2 years ago

Hi. I'm curious how I'd generate UML for a native Android codebase, written in Kotlin 1.5.31 and built with Gradle 7.3.3, or the level of effort to make it possible.

Version 0.0.3 of the plugin is applied by the Kotlin plugins DSL and configured with the sample PlantUmlGeneratorTask, only editing the scanPackages line to assign my own value. Its execution is failing.

> ./gradlew generateUml

> Task :app:generateUml FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:generateUml'.
> no main source set

BUILD FAILED in 2s

That exception is thrown at UmlGenerationConfig.getCompileClassLoader().

However, Android does have a main sourceSet by default. The Android Gradle Plugin also offers a sourceSets task to log their information; below is that output for the :app module of my project. While there are several sourceSets in an Android project, main is confirmed among them.

> ./gradlew app:sourceSets

> Task :app:sourceSets

------------------------------------------------------------
Project ':app'
------------------------------------------------------------

androidTest
-----------
Compile configuration: androidTestCompile
build.gradle name: android.sourceSets.androidTest
Java sources: [app/src/androidTest/java, app/src/androidTest/kotlin]
Kotlin sources: [app/src/androidTest/kotlin, app/src/androidTest/java]
Manifest file: app/src/androidTest/AndroidManifest.xml
Android resources: [app/src/androidTest/res]
Assets: [app/src/androidTest/assets]
AIDL sources: [app/src/androidTest/aidl]
RenderScript sources: [app/src/androidTest/rs]
JNI sources: [app/src/androidTest/jni]
JNI libraries: [app/src/androidTest/jniLibs]
Java-style resources: [app/src/androidTest/resources]

androidTestDebug
----------------
Compile configuration: androidTestDebugCompile
build.gradle name: android.sourceSets.androidTestDebug
Java sources: [app/src/androidTestDebug/java, app/src/androidTestDebug/kotlin]
Kotlin sources: [app/src/androidTestDebug/kotlin, app/src/androidTestDebug/java]
Manifest file: app/src/androidTestDebug/AndroidManifest.xml
Android resources: [app/src/androidTestDebug/res]
Assets: [app/src/androidTestDebug/assets]
AIDL sources: [app/src/androidTestDebug/aidl]
RenderScript sources: [app/src/androidTestDebug/rs]
JNI sources: [app/src/androidTestDebug/jni]
JNI libraries: [app/src/androidTestDebug/jniLibs]
Java-style resources: [app/src/androidTestDebug/resources]

androidTestDev
--------------
Compile configuration: androidTestDevCompile
build.gradle name: android.sourceSets.androidTestDev
Java sources: [app/src/androidTestDev/java, app/src/androidTestDev/kotlin]
Kotlin sources: [app/src/androidTestDev/kotlin, app/src/androidTestDev/java]
Manifest file: app/src/androidTestDev/AndroidManifest.xml
Android resources: [app/src/androidTestDev/res]
Assets: [app/src/androidTestDev/assets]
AIDL sources: [app/src/androidTestDev/aidl]
RenderScript sources: [app/src/androidTestDev/rs]
JNI sources: [app/src/androidTestDev/jni]
JNI libraries: [app/src/androidTestDev/jniLibs]
Java-style resources: [app/src/androidTestDev/resources]

androidTestDevDebug
-------------------
Compile configuration: androidTestDevDebugCompile
build.gradle name: android.sourceSets.androidTestDevDebug
Java sources: [app/src/androidTestDevDebug/java]
Kotlin sources: [app/src/androidTestDevDebug/kotlin, app/src/androidTestDevDebug/java]
Manifest file: app/src/androidTestDevDebug/AndroidManifest.xml
Android resources: [app/src/androidTestDevDebug/res]
Assets: [app/src/androidTestDevDebug/assets]
AIDL sources: [app/src/androidTestDevDebug/aidl]
RenderScript sources: [app/src/androidTestDevDebug/rs]
JNI sources: [app/src/androidTestDevDebug/jni]
JNI libraries: [app/src/androidTestDevDebug/jniLibs]
Java-style resources: [app/src/androidTestDevDebug/resources]

androidTestProd
---------------
Compile configuration: androidTestProdCompile
build.gradle name: android.sourceSets.androidTestProd
Java sources: [app/src/androidTestProd/java, app/src/androidTestProd/kotlin]
Kotlin sources: [app/src/androidTestProd/kotlin, app/src/androidTestProd/java]
Manifest file: app/src/androidTestProd/AndroidManifest.xml
Android resources: [app/src/androidTestProd/res]
Assets: [app/src/androidTestProd/assets]
AIDL sources: [app/src/androidTestProd/aidl]
RenderScript sources: [app/src/androidTestProd/rs]
JNI sources: [app/src/androidTestProd/jni]
JNI libraries: [app/src/androidTestProd/jniLibs]
Java-style resources: [app/src/androidTestProd/resources]

androidTestRelease
------------------
Compile configuration: androidTestReleaseCompile
build.gradle name: android.sourceSets.androidTestRelease
Java sources: [app/src/androidTestRelease/java, app/src/androidTestRelease/kotlin]
Kotlin sources: [app/src/androidTestRelease/kotlin, app/src/androidTestRelease/java]
Manifest file: app/src/androidTestRelease/AndroidManifest.xml
Android resources: [app/src/androidTestRelease/res]
Assets: [app/src/androidTestRelease/assets]
AIDL sources: [app/src/androidTestRelease/aidl]
RenderScript sources: [app/src/androidTestRelease/rs]
JNI sources: [app/src/androidTestRelease/jni]
JNI libraries: [app/src/androidTestRelease/jniLibs]
Java-style resources: [app/src/androidTestRelease/resources]

debug
-----
Compile configuration: debugCompile
build.gradle name: android.sourceSets.debug
Java sources: [app/src/debug/java, app/src/debug/kotlin]
Kotlin sources: [app/src/debug/kotlin, app/src/debug/java]
Manifest file: app/src/debug/AndroidManifest.xml
Android resources: [app/src/debug/res]
Assets: [app/src/debug/assets]
AIDL sources: [app/src/debug/aidl]
RenderScript sources: [app/src/debug/rs]
JNI sources: [app/src/debug/jni]
JNI libraries: [app/src/debug/jniLibs]
Java-style resources: [app/src/debug/resources]

dev
---
Compile configuration: devCompile
build.gradle name: android.sourceSets.dev
Java sources: [app/src/dev/java, app/src/dev/kotlin]
Kotlin sources: [app/src/dev/kotlin, app/src/dev/java]
Manifest file: app/src/dev/AndroidManifest.xml
Android resources: [app/src/dev/res]
Assets: [app/src/dev/assets]
AIDL sources: [app/src/dev/aidl]
RenderScript sources: [app/src/dev/rs]
JNI sources: [app/src/dev/jni]
JNI libraries: [app/src/dev/jniLibs]
Java-style resources: [app/src/dev/resources]

devDebug
--------
Compile configuration: devDebugCompile
build.gradle name: android.sourceSets.devDebug
Java sources: [app/src/devDebug/java]
Kotlin sources: [app/src/devDebug/kotlin, app/src/devDebug/java]
Manifest file: app/src/devDebug/AndroidManifest.xml
Android resources: [app/src/devDebug/res]
Assets: [app/src/devDebug/assets]
AIDL sources: [app/src/devDebug/aidl]
RenderScript sources: [app/src/devDebug/rs]
JNI sources: [app/src/devDebug/jni]
JNI libraries: [app/src/devDebug/jniLibs]
Java-style resources: [app/src/devDebug/resources]

main
----
Compile configuration: compile
build.gradle name: android.sourceSets.main
Java sources: [app/src/main/java, app/src/main/kotlin]
Kotlin sources: [app/src/main/kotlin, app/src/main/java]
Manifest file: app/src/main/AndroidManifest.xml
Android resources: [app/src/main/res]
Assets: [app/src/main/assets]
AIDL sources: [app/src/main/aidl]
RenderScript sources: [app/src/main/rs]
JNI sources: [app/src/main/jni]
JNI libraries: [app/src/main/jniLibs]
Java-style resources: [app/src/main/resources]

prod
----
Compile configuration: prodCompile
build.gradle name: android.sourceSets.prod
Java sources: [app/src/prod/java, app/src/prod/kotlin]
Kotlin sources: [app/src/prod/kotlin, app/src/prod/java]
Manifest file: app/src/prod/AndroidManifest.xml
Android resources: [app/src/prod/res]
Assets: [app/src/prod/assets]
AIDL sources: [app/src/prod/aidl]
RenderScript sources: [app/src/prod/rs]
JNI sources: [app/src/prod/jni]
JNI libraries: [app/src/prod/jniLibs]
Java-style resources: [app/src/prod/resources]

prodRelease
-----------
Compile configuration: prodReleaseCompile
build.gradle name: android.sourceSets.prodRelease
Java sources: [app/src/prodRelease/java]
Kotlin sources: [app/src/prodRelease/kotlin, app/src/prodRelease/java]
Manifest file: app/src/prodRelease/AndroidManifest.xml
Android resources: [app/src/prodRelease/res]
Assets: [app/src/prodRelease/assets, app/build/generated/assets/sentry/prodRelease]
AIDL sources: [app/src/prodRelease/aidl]
RenderScript sources: [app/src/prodRelease/rs]
JNI sources: [app/src/prodRelease/jni]
JNI libraries: [app/src/prodRelease/jniLibs]
Java-style resources: [app/src/prodRelease/resources]

release
-------
Compile configuration: releaseCompile
build.gradle name: android.sourceSets.release
Java sources: [app/src/release/java, app/src/release/kotlin]
Kotlin sources: [app/src/release/kotlin, app/src/release/java]
Manifest file: app/src/release/AndroidManifest.xml
Android resources: [app/src/release/res]
Assets: [app/src/release/assets]
AIDL sources: [app/src/release/aidl]
RenderScript sources: [app/src/release/rs]
JNI sources: [app/src/release/jni]
JNI libraries: [app/src/release/jniLibs]
Java-style resources: [app/src/release/resources]

test
----
Compile configuration: testCompile
build.gradle name: android.sourceSets.test
Java sources: [app/src/test/java, app/src/test/kotlin]
Kotlin sources: [app/src/test/kotlin, app/src/test/java]
Java-style resources: [app/src/test/resources]

testDebug
---------
Compile configuration: testDebugCompile
build.gradle name: android.sourceSets.testDebug
Java sources: [app/src/testDebug/java, app/src/testDebug/kotlin]
Kotlin sources: [app/src/testDebug/kotlin, app/src/testDebug/java]
Java-style resources: [app/src/testDebug/resources]

testDev
-------
Compile configuration: testDevCompile
build.gradle name: android.sourceSets.testDev
Java sources: [app/src/testDev/java, app/src/testDev/kotlin]
Kotlin sources: [app/src/testDev/kotlin, app/src/testDev/java]
Java-style resources: [app/src/testDev/resources]

testDevDebug
------------
Compile configuration: testDevDebugCompile
build.gradle name: android.sourceSets.testDevDebug
Java sources: [app/src/testDevDebug/java]
Kotlin sources: [app/src/testDevDebug/kotlin, app/src/testDevDebug/java]
Java-style resources: [app/src/testDevDebug/resources]

testProd
--------
Compile configuration: testProdCompile
build.gradle name: android.sourceSets.testProd
Java sources: [app/src/testProd/java, app/src/testProd/kotlin]
Kotlin sources: [app/src/testProd/kotlin, app/src/testProd/java]
Java-style resources: [app/src/testProd/resources]

testProdRelease
---------------
Compile configuration: testProdReleaseCompile
build.gradle name: android.sourceSets.testProdRelease
Java sources: [app/src/testProdRelease/java]
Kotlin sources: [app/src/testProdRelease/kotlin, app/src/testProdRelease/java]
Java-style resources: [app/src/testProdRelease/resources]

testRelease
-----------
Compile configuration: testReleaseCompile
build.gradle name: android.sourceSets.testRelease
Java sources: [app/src/testRelease/java, app/src/testRelease/kotlin]
Kotlin sources: [app/src/testRelease/kotlin, app/src/testRelease/java]
Java-style resources: [app/src/testRelease/resources]

BUILD SUCCESSFUL in 835ms

Does anything come to mind that I'm overlooking? I'm also happy to attempt a PR if you have some direction and I understand the change. Or feel free to close this issue if Android support is beyond scope/not of interest.

The plugin works nicely on my pure jvm (non-Android) projects. Thanks for your effort creating it and keep up the great work! 🥇

driptaroop commented 2 years ago

Hey thanks for reaching out. Unfortunately I have little to no idea on android development so I cannot really help in this case. But I can imagine the issue is because only the main sourceset of java plugin is considered (code link).

You can try to add android plugin sourceset here and see if it works. Since I am not actively updating/maintaining this plugin you can either fork this out and create a new plugin for android or create a PR here and I will try to review this as soon as I can. 👍🏼