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

The application plugin's run task should not change the working directory #6074

Open
sschuberth opened this issue Jul 24, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@sschuberth
Copy link
Contributor

commented Jul 24, 2018

Gradle 4.9 added support for passing arguments to JavaExec tasks. By default, JavaExec tasks change the working directory to the project directory. However, this default behavior is confusing when using the application plugin's run task (which is a JavaExec task) and passing relative file paths as part of the arguments.

Expected Behavior

Assume a multi-project and a directory structure like

+ $HOME
  |
  + development (contains root build.gradle file and input-file.txt file)
     |
     + app (contains app build.gradle file)
     |
     + lib (contains lib build.gradle file)

When running an application like

cd ~/development
./gradlew app:run --args="--input input-file.txt"

I would expect the application to look for input-file.txt at ~/development/input-file.txt.

Current Behavior

The application looks for input-file.txt at ~/development/app/input-file.txt.

Context

Now that arguments can be passed to JavaExec tasks, it's convenient to use that feature as a drop-in replacement for calling the start scripts that can be generated by the application plugin. However, currently relative file paths need to be adjusted to take the implicit change of the working directory into account.

Steps to Reproduce (for bugs)

I wouldn't necessarily consider this to be a bug, but rather an ask for a change in behavior to increase convenience.

Your Environment

------------------------------------------------------------
Gradle 4.9
------------------------------------------------------------

Build time:   2018-07-16 08:14:03 UTC
Revision:     efcf8c1cf533b03c70f394f270f46a174c738efc

Kotlin DSL:   0.18.4
Kotlin:       1.2.41
Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM:          1.8.0_162 (Oracle Corporation 25.162-b12)
OS:           Windows 10 10.0 amd64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.