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

Closed
sschuberth opened this issue Jul 24, 2018 · 2 comments
Closed

Comments

@sschuberth
Copy link
Contributor

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
sschuberth added a commit to heremaps/gluecodium that referenced this issue Dec 3, 2018
Since Gradle 4.9 the run task can directly take arguments, see

https://docs.gradle.org/4.9/release-notes.html#command-line-args-supported-by-javaexec

However, note that any relative paths specified as arguments are
interpreted as relative to the project directory, see

gradle/gradle#6074

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@here.com>
sschuberth added a commit to heremaps/gluecodium that referenced this issue Dec 6, 2018
Since Gradle 4.9 the run task can directly take arguments, see

https://docs.gradle.org/4.9/release-notes.html#command-line-args-supported-by-javaexec

However, note that any relative paths specified as arguments are
interpreted as relative to the project directory, see

gradle/gradle#6074

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@here.com>
Dschoordsch pushed a commit to heremaps/gluecodium that referenced this issue Mar 12, 2019
Since Gradle 4.9 the run task can directly take arguments, see

https://docs.gradle.org/4.9/release-notes.html#command-line-args-supported-by-javaexec

However, note that any relative paths specified as arguments are
interpreted as relative to the project directory, see

gradle/gradle#6074

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@here.com>
Dschoordsch pushed a commit to heremaps/gluecodium that referenced this issue Mar 12, 2019
Since Gradle 4.9 the run task can directly take arguments, see

https://docs.gradle.org/4.9/release-notes.html#command-line-args-supported-by-javaexec

However, note that any relative paths specified as arguments are
interpreted as relative to the project directory, see

gradle/gradle#6074

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@here.com>
Dschoordsch pushed a commit to heremaps/gluecodium that referenced this issue Mar 13, 2019
Since Gradle 4.9 the run task can directly take arguments, see

https://docs.gradle.org/4.9/release-notes.html#command-line-args-supported-by-javaexec

However, note that any relative paths specified as arguments are
interpreted as relative to the project directory, see

gradle/gradle#6074

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@here.com>
Dschoordsch pushed a commit to heremaps/gluecodium that referenced this issue Mar 13, 2019
Since Gradle 4.9 the run task can directly take arguments, see

https://docs.gradle.org/4.9/release-notes.html#command-line-args-supported-by-javaexec

However, note that any relative paths specified as arguments are
interpreted as relative to the project directory, see

gradle/gradle#6074

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@here.com>
@bmuskalla bmuskalla added this to the Unscheduled milestone Jun 4, 2020
@jjohannes jjohannes removed this from the Unscheduled milestone Mar 19, 2021
@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added the stale label Apr 16, 2022
@stale
Copy link

stale bot commented Jun 22, 2022

This issue has been automatically closed due to inactivity. If you can reproduce this on a recent version of Gradle or if you have a good use case for this feature, please feel free to to let know so we can reopen the issue. Please try to provide steps to reproduce, a quick explanation of your use case or a high-quality pull request.

@stale stale bot closed this as completed Jun 22, 2022
@wolfs wolfs closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants