Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use the same module name as archive file name for the jar file #921

Open
EchoEllet opened this issue May 13, 2024 · 2 comments
Open

Comments

@EchoEllet
Copy link

EchoEllet commented May 13, 2024

Shadow Version

8.1.1

Gradle Version

8.7

Expected Behavior

Should we be able to use the same module name as jar file? let's say you have a module name called example-module-name and the jar file name would be example-module-name.jar

Actual Behavior

If you use the following:

tasks.withType(com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar::class) {
    archiveFileName.set("example-module-name.jar")
}

and run ./gradlew build you will get the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Some problems were found with the configuration of task ':example-module-name:shadowJar' (type 'ShadowJar').
  - Gradle detected a problem with the following location: '/Users/yourusername/Developer/projects/yourproject/example-module-name/build/libs/example-module-name.jar'.
    
    Reason: Task ':example-module-name:distZip' uses this output of task ':example-module-name:shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':example-module-name:shadowJar' as an input of ':example-module-name:distZip'.
      2. Declare an explicit dependency on ':example-module-name:shadowJar' from ':example-module-name:distZip' using Task#dependsOn.
      3. Declare an explicit dependency on ':example-module-name:shadowJar' from ':example-module-name:distZip' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.7/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
  - Gradle detected a problem with the following location: '/Users/ellet/Developer/projects/minecraft-sync/example-module-name/build/libs/example-module-name.jar'.
    
    Reason: Task ':example-module-name:distTar' uses this output of task ':example-module-name:shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':example-module-name:shadowJar' as an input of ':example-module-name:distTar'.
      2. Declare an explicit dependency on ':example-module-name:shadowJar' from ':example-module-name:distTar' using Task#dependsOn.
      3. Declare an explicit dependency on ':example-module-name:shadowJar' from ':example-module-name:distTar' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.7/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
  - Gradle detected a problem with the following location: '/Users/ellet/Developer/projects/minecraft-sync/example-module-name/build/libs/example-module-name.jar'.
    
    Reason: Task ':example-module-name:startScripts' uses this output of task ':example-module-name:shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':example-module-name:shadowJar' as an input of ':example-module-name:startScripts'.
      2. Declare an explicit dependency on ':example-module-name:shadowJar' from ':example-module-name:startScripts' using Task#dependsOn.
      3. Declare an explicit dependency on ':example-module-name:shadowJar' from ':example-module-name:startScripts' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.7/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

Content of Shadow JAR (jar tf <jar file> - post link to GIST if too long)

I can't get the jar builded

@Goooler
Copy link
Member

Goooler commented May 16, 2024

The stacktrace shows clearly, try

tasks.named("distZip") {
    dependsOn(tasks.withType(com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar::class))
}

@EchoEllet
Copy link
Author

EchoEllet commented May 16, 2024

The stacktrace shows clearly, try

tasks.named("distZip") {
    dependsOn(tasks.withType(com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar::class))
}

Thank you, I will try that, but I'm not sure how it's related to distZib task (it could be that shadowJar depends on distSize but that's already by default). This error only shows when using the exact same module name + .jar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants