Home > Net >  Why my java api won't work with gradle 'from components.java' but with 'from com
Why my java api won't work with gradle 'from components.java' but with 'from com

Time:12-16

Using the repository https://repo.theprogramsrc.xyz/repository/maven-public/ if you import the artifact xyz.theprogramsrc:simplecoreapi:0.0.1.1-SNAPSHOT and try to import the class xyz.theprogramsrc.simplecoreapi.global.module.Module you'll notice that the IDE doesn't recognize the import, but the dependency is in the dependencies list.

Now if you try the same using the version 0.0.1.2-SNAPSHOT you'll notice that now you can use the import.

What's the difference? the line 124, from components.java doesn't work, but from components.kotlin works, my issue is that if I use components.kotlin it doesn't contain the shadowed nor the implementations, only the source code, but if I use components.java it contains everything but the ide won't recognize the imports. I think this might be an issue with Kotlin and shadowjar...

Here is my project for reference: GitHub: TheProgramSrc/SimpleCoreAPI

Edit

I just confirmed that this issue is an IntelliJ issue, why? I don't really know, I'll post the answer here once is available in the issue I created:

https://youtrack.jetbrains.com/issue/IDEA-284719

CodePudding user response:

This issue can be solved by adding the following lines to you shadowJar task:

shadowJar {
    // ...
    mergeServiceFiles()
    exclude('**/*.kotlin_metadata')
    exclude('**/*.kotlin_builtins')
    // ...
}

Thanks to the following comment I solved my problem: https://youtrack.jetbrains.com/issue/KT-25709#focus=Comments-27-5180542.0-0

  • Related