Ahmed Riyadh
05/22/2024, 3:11 PMExecution failed for task ':moduleName:compileKotlin'.
> Could not resolve all files for configuration ':moduleName:detachedConfiguration1'.
> Failed to transform JarName-0.0.1.jar to match attributes {artifactType=classpath-entry-snapshot, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for ClasspathEntrySnapshotTransform: /Users/UserName/Developer/projects/ProjectName/build/libs/JarName-0.0.1.
> Check failed.
It happens when I have code in the root project src/main/kotlin
(not a module or sub-module) in the root project, and then I have a Gradle module that implements the root project, for example, let's say you have moduleName
Gradle module, the issue might be with some of the configurations of Gradle but it happens even after disabling all of them.
The `settings.gradle.kts`:
include(":moduleName")
The dependencies of the build.gradle.kts
of the moduleName:
implementation(project(":"))
I tried using enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
but it's the exact same with type-safety
I tried doing this before and it worked but not sure what I'm missing this time.
Thank you.Vampire
05/22/2024, 3:14 PM--stacktrace
or optimally --scan
?Ahmed Riyadh
05/22/2024, 3:17 PM-i
(same as --info
)
and it didn't give me any related info, with --stacktrace
it give me too much info (Slack won't allow me to send a long message)
Caused by: java.lang.IllegalStateException: Check failed.
Vampire
05/22/2024, 3:18 PM--scan
URLAhmed Riyadh
05/22/2024, 3:19 PMVampire
05/22/2024, 3:23 PM/Users/ellet/Developer/projects/minecraft-sync/build/libs/MinecraftSync-0.0.1-experimental.jar
not existing for some reason when it expects it to exist.Vampire
05/22/2024, 3:24 PM:jar
task was skippedAhmed Riyadh
05/22/2024, 3:24 PMVampire
05/22/2024, 3:25 PMSkip reason'Task is enabled' not satisfied
Vampire
05/22/2024, 3:25 PMenabled = false
for the jar
task on the root projectAhmed Riyadh
05/22/2024, 3:25 PM// Disable the normal jar task as we will use the one from Shadow plugin
tasks.jar { enabled = false }
Because I'm using Shadow jarAhmed Riyadh
05/22/2024, 3:25 PMVampire
05/22/2024, 3:26 PMVampire
05/22/2024, 3:27 PM:outgoingVariants
taskAhmed Riyadh
05/22/2024, 3:35 PMtasks.jar { enabled = false }
The reason why it worked before with this code snippet because it already build the jar in build/libs
and I didn't change the version, doing ./gradlew clean
or removing the build
folder will make the issue happen again.Ahmed Riyadh
05/22/2024, 3:39 PMbuild/libs
as this would make it more confusing and I have other reasons, have you used Gradle Shadow plugin before?Vampire
05/22/2024, 3:44 PMVampire
05/22/2024, 3:45 PMI avoid it wherever possibleAnd especially never for anything something else depends on. If at all needing to build fat jars, then only at the end of the dependency chain
Ahmed Riyadh
05/22/2024, 3:46 PMVampire
05/22/2024, 4:04 PMapplication
plugin does it.
If that would be platform dependent, so would be your fat jar.Ahmed Riyadh
05/22/2024, 4:35 PMtasks.jar { enabled = false }
And changed the output of the fat jar provided by shadow jar plugin to somewhere else so the CI doesn't provide the jar that is built by Gradle which is used by other modules, but I still doesn't understand why this is a solution, when I add implementation of module A in a Gradle module B, I can access to all the libraries of of module A in module B, if it depends on the Jar that is built by Gradle then how it can access the libraries? The library built by Jar doesn't include the libraries and it's very small and usually when running an application with that jar built by Gradle, it will give you ClassNotFoundException
if you use libraries, this is why we use fat jar.Vampire
05/22/2024, 6:26 PMjar
does not find the classes.
As I said, you would normally using something like the application
plugin to build a proper distribution that contains your jar, your libraries, anything else you configure, and generated start scripts that put everything together when running.
https://docs.gradle.org/current/userguide/application_plugin.htmlAhmed Riyadh
05/22/2024, 6:27 PMjar
then how it's possible to use the Gradle libraries of the included module/project? Does it store metadata in the jar about the libraries for example?Vampire
05/22/2024, 8:21 PM