dagger: `dagger run` does not work with Gradle

What is the issue?

Gradle does not work when run within a dagger run context.

Log output

Example. I have a simple application in a gradle module called playground. I can run the app easily with the following

$ ./gradlew playground:run -q --console=plain
hi

however, feed this through dagger run ./gradlew playground:run -q --console=plain and the process hangs indefinitely.

Adding a --debug does not offer a whole lot of insight

$  dagger run -s ./gradlew playground:run --debug --console=plain
Connected to engine b406cfb838a0
2023-06-04T14:00:30.865-0400 [INFO] [org.gradle.internal.nativeintegration.services.NativeServices] Initialized native services in: /Users/megame/.gradle/native
2023-06-04T14:00:30.890-0400 [INFO] [org.gradle.internal.nativeintegration.services.NativeServices] Initialized jansi services in: /Users/megame/.gradle/native

At this point, it just hangs indefinitely.

Steps to reproduce

This can be reproduced even without an associated project. Install Gradle (my version is 8.1.1) and run gradle tasks. Assuming you are in a directory with no gradle project, this operation will fail, but it will show some output. Do the same via dagger run -s gradle tasks --console=plain and you will see that even this command hangs.

SDK version

Dagger CLI 0.6.1

OS version

Confirmed on both MacOS Mojave and Ubuntu 22.04

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 16 (13 by maintainers)

Commits related to this issue

Most upvoted comments

I confirm that gradle works since #5712 has been merged:

./hack/dev dagger run gradle tasks
...
█ [4.06s] ERROR gradle tasks
┃                                                                                                                                                                    
┃ Welcome to Gradle 8.4!                                                                                                                                             
┃                                                                                                                                                                    
┃ Here are the highlights of this release:                                                                                                                           
┃  - Compiling and testing with Java 21                                                                                                                              
┃  - Faster Java compilation on Windows                                                                                                                              
┃  - Role focused dependency configurations creation                                                                                                                 
┃                                                                                                                                                                    
┃ For more details see https://docs.gradle.org/8.4/release-notes.html                                                                                                
┃                                                                                                                                                                    
┃ Starting a Gradle Daemon (subsequent builds will be faster)                                                                                                        
┃                                                                                                                                                                    
┃ FAILURE: Build failed with an exception.                                                                                                                           
┃                                                                                                                                                                    
┃ * What went wrong:                                                                                                                                                 
┃ Directory '/Users/tomchauveau/Documents/DAGGER/dagger' does not contain a Gradle build.                                                                            
┃                                                                                                                                                                    
┃ A Gradle build should contain a 'settings.gradle' or 'settings.gradle.kts' file in its root directory. It may also contain a 'build.gradle' or 'build.gradle.kts' f
┃ ile.                                                                                                                                                               
┃                                                                                                                                                                    
┃ To create a new Gradle build in this directory run 'gradle init'                                                                                                   
┃                                                                                                                                                                    
┃ For more information about the 'init' task, please refer to https://docs.gradle.org/8.4/userguide/build_init_plugin.html in the Gradle documentation.              
┃                                                                                                                                                                    
┃ For more details on creating a Gradle build, please refer to https://docs.gradle.org/8.4/userguide/tutorial_using_tasks.html in the Gradle documentation.          
┃                                                                                                                                                                    
┃ * Try:                                                                                                                                                             
┃ > Run gradle init to create a new Gradle build in this directory.                                                                                                  
┃ > Run with --stacktrace option to get the stack trace.                                                                                                             
┃ > Run with --info or --debug option to get more log output.                                                                                                        
┃ > Get more help at https://help.gradle.org.                                                                                                                        
┃                                                                                                                                                                    
┃ BUILD FAILED in 1s                                                                                                                                                 
┻ 
• Engine: 5096d9fac428 (version devel ())

My guess is that gradle needs some control over stdout/stderr/stdin \cc @vito.

I reproduced it, even with an error (i.e., on it’s own the usage error from gradle reports I’m missing some tooling, so it fails early).